39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?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&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();
|
|
}
|
|
}
|