extra = resource_path('image-worlds/berge'); File::ensureDirectoryExists($this->extra.'/svg'); File::put($this->extra.'/world.json', json_encode([ 'name' => 'Berge', 'description' => 'Gipfel statt Wellen.', 'slots' => ['divider' => 'grat', 'crest' => 'gipfel'], ])); File::put($this->extra.'/svg/grat.svg', ''); app()->forgetInstance(ImageWorldRegistry::class); } protected function tearDown(): void { File::deleteDirectory($this->extra); parent::tearDown(); } public function test_the_registry_finds_every_world_and_reports_slots_without_a_file(): void { $registry = app(ImageWorldRegistry::class); $this->assertArrayHasKey('ostsee', $registry->all()); $this->assertArrayHasKey('berge', $registry->all()); $this->assertSame('Berge', $registry->options()['berge']); $this->assertSame([], $registry->get('ostsee')->missingFiles()); $this->assertSame(['crest'], $registry->get('berge')->missingFiles(), 'gipfel.svg fehlt und muss auffallen.'); $this->assertNull($registry->get('gibtsnicht')); } public function test_a_slot_without_a_file_renders_nothing_instead_of_breaking(): void { $this->useWorld('berge'); $this->assertSame('', (string) app(MotifRenderer::class)->render('crest')); $this->assertFalse(app(MotifRenderer::class)->has('crest')); $this->assertTrue(app(MotifRenderer::class)->has('divider')); } public function test_the_apartment_overrules_the_website(): void { $this->useWorld('ostsee'); $this->assertSame('ostsee', app(MotifRenderer::class)->world()?->key); $this->useWorld('ostsee', apartmentWorld: 'berge'); $this->assertSame('berge', app(MotifRenderer::class)->world()?->key, 'Die Bergwohnung trägt ihre eigene Bildwelt.'); } public function test_without_any_choice_the_installation_decides(): void { config(['image-worlds.default' => 'berge']); $this->useWorld(null); $this->assertSame('berge', app(MotifRenderer::class)->world()?->key); } public function test_the_rendered_graphic_is_decorative_unless_it_is_given_a_label(): void { $this->useWorld('berge'); $plain = (string) app(MotifRenderer::class)->render('divider', 'h-8 text-accent'); $this->assertStringContainsString('aria-hidden="true"', $plain); $this->assertStringContainsString('class="h-8 text-accent"', $plain); $this->assertStringNotContainsString('