symbol();
$html = '
Absatz
Eins
';
$canonical = FormattedText::canonical($html, true);
$this->assertSame($html, $canonical);
$this->assertSame($canonical, FormattedText::canonical($canonical, true), 'Die kanonische Form ist stabil.');
}
public function test_invalid_values_and_misplaced_markers_are_dropped(): void
{
$symbol = $this->symbol();
$this->assertSame('A
', FormattedText::canonical('A
', true));
$this->assertSame('A
', FormattedText::canonical('A
', true));
// Kreise gehören zur Nummerierung, Symbole zur Aufzählung; unbekannte Farbe entfällt, die Nummerierung bleibt im Kreis.
$this->assertSame('Eins
', FormattedText::canonical('Eins ', true));
$this->assertSame('', FormattedText::canonical('', true));
$this->assertSame('', FormattedText::canonical('', true), 'Ohne Symbol kein Symbolmarker.');
$this->assertSame('Eins
', FormattedText::canonical('Eins ', true));
$this->assertSame('A
', FormattedText::canonical('A
', true), 'Fremde Attribute entfallen.');
}
public function test_a_symbol_stays_only_on_a_top_level_paragraph(): void
{
$symbol = $this->symbol();
$this->assertSame('', FormattedText::canonical('', true));
$this->assertSame('Zitat
', FormattedText::canonical('Zitat
', true));
$this->assertStringNotContainsString('data-symbol', FormattedText::canonical('', true));
}
public function test_the_catalog_profiles_know_no_markers(): void
{
$symbol = $this->symbol();
$this->assertSame('A
', FormattedText::canonical('A
'));
$this->assertSame('E
', FormattedText::canonical('E '));
}
public function test_the_output_inserts_symbols_and_circles_and_leaves_plain_text_alone(): void
{
$symbol = $this->symbol();
$this->assertSame([], DesignPalette::save(null, 'Sand', '#f3e9d2', '#15243a'));
$plain = 'Nur Text
';
$this->assertSame($plain, TextMarkers::decorate($plain), 'Ein Text ohne Zeichen bleibt Byte für Byte gleich.');
$html = TextMarkers::decorate(
'Mit Symbol
'
.'Eins
Zwei
'
.'',
);
$this->assertStringContainsString('assertStringContainsString('class="text-list-circle"', $html);
$this->assertStringContainsString('--tone-bg: #f3e9d2; --tone-fg: #15243a', $html);
$this->assertSame(2, substr_count($html, 'text-list-symbol__mark'), 'Ein Symbol je Aufzählungspunkt.');
}
public function test_a_colour_that_no_longer_exists_falls_back_to_the_default(): void
{
$html = TextMarkers::decorate('Eins
');
$this->assertStringContainsString('--tone-bg: #032551', $html);
}
public function test_bild_und_text_keeps_the_markers_and_drops_invalid_ones(): void
{
$symbol = $this->symbol();
$kept = RichText::sanitize('A
E ');
$this->assertStringContainsString('data-symbol="'.$symbol.'"', $kept);
$this->assertStringContainsString('data-marker="circle"', $kept);
$dropped = RichText::sanitize('A
');
$this->assertStringNotContainsString('data-', $dropped);
}
public function test_the_published_page_shows_the_markers_in_text_and_in_bild_und_text(): void
{
$symbol = $this->symbol();
$body = 'Erster Absatz
Eins
';
$page = Page::query()->create(['path' => '/zeichen']);
$service = app(PageService::class);
$service->publish($page, $service->saveRevision($page, [
['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'prose', 'v' => 2, 'settings' => [], 'data' => ['body' => $body]]]],
['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'image_text', 'v' => 2, 'settings' => [], 'data' => ['title' => 'Bild', 'body' => $body]]]],
], null, null, null));
$html = $this->get('/zeichen')->assertOk()->getContent();
$this->assertSame(2, substr_count($html, 'class="has-symbol"'));
$this->assertSame(2, substr_count($html, 'class="text-list-circle"'));
}
public function test_a_colour_used_in_a_text_is_in_use(): void
{
$this->assertSame([], DesignPalette::save(null, 'Sand', '#f3e9d2', '#15243a'));
$page = Page::query()->create(['path' => '/farbe-im-text']);
$service = app(PageService::class);
$service->saveRevision($page, [
['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'prose', 'v' => 2, 'settings' => [], 'data' => ['body' => 'Eins
']]]],
], null, null, null);
$uses = DesignPalette::usage();
$this->assertArrayHasKey('c1', $uses);
$this->assertSame('/farbe-im-text', $uses['c1'][0]['path']);
$this->assertNotSame([], DesignPalette::remove('c1'), 'Eine Farbe, die ein Text verwendet, lässt sich nicht entfernen.');
}
public function test_every_widget_with_formatted_text_shows_the_markers(): void
{
$symbol = $this->symbol();
$body = 'Absatz
Eins
';
$one = fn (array $widget): array => ['layout' => 'u4', 'style' => [], 'slots' => [$widget]];
$page = Page::query()->create(['path' => '/alle-widgets']);
$service = app(PageService::class);
$service->publish($page, $service->saveRevision($page, [
$one(['type' => 'heading', 'v' => 2, 'settings' => [], 'data' => ['heading' => 'Titel', 'intro' => $body]]),
$one(['type' => 'cards', 'v' => 2, 'variant' => 'standard', 'settings' => ['link_style' => 'text'], 'data' => ['items' => [['title' => 'K', 'text' => $body]]]]),
$one(['type' => 'notice', 'v' => 1, 'settings' => [], 'data' => ['title' => 'Hinweis', 'text' => $body]]),
], null, null, null));
$html = $this->get('/alle-widgets')->assertOk()->getContent();
$this->assertSame(3, substr_count($html, 'class="has-symbol"'), 'Überschrift, Karten und Hinweis zeigen das Symbol.');
$this->assertSame(3, substr_count($html, 'class="text-list-circle"'));
}
}