2019-12-24 01:52:07 +01:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Psl\Tests\Str\Byte;
|
|
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-12-26 23:10:57 +01:00
|
|
|
|
use Psl\Str\Byte;
|
2019-12-24 01:52:07 +01:00
|
|
|
|
|
2020-10-15 10:18:03 +02:00
|
|
|
|
final class ChunkTest extends TestCase
|
2019-12-24 01:52:07 +01:00
|
|
|
|
{
|
2019-12-26 23:10:57 +01:00
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideData
|
|
|
|
|
*/
|
|
|
|
|
public function testCapitalize(array $expected, string $value, int $chunk_size = 1): void
|
|
|
|
|
{
|
2020-10-15 10:18:03 +02:00
|
|
|
|
static::assertSame($expected, Byte\chunk($value, $chunk_size));
|
2019-12-26 23:10:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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, ],
|
|
|
|
|
[['م', 'ر', 'ح', 'ب', 'ا'], 'مرحبا', 2],
|
|
|
|
|
[[], ''],
|
|
|
|
|
];
|
|
|
|
|
}
|
2019-12-24 01:52:07 +01:00
|
|
|
|
}
|