mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-11 16:49:40 +01:00
33 lines
897 B
PHP
33 lines
897 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Str;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl\Str;
|
|
|
|
class TruncateTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideData
|
|
*/
|
|
public function testTruncate(string $expected, string $str, int $offset, int $width, ?string $trim_marker = null): void
|
|
{
|
|
self::assertSame($expected, Str\truncate($str, $offset, $width, $trim_marker));
|
|
}
|
|
|
|
public function provideData(): array
|
|
{
|
|
return [
|
|
['Hello', 'Hello, World!', 0, 5],
|
|
['He...', 'Hello, World!', 0, 5, '...'],
|
|
['Hello...', 'Hello, World!', 0, 8, '...'],
|
|
['héllö...', 'héllö, wôrld!', 0, 8, '...'],
|
|
['wôrld!', 'héllö, wôrld!', 7, 8, '...'],
|
|
['مرحبا...', 'مرحبا بكم', 0, 8, '...'],
|
|
['سيف', 'مرحبا سيف', 6, 8, '...'],
|
|
];
|
|
}
|
|
}
|