publicFilm(); $this->publish('/mit-text', $this->card($film, [])); $html = $this->card_html($this->get('/mit-text')->assertOk()->getContent()); $this->assertStringContainsString('Eine Pause, die stark macht', $html); $this->assertStringContainsString('KURZ-TEXT', $html); $this->assertStringContainsString('lf-pc__cta', $html); $this->assertStringContainsString('lf-pc__meta', $html); $this->assertStringNotContainsString('lf-pc--bare', $html); } public function test_without_texts_only_the_picture_remains_and_the_title_stays_for_assistive_technology(): void { $film = $this->publicFilm(); $this->publish('/ohne-text', $this->card($film, ['show_body' => 'no'])); $html = $this->card_html($this->get('/ohne-text')->assertOk()->getContent()); $this->assertStringContainsString('lf-pc--bare', $html); $this->assertStringNotContainsString('KURZ-TEXT', $html); $this->assertStringNotContainsString('lf-pc__cta', $html, 'Keine Aktion.'); $this->assertStringNotContainsString('lf-pc__meta', $html, 'Keine Zusatzangaben.'); $this->assertStringNotContainsString('lf-pc__kind', $html, 'Keine Art.'); $this->assertStringNotContainsString('lf-pc__badge', $html, 'Keine Marke im Bild.'); $this->assertStringContainsString('class="lf-pc__title visually-hidden"', $html); $this->assertStringContainsString('Eine Pause, die stark macht', $html, 'Der Titel bleibt für Hilfstechnik erhalten.'); } public function test_the_trailer_still_plays_on_a_card_without_texts(): void { $film = $this->publicFilm(); $trailer = $this->clip('Trailer Denkpause'); PresentationAssignment::query()->create([ 'subject_type' => $film->getMorphClass(), 'subject_id' => $film->getKey(), 'content_element_id' => $trailer->id, 'presentation_role_id' => PresentationRole::query()->where('slug', 'trailer')->value('id'), 'position' => 1, ]); app(WebsiteRelease::class)->release($trailer->fresh()); foreach ([WebsiteImage::class, CardClip::class, WebsiteMedia::class] as $class) { $this->app->forgetInstance($class); } $this->publish('/ohne-text-trailer', $this->card($film, ['show_body' => 'no'])); $html = $this->card_html($this->get('/ohne-text-trailer')->assertOk()->getContent()); $this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $html); $this->assertStringContainsString('aria-label="Trailer abspielen: Trailer Denkpause"', $html); $this->assertStringNotContainsString('KURZ-TEXT', $html); } public function test_only_cards_with_a_picture_offer_the_choice_and_it_is_validated(): void { $registry = app(WidgetRegistry::class); $this->assertSame(['yes', 'no'], array_keys($registry->get('media_card')->settingOptions()['show_body'])); $this->assertSame(['yes', 'no'], array_keys($registry->get('program_card')->settingOptions()['show_body'])); $this->assertArrayNotHasKey('show_body', $registry->get('topic_card')->settingOptions(), 'Eine Themenkarte ohne Bild bliebe leer.'); $film = $this->publicFilm(); try { $registry->normalize($this->card($film, ['show_body' => 'vielleicht'])[0]['slots']); $this->fail('Eine unbekannte Wahl wurde angenommen.'); } catch (ValidationException $exception) { $this->assertArrayHasKey('blocks.0.settings.show_body', $exception->errors()); } } public function test_the_preview_keeps_the_editorial_notes_on_a_card_without_texts(): void { $film = $this->publicFilm(); $revision = $this->publish('/ohne-text-vorschau', $this->card($film, ['show_body' => 'no'])); $preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent(); $this->assertStringContainsString('lf-pc--bare', $preview); $this->assertStringNotContainsString('lf-pc__cta', $preview); } /** * @param array $settings * @return list> */ private function card(ContentElement $film, array $settings): array { return [['layout' => 'u4', 'style' => [], 'slots' => [ ['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => $settings, 'data' => [], 'refs' => ['element' => $film->id]], ]]]; } private function card_html(string $html): string { preg_match('#