endtoend-test-psl/tests/Psl/Str/WrapTest.php

43 lines
1.4 KiB
PHP
Raw Normal View History

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 WrapTest extends TestCase
{
2019-12-26 23:10:57 +01:00
/**
* @dataProvider provideData
*/
public function testWrap(
string $expected,
string $str,
int $width = 75,
string $break = "\n",
bool $cut = false
): void {
2019-12-26 23:10:57 +01:00
self::assertSame($expected, Str\wrap($str, $width, $break, $cut));
}
public function provideData(): array
{
return [
['Hello', 'Hello'],
['', ''],
['☕ ~ ☕ ~ ☕', '☕ ☕ ☕', 1, ' ~ '],
["♈♉\n♊♋\n♌♍\n♎♏\n♐♑\n♒♓", "♈♉♊♋♌♍♎♏♐♑\n♒♓", 2, "\n", true],
["héllö,-\nwôrld", 'héllö, wôrld', 8, "-\n", true],
['مرحبا<br />بكم', 'مرحبا بكم', 3, '<br />', false],
['مرح<br />با<br />بكم', 'مرحبا بكم', 3, '<br />', true],
["こんに\nちは世\n", 'こんにちは世界', 3, "\n", true],
['こんにちは世界', 'こんにちは世界', 3, "\n", false],
['こんにちは世界', 'こんにちは世界', 7, "\n", true],
[Str\concat('ส', '-', 'ว', '-', 'ั', '-', 'ส', '-', 'ด', '-', 'ี'), 'สวัสดี', 1, '-', true],
['สวัสดี', 'สวัสดี', 1, '-', false],
];
}
2019-12-24 01:52:07 +01:00
}