2019-12-24 01:52:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Psl\Tests\Str;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-12-26 23:10:57 +01:00
|
|
|
use Psl\Str;
|
2019-12-24 01:52:07 +01:00
|
|
|
|
|
|
|
class EndsWithCiTest extends TestCase
|
|
|
|
{
|
2019-12-26 23:10:57 +01:00
|
|
|
/**
|
|
|
|
* @dataProvider provideData
|
|
|
|
*/
|
|
|
|
public function testEndsWithCi(bool $expected, string $haystack, string $suffix): void
|
|
|
|
{
|
2019-12-26 23:10:57 +01:00
|
|
|
if (null === Str\search_ci($haystack, $suffix)) {
|
|
|
|
self::assertFalse(Str\ends_with_ci($haystack, $suffix));
|
|
|
|
} else {
|
|
|
|
self::assertSame($expected, Str\ends_with_ci($haystack, $suffix));
|
|
|
|
}
|
2019-12-26 23:10:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function provideData(): array
|
|
|
|
{
|
|
|
|
return [
|
2019-12-26 23:10:57 +01:00
|
|
|
[true, 'Hello', 'Hello'],
|
2019-12-26 23:10:57 +01:00
|
|
|
[true, 'Hello, World', 'world', ],
|
2019-12-26 23:10:57 +01:00
|
|
|
[true, 'Hello, WorlḐ', 'worlḑ', ],
|
2019-12-26 23:10:57 +01:00
|
|
|
[false, 'T U N I S I A', 'e', ],
|
|
|
|
[true, 'تونس', 'س'],
|
2019-12-26 23:10:57 +01:00
|
|
|
[false, 'Hello, World', '', ],
|
2019-12-26 23:10:57 +01:00
|
|
|
[false, 'hello, world', 'hey', ],
|
2019-12-26 23:10:57 +01:00
|
|
|
[false, 'hello, world', 'hello cruel world'],
|
2019-12-26 23:10:57 +01:00
|
|
|
[true, 'azjezz', 'z', ],
|
|
|
|
[true, 'مرحبا بكم', 'بكم', ],
|
|
|
|
];
|
|
|
|
}
|
2019-12-24 01:52:07 +01:00
|
|
|
}
|