get('/magazin') ->assertSuccessful() ->assertSee('Magazin'); }); it('magazin list shows all five articles', function () { $this->get('/magazin') ->assertSuccessful() ->assertSee('Escrow-System') ->assertSee('Al Jaddaf') ->assertSee('Turnkey-Investments') ->assertSee('Supply-Chain-Management') ->assertSee('Local for Local'); }); it('magazin detail page loads for the first article', function () { $this->get('/magazin/escrow-system-dubai-investoren') ->assertSuccessful() ->assertSee('Escrow-System') ->assertSee('Dubai Land Department'); }); it('magazin detail page loads for the last article', function () { $this->get('/magazin/local-for-local-regionaler-moebelhandel') ->assertSuccessful() ->assertSee('Local for Local') ->assertSee('Support your Locals'); }); it('serves every article by its slug', function () { foreach (CmsArticle::LEGACY_ID_TO_SLUG as $slug) { $this->get('/magazin/'.$slug)->assertSuccessful(); } }); it('returns 404 for an unknown slug instead of silently showing the first article', function () { $this->get('/magazin/gibt-es-nicht')->assertNotFound(); }); it('links to the articles by slug, not by id', function () { $this->get('/magazin') ->assertSuccessful() ->assertSee('/magazin/escrow-system-dubai-investoren'); }); // ======================================== // Alte numerische URLs // ======================================== it('redirects the old numeric URLs permanently to the slug', function () { foreach (CmsArticle::LEGACY_ID_TO_SLUG as $id => $slug) { $this->get('/magazin/'.$id) ->assertStatus(301) ->assertRedirect('/magazin/'.$slug); } }); it('returns 404 for a numeric URL that never existed', function () { $this->get('/magazin/999')->assertNotFound(); }); // ======================================== // CMS-Anbindung // ======================================== it('renders what is maintained in the CMS, not the lang file', function () { CmsArticle::factory()->create([ 'slug' => 'escrow-system-dubai-investoren', 'title' => 'Im CMS geänderter Titel', 'is_published' => true, 'order' => 1, 'content' => ['de' => ['intro' => 'Im CMS geänderter Einstieg.', 'sections' => []]], ]); $this->get('/magazin') ->assertSuccessful() ->assertSee('Im CMS geänderter Titel'); $this->get('/magazin/escrow-system-dubai-investoren') ->assertSuccessful() ->assertSee('Im CMS geänderter Titel'); }); it('hides unpublished articles from the list and returns 404 on their detail page', function () { CmsArticle::factory()->create([ 'slug' => 'noch-nicht-fertig', 'title' => 'Entwurf, noch nicht öffentlich', 'is_published' => false, 'order' => 1, ]); // Ein veroeffentlichter Artikel muss existieren, sonst greift der Lang-Fallback. CmsArticle::factory()->create([ 'slug' => 'escrow-system-dubai-investoren', 'title' => 'Veröffentlicht', 'is_published' => true, 'order' => 2, ]); $this->get('/magazin') ->assertSuccessful() ->assertDontSee('Entwurf, noch nicht öffentlich'); $this->get('/magazin/noch-nicht-fertig')->assertNotFound(); }); it('falls back to the lang file while no articles are maintained', function () { expect(CmsArticle::count())->toBe(0); $this->get('/magazin') ->assertSuccessful() ->assertSee('Escrow-System'); }); it('prefers the CMS over the lang file once articles exist', function () { CmsArticle::factory()->create([ 'slug' => 'nur-dieser-eine', 'title' => 'Einziger gepflegter Artikel', 'is_published' => true, 'order' => 1, ]); $this->get('/magazin') ->assertSuccessful() ->assertSee('Einziger gepflegter Artikel') ->assertDontSee('Al Jaddaf'); }); // ======================================== // Neue Interior-Beiträge // ======================================== it('leads the list with the interior articles, not with the dubai ones', function () { $slugs = array_keys(CmsArticle::forFrontend()); expect($slugs[0])->toBe('massanfertigung-warum-der-millimeter-zaehlt') ->and($slugs[1])->toBe('kueche-planen-vom-wunsch-zum-grundriss'); }); it('serves the two new articles by their own slug', function () { $this->get('/magazin/massanfertigung-warum-der-millimeter-zaehlt') ->assertSuccessful() ->assertSee('Nach Maß statt von der Stange', false); $this->get('/magazin/kueche-planen-vom-wunsch-zum-grundriss') ->assertSuccessful() ->assertSee('Küche planen', false); }); it('does not invent legacy numeric urls for the new articles', function () { // Die Slugs kommen aus der Lang-Datei, nicht aus LEGACY_ID_TO_SLUG – /magazin/6 gab es nie. expect(CmsArticle::slugForLegacyId(6))->toBeNull(); $this->get('/magazin/6')->assertNotFound(); }); it('takes the slug from the lang entry when one is given', function () { expect(CmsArticle::slugForLangArticle(6, ['slug' => 'eigener-slug']))->toBe('eigener-slug') ->and(CmsArticle::slugForLangArticle(1, []))->toBe('escrow-system-dubai-investoren') ->and(CmsArticle::slugForLangArticle(99, []))->toBeNull(); });