2019-12-24 01:52:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Psl\Tests\Str\Byte;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-12-26 23:10:57 +01:00
|
|
|
use Psl\Str\Byte;
|
2019-12-24 01:52:07 +01:00
|
|
|
|
|
|
|
class StripPrefixTest extends TestCase
|
|
|
|
{
|
2019-12-26 23:10:57 +01:00
|
|
|
/**
|
|
|
|
* @dataProvider provideData
|
|
|
|
*/
|
|
|
|
public function testStripPrefix(string $expected, string $haystack, string $prefix): void
|
|
|
|
{
|
|
|
|
self::assertSame($expected, Byte\strip_prefix($haystack, $prefix));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function provideData(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['World', 'Hello, World', 'Hello, '],
|
|
|
|
['Hello, World', 'Hello, World', 'world'],
|
|
|
|
['Hello, World', 'Hello, World', ''],
|
|
|
|
['hello, world', 'hello, world', 'hey'],
|
|
|
|
['jezz', 'azjezz', 'az'],
|
|
|
|
['azjezz', 'azjezz', 'Az'],
|
|
|
|
['مرحبا بكم', 'مرحبا بكم', 'بكم'],
|
|
|
|
['بكم', 'مرحبا بكم', 'مرحبا '],
|
|
|
|
['سيف', 'مرحبا سيف', 'مرحبا ', 3],
|
|
|
|
['مرحبا سيف', 'مرحبا سيف', 'سيف', 3],
|
|
|
|
[' بكم', 'اهلا بكم', 'اهلا', 2],
|
|
|
|
['wôrld', 'héllö wôrld', 'héllö '],
|
|
|
|
['héllö wôrld', 'héllö wôrld', 'hello'],
|
|
|
|
['', 'fôo', 'fôo'],
|
|
|
|
['ôo', 'fôo', 'f'],
|
|
|
|
['o', 'fôo', 'fô'],
|
|
|
|
];
|
|
|
|
}
|
2019-12-24 01:52:07 +01:00
|
|
|
}
|