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 StartsWithTest extends TestCase
|
|
|
|
{
|
2019-12-26 23:10:57 +01:00
|
|
|
/**
|
|
|
|
* @dataProvider provideData
|
|
|
|
*/
|
|
|
|
public function testStartsWith(bool $expected, string $haystack, string $prefix): void
|
|
|
|
{
|
|
|
|
self::assertSame($expected, Str\starts_with($haystack, $prefix));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function provideData(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[true, 'Hello, World', 'Hello', ],
|
|
|
|
[false, 'Hello, World', 'world', ],
|
|
|
|
[false, 'Hello, World', '', ],
|
|
|
|
[false, 'hello, world', 'hey', ],
|
|
|
|
[true, 'azjezz', 'az', ],
|
|
|
|
[false, 'azjezz', 'Az', ],
|
|
|
|
[false, 'مرحبا بكم', 'بكم', ],
|
|
|
|
[true, 'مرحبا بكم', 'مرحبا', ],
|
|
|
|
[true, 'مرحبا سيف', 'مرحبا', 3],
|
|
|
|
[false, 'مرحبا سيف', 'سيف', 3],
|
|
|
|
[true, 'اهلا بكم', 'اهلا', 2],
|
|
|
|
[true, 'héllö wôrld', 'héllö', ],
|
|
|
|
[false, 'héllö wôrld', 'hello', ],
|
|
|
|
[true, 'fôo', 'fôo', ],
|
|
|
|
[true, 'fôo', 'f', ],
|
|
|
|
[true, 'fôo', 'fô', ],
|
|
|
|
];
|
|
|
|
}
|
2019-12-24 01:52:07 +01:00
|
|
|
}
|