mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-02 17:56:09 +01:00
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Str\Byte;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl\Str\Byte;
|
|
|
|
class SpliceTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideData
|
|
*/
|
|
public function testSplice(
|
|
string $expected,
|
|
string $string,
|
|
string $replacement,
|
|
int $offset,
|
|
?int $length = null
|
|
): void {
|
|
self::assertSame($expected, Byte\splice($string, $replacement, $offset, $length));
|
|
}
|
|
|
|
public function provideData(): array
|
|
{
|
|
return [
|
|
['', '', '', 0, null, ],
|
|
['hello darkness', 'hello world', 'darkness', 6, null, ],
|
|
['hello cruel world', 'hello world', ' cruel ', 5, 1],
|
|
['hello cruel world', 'hello world', ' cruel ', -6, 1, ],
|
|
['hello cruel world', 'hello world', ' cruel', 5, 0, ],
|
|
['hello darkness', 'hello ', 'darkness', 6, null, ],
|
|
['hello darkness', 'hello world', 'darkness', 6, 100, ],
|
|
['hello darkness', 'hello world', 'darkness', 6, 11, ],
|
|
[
|
|
'People linked by destiny will always find each other.',
|
|
'People linked by destiny will find each other.',
|
|
' always ',
|
|
29,
|
|
1
|
|
],
|
|
];
|
|
}
|
|
}
|