fix: drop blank lines and split on any line break in nl2list

This commit is contained in:
fromme committed 2026-11-12 11:25:30 +01:00
1 parent 9ba6529ee0
commit eda7856e48
2 files changed
+40 -1

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace App\Tests\Twig;
use App\Twig\AppRuntime;
use PHPUnit\Framework\TestCase;
/**
* The default benefits of an assignment end with a line break, and textareas submit \r\n: neither
* may turn into an empty bullet or a stray carriage return.
*/
class Nl2ListTest extends TestCase
{
public function testTrailingAndBlankLinesAreNoItems(): void
{
$this->assertSame(
'<ul class="list-disc pl-4"><li>Unterkunft</li><li>Skipass</li></ul>',
$this->createRuntime()->nl2List("Unterkunft\n\nSkipass\n")
);
}
public function testWindowsLineBreaksSplitCleanly(): void
{
$this->assertSame(
'<ul class="list-disc pl-4"><li>Anreise im E&amp;P Reisebus</li><li>Verpflegung</li></ul>',
$this->createRuntime()->nl2List("Anreise im E&P Reisebus\r\nVerpflegung\r\n")
);
}
private function createRuntime(): AppRuntime
{
$reflection = new \ReflectionClass(AppRuntime::class);
return $reflection->newInstanceWithoutConstructor();
}
}