endtoend-test-psl/tests/Psl/Str/ChunkTest.php
2019-12-27 05:42:24 +01:00

33 lines
827 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
namespace Psl\Tests\Str;
use PHPUnit\Framework\TestCase;
use Psl\Str;
class ChunkTest extends TestCase
{
/**
* @dataProvider provideData
*/
public function testCapitalize(array $expected, string $value, int $chunk_size = 1): void
{
self::assertSame($expected, Str\chunk($value, $chunk_size));
}
public function provideData(): array
{
return [
[['h', 'e', 'l', 'l', 'o'], 'hello', ],
[['h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'], 'hello, world', ],
[['Al', 'ph', 'a ', ' '], 'Alpha ', 2, ],
[['م', 'ر', 'ح', 'ب', 'ا', ' ', 'ب', 'ك', 'م'], 'مرحبا بكم', ],
[['مرحبا بكم'], 'مرحبا بكم', 9, ],
[[], ''],
];
}
}