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 ChunkTest extends TestCase
|
|
|
|
|
{
|
2019-12-26 23:10:57 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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, ],
|
|
|
|
|
[[], ''],
|
|
|
|
|
];
|
|
|
|
|
}
|
2019-12-24 01:52:07 +01:00
|
|
|
|
}
|