websiteFilm('Teaser Denkpause'); $options = app(PublicMaterialReader::class)->search('Teaser Denk'); $this->assertArrayHasKey($teaser->id, $options); $this->assertStringContainsString('Website-Datei nicht freigegeben', $options[$teaser->id]); $this->assertArrayHasKey($teaser->id, app(PublicMaterialReader::class)->search(null), 'Auch ohne Suchbegriff.'); $this->assertTrue(app(PublicMaterialReader::class)->isSelectable($teaser)); } public function test_the_dropdown_label_says_when_the_file_is_released(): void { $teaser = $this->websiteFilm('Teaser Denkpause'); $this->release($teaser); $options = app(PublicMaterialReader::class)->search('Teaser Denk'); $this->assertStringContainsString('öffentlich mit Website-Datei', $options[$teaser->id]); } public function test_the_card_endpoint_accepts_such_a_film_as_its_medium(): void { $teaser = $this->websiteFilm('Teaser Denkpause'); $widget = app(WidgetRegistry::class)->get('media_card'); $options = (new \ReflectionMethod($widget, 'rejectSubject'))->invoke($widget, $teaser->id); $this->assertNull($options, 'Die Auswahl wird nicht mit „archiviert oder gesperrt“ abgelehnt.'); } public function test_a_released_website_film_shows_publicly_with_its_clip_and_without_an_action(): void { $teaser = $this->websiteFilm('Teaser Denkpause'); $this->release($teaser); $this->publish('/teaser-karte', $teaser); $html = $this->get('/teaser-karte')->assertOk()->getContent(); $this->assertStringContainsString('Teaser Denkpause', $html); $this->assertStringContainsString('data-clip-src="'.route('website.media', $teaser).'"', $html, 'Das freigegebene Video ist der Clip der Karte.'); $this->assertStringNotContainsString('lf-pc__cta', $html, 'Ohne Programmseite gibt es keine Aktion.'); $this->assertStringNotContainsString('teaser/', $html); $this->assertStringNotContainsString('originals/', $html); } public function test_an_unreleased_website_film_stays_out_of_the_public_page_but_shows_in_the_preview(): void { $teaser = $this->websiteFilm('Teaser Denkpause'); $this->publish('/teaser-nicht-frei', $teaser); $this->get('/teaser-nicht-frei')->assertOk()->assertDontSee('Teaser Denkpause'); $subject = app(PublicMaterialReader::class)->subject($teaser->id, includeNonPublic: true); $this->assertNotNull($subject); $this->assertFalse($subject->public); $this->assertStringContainsString('nicht für die Website freigegeben', (string) $subject->notice); } public function test_withdrawing_the_release_takes_the_card_off_the_public_page(): void { $teaser = $this->websiteFilm('Teaser Denkpause'); $this->release($teaser); $this->publish('/teaser-zurueck', $teaser); $this->get('/teaser-zurueck')->assertSee('Teaser Denkpause'); app(WebsiteRelease::class)->withdraw($teaser->fresh()); $this->flushScoped(); $this->get('/teaser-zurueck')->assertOk()->assertDontSee('Teaser Denkpause'); } public function test_an_archived_website_film_is_never_offered(): void { $archived = $this->websiteFilm('Archiv Denkpause'); $archived->forceFill(['archived_at' => now()])->save(); $this->assertArrayNotHasKey($archived->id, app(PublicMaterialReader::class)->search('Archiv')); } public function test_an_image_without_a_version_is_not_offered_as_medium(): void { $path = 'inhalte/bild.jpg'; Storage::disk('cms_incoming')->put($path, 'bild-bytes'); $image = app(ContentService::class)->createElement('bild', 'bild', 'Bild Denkpause'); app(PresentationFile::class)->store($image, $path); $this->assertArrayNotHasKey($image->id, app(PublicMaterialReader::class)->search('Bild Denk'), 'Nur Filme ohne Fassung zählen als Medium der Karte.'); } private function websiteFilm(string $title): ContentElement { $path = 'inhalte/'.md5($title).'.mp4'; Storage::disk('cms_incoming')->put($path, '0123456789abcdefghij'); $element = app(ContentService::class)->createElement('film', 'film', $title); $element->display_title = $title; $element->save(); app(PresentationFile::class)->store($element, $path); return $element->fresh(); } private function release(ContentElement $element): void { app(WebsiteRelease::class)->release($element->fresh()); $this->flushScoped(); } private function flushScoped(): void { foreach ([WebsiteImage::class, CardClip::class, WebsiteMedia::class, PublicMaterialReader::class] as $class) { $this->app->forgetInstance($class); } } private function publish(string $path, ContentElement $film): PageRevision { $page = Page::query()->create(['path' => $path]); $service = app(PageService::class); $revision = $service->saveRevision($page, [['layout' => 'u4', 'style' => [], 'slots' => [ ['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => [], 'refs' => ['element' => $film->id]], ]]], null, null, null); $service->publish($page, $revision); return $revision; } }