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
|
|
|
|
2020-10-15 10:18:03 +02:00
|
|
|
final class StripSuffixTest extends TestCase
|
2019-12-24 01:52:07 +01:00
|
|
|
{
|
2019-12-26 23:10:57 +01:00
|
|
|
/**
|
|
|
|
* @dataProvider provideData
|
|
|
|
*/
|
|
|
|
public function testStripSuffix(string $expected, string $haystack, string $suffix): void
|
|
|
|
{
|
2020-10-15 10:18:03 +02:00
|
|
|
static::assertSame($expected, Byte\strip_suffix($haystack, $suffix));
|
2019-12-26 23:10:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function provideData(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['', 'Hello', 'Hello'],
|
|
|
|
['Hello, World', 'Hello, World', 'world', ],
|
|
|
|
['T U N I S I A', 'T U N I S I A', 'e', ],
|
|
|
|
['تون', 'تونس', 'س'],
|
|
|
|
['Hello, World', 'Hello, World', '', ],
|
|
|
|
['Hello, World', 'Hello, World', 'Hello, cruel world!', ],
|
|
|
|
['hello, world', 'hello, world', 'hey', ],
|
|
|
|
['azjez', 'azjezz', 'z', ],
|
|
|
|
['مرحبا ', 'مرحبا بكم', 'بكم', ],
|
|
|
|
['Hello', 'Hello, World', ', World', ],
|
|
|
|
['Hello, World', 'Hello, World', 'world', ],
|
|
|
|
['Hello, World', 'Hello, World', '', ],
|
|
|
|
['hello, world', 'hello, world', 'universe', ],
|
|
|
|
['azje', 'azjezz', 'zz', ],
|
|
|
|
['azjezz', 'azjezz', 'ZZ', ],
|
|
|
|
['مرحبا', 'مرحبا سيف', ' سيف', 3],
|
|
|
|
['اهلا', 'اهلا بكم', ' بكم', 3],
|
|
|
|
['héllö', 'héllö wôrld', ' wôrld', ],
|
|
|
|
['héllö wôrld', 'héllö wôrld', ' world', ],
|
|
|
|
['fô', 'fôo', 'o', ],
|
|
|
|
['fôo', 'fôo', 'ô', ],
|
|
|
|
['f', 'fôo', 'ôo', ],
|
|
|
|
];
|
|
|
|
}
|
2019-12-24 01:52:07 +01:00
|
|
|
}
|