travelTo(CarbonImmutable::parse('2026-10-22 10:00')); $this->seed([PropertySeeder::class, WebsiteContentSeeder::class, SiteSeeder::class]); $this->themesPath = storage_path('framework/testing/theme-tooling'); File::deleteDirectory($this->themesPath); File::ensureDirectoryExists($this->themesPath); config(['themes.paths' => [$this->themesPath, resource_path('themes')]]); app()->forgetInstance(ThemeRegistry::class); } protected function tearDown(): void { File::deleteDirectory($this->themesPath); parent::tearDown(); } public function test_installed_themes_fulfil_the_theme_contract(): void { config(['themes.paths' => [resource_path('themes')]]); app()->forgetInstance(ThemeRegistry::class); $this->artisan('themes:check')->assertSuccessful(); } public function test_new_theme_is_created_next_to_the_existing_ones_and_passes_the_check(): void { $this->artisan('themes:make', ['key' => 'ostsee-nacht', '--name' => 'Ostsee-Nacht'])->assertSuccessful(); app()->forgetInstance(ThemeRegistry::class); $registry = app(ThemeRegistry::class); $theme = $registry->get('ostsee-nacht'); $this->assertSame(['ostsee-nacht', 'ostsee-licht'], array_map(fn ($manifest) => $manifest->key, $registry->chain('ostsee-nacht'))); $this->assertArrayHasKey('ostsee-nacht', $registry->options()); $this->assertSame(array_keys($registry->tokens('ostsee-licht')), array_keys($theme->tokens)); $this->assertSame([], app(ThemeChecker::class)->check($theme)['errors']); $this->assertFileExists(resource_path('themes/ostsee-licht/theme.json'), 'the base theme stays untouched'); $this->artisan('themes:make', ['key' => 'ostsee-nacht'])->assertFailed(); } public function test_checker_reports_contract_violations(): void { $this->artisan('themes:make', ['key' => 'kaputt'])->assertSuccessful(); $path = $this->themesPath.'/kaputt'; $manifest = json_decode(File::get($path.'/theme.json'), true); $manifest['tokens']['muted']['default'] = '#CCCCCC'; File::put($path.'/theme.json', json_encode($manifest)); File::put($path.'/views/sections/booking.blade.php', '
{{ $heading }}
'); File::put($path.'/views/sections/text-image.blade.php', '
'); File::put($path.'/theme.css', File::get($path.'/theme.css')."\n@import url('https://fonts.googleapis.com/css2?family=Inter');\n"); app()->forgetInstance(ThemeRegistry::class); $errors = implode("\n", app(ThemeChecker::class)->check(app(ThemeRegistry::class)->get('kaputt'))['errors']); $this->assertStringContainsString('Kalender/Anfrage fehlt', $errors); $this->assertStringContainsString('feste Farbe „bg-blue-700“', $errors); $this->assertStringContainsString('unbekannter Baustein', $errors); $this->assertStringContainsString('fonts.googleapis', $errors); $this->assertStringContainsString('Kontrast muted auf ground', $errors); $this->artisan('themes:check', ['theme' => 'kaputt'])->assertFailed(); } public function test_contrast_follows_wcag(): void { $this->assertSame(21.0, ThemeChecker::contrast('#000000', '#FFFFFF')); $this->assertGreaterThan(4.5, ThemeChecker::contrast('#4E5C66', '#F6F2EA')); $this->assertLessThan(4.5, ThemeChecker::contrast('#999', '#FFF')); } public function test_signed_preview_shows_the_site_with_another_theme_without_switching(): void { $this->artisan('themes:make', ['key' => 'ostsee-nacht', '--name' => 'Ostsee-Nacht'])->assertSuccessful(); File::put($this->themesPath.'/ostsee-nacht/views/sections/facts.blade.php', '
Eckdaten im neuen Theme
'); app()->forgetInstance(ThemeRegistry::class); $this->withoutVite(); $this->get(URL::temporarySignedRoute('home', now()->addHour(), ['theme' => 'ostsee-nacht'])) ->assertOk() ->assertSee('Eckdaten im neuen Theme') ->assertSee('Theme „Ostsee-Nacht“') ->assertSee('', false); $this->get('/?theme=ostsee-nacht')->assertOk()->assertDontSee('Eckdaten im neuen Theme'); $this->assertSame('ostsee-licht', Site::sole()->theme); $this->artisan('themes:preview', ['theme' => 'ostsee-nacht']) ->expectsOutputToContain('Die Wohnung') ->expectsOutputToContain('Weihnachten:') ->assertSuccessful(); } }