Files
fotospiel-app/tests/Feature/MarketingLocaleRoutingTest.php

96 lines
2.7 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\LegalPage;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class MarketingLocaleRoutingTest extends TestCase
{
use RefreshDatabase;
public function test_contact_page_is_accessible_in_german(): void
{
$response = $this->get('/de/kontakt');
$response->assertStatus(200);
}
public function test_contact_page_is_accessible_in_english(): void
{
$response = $this->get('/en/contact');
$response->assertStatus(200);
}
public function test_german_contact_slug_redirects_to_english_variant_when_locale_is_english(): void
{
$response = $this->get('/en/kontakt');
$response->assertRedirect(route('marketing.contact', [
'locale' => 'en',
]));
}
public function test_english_contact_slug_redirects_to_german_variant_when_locale_is_german(): void
{
$response = $this->get('/de/contact');
$response->assertRedirect(route('kontakt', [
'locale' => 'de',
]));
}
public function test_occasion_canonical_slugs_resolve_for_both_locales(): void
{
$this->get('/de/anlaesse/hochzeit')->assertStatus(200);
$this->get('/en/occasions/wedding')->assertStatus(200);
}
public function test_english_locale_redirects_from_german_occasions_slug(): void
{
$response = $this->get('/en/anlaesse/hochzeit');
$response->assertRedirect(route('occasions.type', [
'locale' => 'en',
'type' => 'wedding',
]));
}
public function test_german_locale_redirects_from_english_occasions_slug(): void
{
$response = $this->get('/de/occasions/wedding');
$response->assertRedirect(route('anlaesse.type', [
'locale' => 'de',
'type' => 'hochzeit',
]));
}
public function test_legal_pages_render_for_german_locale(): void
{
foreach (['impressum', 'datenschutz', 'agb'] as $slug) {
LegalPage::updateOrCreate(
['slug' => $slug, 'version' => 1],
[
'title' => [
'de' => ucfirst($slug),
'en' => ucfirst($slug),
],
'body_markdown' => [
'de' => '# '.$slug,
'en' => '# '.$slug,
],
'locale_fallback' => 'de',
'is_published' => true,
]
);
}
$this->get('/de/impressum')->assertStatus(200);
$this->get('/de/datenschutz')->assertStatus(200);
$this->get('/de/agb')->assertStatus(200);
}
}