Skip to content

Commit 3542818

Browse files
committed
test: add regression tests for word_wrap() with small character limits
1 parent cf6fe33 commit 3542818

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎tests/system/Helpers/TextHelperTest.php‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,27 @@ public function testEllipsize(): void
358358
}
359359
}
360360

361+
/**
362+
* A character limit below 2 used to make word_wrap() loop forever.
363+
*/
364+
#[DataProvider('provideWordWrapSmallCharLimit')]
365+
public function testWordWrapSmallCharLimit(int $charlim): void
366+
{
367+
$this->assertSame("aaa\na\nbbb\nb", word_wrap('aaaa bbbb', $charlim));
368+
}
369+
370+
/**
371+
* @return iterable<string, array{int}>
372+
*/
373+
public static function provideWordWrapSmallCharLimit(): iterable
374+
{
375+
yield 'one' => [1];
376+
377+
yield 'zero' => [0];
378+
379+
yield 'negative' => [-5];
380+
}
381+
361382
public function testWordWrap(): void
362383
{
363384
$string = 'Here is a simple string of text that will help us demonstrate this function.';

0 commit comments

Comments
 (0)