*/ private function heading(string $text): array { return ['type' => 'heading', 'v' => 1, 'data' => ['heading' => $text]]; } /** * @return array */ private function prose(string $text): array { return ['type' => 'prose', 'v' => 1, 'data' => ['body' => $text]]; } /** * @param list> $sections */ private function publish(string $path, array $sections): Page { $service = app(PageService::class); $page = Page::query()->create(['path' => $path]); $service->publish($page, $service->saveRevision($page, $sections, null, null, null)); return $page->fresh(); } public function test_sections_render_grid_ratios_backgrounds_and_dividers(): void { $this->publish('/raster', [ ['layout' => 'u4', 'style' => ['background' => 'dark', 'divider' => 'accent'], 'slots' => [$this->heading('Einstieg')]], ['layout' => 'u1_3', 'style' => ['background' => 'light', 'width' => 'wide', 'divider' => 'line'], 'slots' => [$this->prose('Schmal'), $this->prose('Breit')]], ['layout' => 'u1_1_1_1', 'style' => ['background' => 'accent', 'spacing' => 'large'], 'slots' => [$this->prose('A'), $this->prose('B'), $this->prose('C'), $this->prose('D')]], ['layout' => 'u2_2', 'style' => ['divider' => 'line'], 'slots' => [$this->prose('Letzter')]], ]); $html = $this->get('/raster')->assertOk()->getContent(); $this->assertStringContainsString('page-section section-bg-dark section-width-standard section-space-top-compact section-space-bottom-compact section-gap-normal section-layout-u4 scope-dark', $html); $this->assertStringContainsString('section-bg-light section-width-wide', $html); $this->assertStringContainsString('--section-cols-lg: minmax(0, 1fr) minmax(0, 3fr); --section-cols-md: minmax(0, 1fr)', $html); $this->assertStringContainsString('--section-cols-md: repeat(2, minmax(0, 1fr))', $html, 'Vier gleiche Plätze stehen auf dem Tablet als 2 × 2.'); // Eingabe im Format der Version 1 („spacing“): oben und unten großzügig, Widget-Abstand wie bisher normal. $this->assertStringContainsString('section-bg-accent section-width-standard section-space-top-large section-space-bottom-large section-gap-normal section-layout-u1-1-1-1 scope-accent', $html); $this->assertStringContainsString('section-divider section-divider-accent', $html); $this->assertSame(1, substr_count($html, 'section-divider section-divider-line'), 'Nach dem letzten Abschnitt steht kein Trenner.'); $this->assertSame(1, substr_count($html, '

'), 'Nur das erste Widget der Seite ist Überschrift erster Ordnung.'); $this->assertLessThan(strpos($html, 'Breit'), strpos($html, 'Schmal'), 'Lese- und Fokusreihenfolge folgt den Plätzen.'); } public function test_empty_slots_keep_their_place_and_empty_sections_leave_no_gaps(): void { $this->publish('/luecken', [ ['layout' => 'u1_2_1', 'style' => [], 'slots' => [$this->prose('Links'), null, $this->prose('Rechts')]], ['layout' => 'u2_2', 'style' => ['background' => 'dark'], 'slots' => [null, null]], ['layout' => 'u1_3', 'style' => [], 'slots' => [null, $this->prose('Allein')]], ]); $html = $this->get('/luecken')->assertOk()->getContent(); // 1 + 2 + 1 mit leerer Mitte: Links und Rechts behalten ihre Spalten, die Mitte bleibt als leere Spalte stehen. $this->assertStringContainsString('data-slots="3" style="--section-cols-lg: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr)', $html); $this->assertMatchesRegularExpression('~
.*?Links.*?
.*?Rechts~s', $html); // 1 + 3 mit leerem ersten Platz: Das Widget steht im breiten Platz rechts, nicht links. $this->assertStringContainsString('data-slots="2" style="--section-cols-lg: minmax(0, 1fr) minmax(0, 3fr)', $html); $this->assertMatchesRegularExpression('~
.*?Allein~s', $html); $this->assertStringNotContainsString('section-bg-dark', $html, 'Ein Abschnitt ohne Inhalt entfällt samt Fläche.'); $this->assertSame(2, substr_count($html, 'section-slot-empty" data-units'), 'Nur leere Plätze in Abschnitten mit Inhalt bleiben stehen.'); } public function test_a_fully_empty_row_of_the_tablet_grid_is_marked_so_it_leaves_no_gap(): void { $this->publish('/zeilen', [ ['layout' => 'u1_1_1_1', 'style' => [], 'slots' => [null, null, $this->prose('Drei'), $this->prose('Vier')]], ['layout' => 'u1_1_1_1', 'style' => [], 'slots' => [$this->prose('Eins'), null, null, null]], ['layout' => 'u1_1_1_1', 'style' => [], 'slots' => [null, $this->prose('Zwei'), null, $this->prose('Vier')]], ['layout' => 'u1_3', 'style' => [], 'slots' => [null, $this->prose('Allein')]], ]); $html = $this->get('/zeilen')->assertOk()->getContent(); $sections = array_slice(explode('
assertStringNotContainsString('section-slot-empty-row', $sections[2]); $this->assertStringContainsString('section-grid section-grid-tablet-columns', $sections[0]); // Ungleiche Raster stapeln auf dem Tablet und kennen keine Zeilen nebeneinander. $this->assertStringNotContainsString('section-grid-tablet-columns', $sections[3]); $this->assertStringNotContainsString('section-slot-empty-row', $sections[3]); } public function test_background_image_comes_from_the_public_area_with_focus_and_overlay(): void { Queue::fake(); $this->publish('/bild', [ ['layout' => 'u4', 'style' => ['background' => 'image', 'image' => 'cms/flaeche.jpg', 'focus' => 'top_left', 'overlay' => 'dark'], 'slots' => [$this->heading('Auf Bild')]], ['layout' => 'u4', 'style' => ['background' => 'image', 'image' => 'cms/zweites.jpg', 'overlay' => 'light'], 'slots' => [$this->prose('Hell')]], ]); $html = $this->get('/bild')->assertOk()->getContent(); $this->assertStringContainsString('section-bg-image', $html); $this->assertStringContainsString('section-overlay-dark scope-dark', $html); $this->assertStringContainsString('section-overlay-light scope-light', $html); $this->assertMatchesRegularExpression('#]*object-position: 0% 0%#', $html); $this->assertMatchesRegularExpression('#publish('/gleich', [ ['layout' => 'u2_2', 'style' => ['background' => 'light'], 'slots' => [$this->heading('Links'), $this->prose('Rechts')]], ]); $editor = User::factory()->redakteur()->create(); $public = $this->get('/gleich')->getContent(); $preview = $this->actingAs($editor, 'staff')->get(route('pages.preview', $page->published_revision_id))->getContent(); $this->assertSame($this->sectionsMarkup($public), $this->sectionsMarkup($preview)); $this->assertStringContainsString('Vorschau einer unveröffentlichten Revision', $preview); } public function test_public_page_is_identical_for_guests_and_members(): void { // Schrift-Vorabladehinweise gibt der Rahmen je Prozess nur einmal aus; sie hängen nicht vom Besucher ab. $withoutPreload = fn (string $html): string => preg_replace('#]*>\s*#', '', $html); $guest = $withoutPreload($this->get('/praevention')->assertOk()->getContent()); $member = $withoutPreload($this->actingAs(User::factory()->create())->get('/praevention')->assertOk()->getContent()); $this->assertSame($guest, $member, 'Öffentliche Seiten hängen nicht vom Anmeldestatus ab (ADR-32).'); $this->assertStringContainsString('href="'.route('member.dashboard').'"', $guest); $this->assertStringContainsString('Mitgliederbereich', $guest); } public function test_global_layout_has_header_navigation_mobile_menu_and_footer(): void { // Der Warenkorb gehört zum Shop (Etappe 1, nur Testzahlung). Ohne aktiven Shop erscheint kein Kaufknopf. config(['services.payment.driver' => 'unbekannt']); $html = $this->get('/praevention')->assertOk()->getContent(); $this->assertStringContainsString('Prävention#', $html); $this->assertStringContainsString('data-site-menu-button', $html); $this->assertStringContainsString('aria-controls="site-nav"', $html); $this->assertStringContainsString('class="site-footer scope-dark"', $html); $this->assertStringContainsString('', $html); $this->assertStringContainsString('Impressum', $html); $this->assertStringNotContainsString('Warenkorb', $html, 'Ohne aktiven Shop erscheint kein Kaufknopf.'); $this->assertStringNotContainsString('fonts.bunny.net', $html); $this->assertStringNotContainsString('fonts.googleapis.com', $html); } public function test_cart_entry_appears_only_when_the_shop_is_enabled(): void { // Seit Etappe 1 ist der Warenkorb umgesetzt: Der Eintrag folgt dem Shop (Testzahlung, nie Produktion) // statt der früheren Vorbereitung über cms.cart.*. $this->get('/praevention')->assertSee('Warenkorb')->assertSee('href="'.route('cart').'"', false); config(['services.payment.driver' => 'unbekannt']); $this->get('/praevention')->assertDontSee('Warenkorb'); } public function test_submenus_footer_groups_and_hidden_parents(): void { $parent = NavigationItem::query()->where('label', 'Prävention')->firstOrFail(); NavigationItem::query()->create(['label' => 'Grenzen', 'url' => '/themen/grenzen', 'placement' => 'header', 'parent_id' => $parent->id, 'sort_order' => 1]); NavigationItem::query()->create(['label' => 'Kontaktformular', 'url' => '/kontakt', 'placement' => 'footer_contact', 'sort_order' => 1]); NavigationItem::query()->create(['label' => 'Fußkind', 'url' => '/x', 'placement' => 'footer', 'parent_id' => $parent->id, 'sort_order' => 2]); $html = $this->get('/praevention')->getContent(); $this->assertStringContainsString('site-nav-item has-children is-active-trail', $html); $this->assertStringContainsString('aria-controls="untermenue-'.$parent->id.'"', $html); $this->assertStringContainsString('Untermenü Prävention', $html); $this->assertMatchesRegularExpression('#
    \s*
  • Grenzen
  • #', $html); $this->assertStringContainsString('', $html); $this->assertNull(NavigationItem::query()->where('label', 'Fußkind')->value('parent_id'), 'Untermenüs gibt es nur in der Hauptnavigation.'); $parent->update(['is_visible' => false]); $this->assertStringNotContainsString('Grenzen', $this->get('/praevention')->getContent(), 'Mit dem Eintrag ist auch sein Untermenü ausgeblendet.'); } public function test_deleting_a_parent_moves_its_children_to_the_top_level(): void { $parent = NavigationItem::query()->where('label', 'Prävention')->firstOrFail(); $child = NavigationItem::query()->create(['label' => 'Grenzen', 'url' => '/themen/grenzen', 'placement' => 'header', 'parent_id' => $parent->id]); $parent->delete(); $this->assertNull($child->fresh()->parent_id); $this->get('/ueber')->assertSee('Grenzen'); } public function test_member_area_uses_the_shared_wordmark_and_tokens(): void { $member = User::factory()->create(); $this->actingAs($member) ->get(route('member.dashboard')) ->assertOk() // Seit Kit 14 trägt der Mitgliederbereich die freigegebene Wortmarke der Website und eine einzige Navigation. ->assertSee('class="brand brand-logo mb-brand"', false) ->assertSee('data-brand-status="freigegeben"', false) ->assertSee('class="mb-nav"', false) ->assertSee('class="mb-dock"', false); } public function test_rollback_column_lets_the_previous_renderer_show_every_widget(): void { $page = $this->publish('/rueckfall', [ ['layout' => 'u1_1_1_1', 'style' => ['background' => 'dark'], 'slots' => [$this->heading('Erstens'), $this->prose('Zweitens'), null, $this->prose('Viertens')]], ]); // Darstellung wie in der Fassung vor dem Abschnittsraster: flache Liste aus der Spalte blocks. $html = app(WidgetRenderer::class)->renderAll($page->publishedRevision->blocks, RenderContext::publicPage())->toHtml(); foreach (['Erstens', 'Zweitens', 'Viertens'] as $text) { $this->assertStringContainsString($text, $html); } } public function test_restore_copies_sections_and_rollback_column_unchanged(): void { $page = $this->publish('/wieder', [ ['layout' => 'u2_2', 'style' => ['background' => 'light'], 'slots' => [$this->heading('Früher'), $this->prose('Stand')]], ]); $first = $page->publishedRevision; $service = app(PageService::class); $service->publish($page, $service->saveRevision($page, [['layout' => 'u4', 'style' => [], 'slots' => [$this->heading('Später')]]], null, null, null)); $restored = $service->restore($page->fresh(), $first, null); $service->publish($page->fresh(), $restored); $this->assertSame($first->sections, $restored->fresh()->sections); $this->assertSame($first->blocks, $restored->fresh()->blocks); $this->get('/wieder')->assertSee('Früher')->assertDontSee('Später'); } public function test_program_reference_in_a_narrow_slot_reads_catalog_data(): void { $program = $this->composition('Programm Abstand', 'programm', summary: 'Kurzbeschreibung aus den Fachdaten'); $this->publish('/programme-schmal', [ ['layout' => 'u3_1', 'style' => [], 'slots' => [ $this->prose('Hauptinhalt'), ['type' => 'catalog_cards', 'v' => 1, 'variant' => 'compact', 'data' => [], 'refs' => ['items' => [['type' => 'composition', 'id' => $program->composition_id]]]], ]], ]); $this->get('/programme-schmal') ->assertOk() ->assertSee('Programm Abstand') ->assertSee('catalog-cards catalog-cards-compact', false) ->assertSee('data-units="1"', false); } private function sectionsMarkup(string $html): string { preg_match('#]*>(.*)#s', $html, $match); $markup = preg_replace('#

    #s', '', $match[1] ?? ''); return trim(preg_replace('/\s+/', ' ', $markup)); } }