endtoend-test-psl/tests/Psl/Str/Byte/WordsTest.php
2020-01-02 00:00:08 +01:00

35 lines
887 B
PHP

<?php
declare(strict_types=1);
namespace Psl\Tests\Str\Byte;
use PHPUnit\Framework\TestCase;
use Psl\Str\Byte;
class WordsTest extends TestCase
{
/**
* @dataProvider provideData
*/
public function testWords(array $expected, string $string, ?string $extra_chars = null): void
{
self::assertSame($expected, Byte\words($string, $extra_chars));
}
public function provideData(): array
{
return [
[[], ''],
[['Hello'], 'Hello'],
[['Hello'], 'Hello', ' '],
[[0 => 'Hello', 7 => 'World'], 'Hello, World!'],
[[0 => 'Hello', 6 => ' World'], 'Hello, World!', ' '],
[[0 => 'Hello', 7 => 'World!'], 'Hello, World!', '!'],
[[0 => 'Hello,', 7 => 'World!'], 'Hello, World!', '!,'],
[[0 => 'Hello, World!'], 'Hello, World!', '!, '],
];
}
}