Ordne Übungsabschnitte im Medienbestand ein und filtere Materialarten mehrfach
Deploy Test / test (push) Successful in 2m51s
CI Feature / test (push) Successful in 2m49s
Deploy Test / deploy (push) Successful in 35s

- Medium anlegen: Pflichtfeld Fachliche Materialart (serverseitig geprüft)
- Materialart Übungsabschnitt (automatisch) für Abschnitte im Übungseditor und aus Shinkan, mit Verweis auf die Übung
- Medienmanager: Checkboxen statt Dropdown, Start ohne Übungsabschnitte, persönlicher Standard je Konto
- Zuordnung des Bestands nur bei belegter Herkunft; Übungsabschnitte nie öffentlich

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-24 07:40:30 +01:00
1 parent 99122ddfee
commit ad581cb545
29 files changed
+1321 -25

No files matched your search

+2
View File
@@ -9,6 +9,7 @@
use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Media\ThumbnailDeriver;
use App\Filament\Pages\EditorialDesk;
use App\Filament\Resources\ContentElements\ContentElementResource;
@@ -671,6 +672,7 @@ public function test_a_file_can_be_created_inside_the_module(): void
->assertMountedActionModalSee('Vorschaubild')
->fillForm([
'working_title' => 'Merkblatt',
'editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'merkblatt')->value('id'),
'shape' => 'document',
'description' => 'Für die Gruppe',
'usage_note' => 'Vorher lesen',
+2 -1
View File
@@ -6,6 +6,7 @@
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\EditorialDimension;
use App\Domain\Catalog\IdentityDimension;
use App\Domain\Catalog\PillarService;
@@ -330,7 +331,7 @@ public function test_the_create_medium_dialog_has_a_place_to_open_on_the_library
->assertSeeHtml('wire:partial="action-modals"')
->mountAction('create')
->assertActionMounted('create')
->fillForm(['working_title' => 'Neuer Prüftext', 'shape' => 'text', 'body' => 'Wortlaut'])
->fillForm(['working_title' => 'Neuer Prüftext', 'editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'merkblatt')->value('id'), 'shape' => 'text', 'body' => 'Wortlaut'])
->callMountedAction()
->assertHasNoFormErrors();
+1
View File
@@ -163,6 +163,7 @@ public function test_creating_a_presentation_film_does_not_open_a_content_versio
$element = MediumForm::create([
'working_title' => 'Marketingclip',
'editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'merkblatt')->value('id'),
'shape' => 'film',
'incoming' => 'inhalte/teaser.mp4',
'without_version' => true,
+45
View File
@@ -8,6 +8,7 @@
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\ExerciseGuide;
use App\Domain\Catalog\ExerciseSections;
use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\RightsProfileVersion;
@@ -242,6 +243,50 @@ public function test_the_stand_keeps_what_was_chosen_when_a_newer_exercise_versi
->assertSee('Nein sagen und Abstand halten');
}
public function test_two_product_stands_show_their_own_text_versions_and_an_exercise_of_sections_only_gives_a_pdf(): void
{
$content = app(ContentService::class);
$articles = app(ArticleService::class);
$exercise = $this->exerciseComposition('Nur Abschnitte');
$section = $this->section('Ablauf', '<p>Stand eins des Abschnitts.</p>');
app(ExerciseSections::class)->mark($section->element, $exercise);
$first = $content->publishComposition($exercise, [['role' => 'Durchführung', 'target' => $section]]);
$moduleOne = $this->moduleWith('Modul eins', $first);
$articleOne = $articles->create('nur-abschnitte-eins');
$releaseOne = $articles->publishRelease($articleOne, $moduleOne, 'Eins.');
$revised = $content->publishElementVersion($section->element, '<p>Stand zwei des Abschnitts.</p>');
$second = $content->publishComposition($exercise, [['role' => 'Durchführung', 'target' => $revised]]);
$moduleTwo = $this->moduleWith('Modul zwei', $second);
$articleTwo = $articles->create('nur-abschnitte-zwei');
$releaseTwo = $articles->publishRelease($articleTwo, $moduleTwo, 'Zwei.');
// Der Abschnitt wird außerdem direkt in einem Modul verwendet und bleibt dort erreichbar.
$direct = $this->moduleWith('Modul direkt', $second, null, CompositionKind::Uebung, $revised);
$articleDirect = $articles->create('nur-abschnitte-direkt');
$articles->publishRelease($articleDirect, $direct, 'Direkt.');
$member = $this->grantTo($this->full(), [$articleOne, $articleTwo, $articleDirect]);
$this->actingAs($member)->get($this->page($articleOne, $releaseOne))->assertOk()
->assertSee('Stand eins des Abschnitts.')->assertDontSee('Stand zwei des Abschnitts.');
$this->actingAs($member)->get($this->page($articleTwo, $releaseTwo))->assertOk()
->assertSee('Stand zwei des Abschnitts.')->assertDontSee('Stand eins des Abschnitts.');
$pdfOne = $this->actingAs($member)->get($this->pdf($articleOne, $releaseOne, null, $member));
$pdfOne->assertOk()->assertHeader('Content-Type', 'application/pdf');
$this->assertStringContainsString('Stand eins des Abschnitts.', $this->pdfText($pdfOne->getContent()));
$this->assertStringNotContainsString('Stand zwei', $this->pdfText($pdfOne->getContent()));
$this->assertStringContainsString('Stand zwei des Abschnitts.', $this->pdfText($this->actingAs($member)->get($this->pdf($articleTwo, $releaseTwo, null, $member))->getContent()));
app(CompositionDisplayRelease::class)->release($direct, $member);
$page = $this->actingAs($member)
->get(route('member.content', ['composition' => $direct->composition_id, 'version' => $revised->id]))
->assertOk()
->assertSee('Ablauf');
$this->assertSame(1, preg_match('#href="([^"]+/ansehen\?[^"]+)"#', $page->getContent(), $link), 'Die Seite bietet „Ansehen“ an.');
$this->actingAs($member)->get(html_entity_decode($link[1]))->assertOk()->assertSee('Stand zwei des Abschnitts.');
}
public function test_a_wrong_path_is_not_found(): void
{
$this->actingAs($this->member)->get(route('member.exercise', ['article' => $this->moduleArticle, 'release' => $this->moduleRelease, 'path' => '7']))->assertNotFound();
@@ -0,0 +1,477 @@
<?php
namespace Tests\Feature;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\ExerciseSections;
use App\Domain\Catalog\ExerciseSource;
use App\Domain\Catalog\ShinkanImport;
use App\Filament\Resources\ContentElements\Pages\ListContentElements;
use App\Filament\Resources\Exercises\Pages\EditExercise;
use App\Filament\Resources\Practices\Pages\EditPractice;
use App\Filament\Support\MaterialKindSelection;
use App\Filament\Support\MediaLibrary;
use App\Filament\Support\MediumForm;
use App\Models\User;
use App\Models\UserViewDefault;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Storage;
use Livewire\Livewire;
use Tests\Support\BuildsExercises;
use Tests\TestCase;
/**
* Übungsabschnitte im gemeinsamen Medienbestand (Auftrag Übungsverwaltung, Abschnitt 9): Materialart beim Anlegen,
* automatische Einordnung der Abschnitte, Mehrfachauswahl im Medienmanager und persönlicher Standard.
*/
class UebungsabschnitteMedienbestandTest extends TestCase
{
use BuildsExercises;
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
}
// ---------------------------------------------------------------- 1. Materialart beim Anlegen
public function test_a_pdf_is_created_as_a_document_with_the_material_kind_merkblatt(): void
{
Storage::fake('cms_incoming');
Storage::disk('cms_incoming')->put('inhalte/merkblatt.pdf', 'pdfbytes');
Livewire::actingAs($this->editor(), 'staff')
->test(ListContentElements::class)
->mountAction('create')
->fillForm([
'working_title' => 'Merkblatt Abstand',
'editorial_content_kind_id' => $this->kind('merkblatt'),
'shape' => 'document',
'incoming' => ['inhalte/merkblatt.pdf'],
])
->callMountedAction()
->assertHasNoFormErrors();
$element = ContentElement::query()->where('working_title', 'Merkblatt Abstand')->firstOrFail();
$this->assertSame('document', $element->output_class);
$this->assertSame($this->kind('merkblatt'), $element->editorial_content_kind_id);
$this->assertSame('Merkblatt', $this->card($element)['editorialKind']);
$merkblaetter = MediaLibrary::class;
$this->assertSame(
['Merkblatt Abstand'],
array_column(app($merkblaetter)->cards(['arten' => MaterialKindSelection::encode(['k'.$this->kind('merkblatt')])], false), 'title'),
'Das Medium lässt sich nach der Materialart filtern.',
);
}
public function test_the_material_kind_is_required_when_creating_a_medium(): void
{
Livewire::actingAs($this->editor(), 'staff')
->test(ListContentElements::class)
->mountAction('create')
->fillForm(['working_title' => 'Ohne Art', 'shape' => 'text', 'body' => 'Wortlaut'])
->callMountedAction()
->assertHasFormErrors(['editorial_content_kind_id' => 'required']);
$this->assertDatabaseMissing('content_elements', ['working_title' => 'Ohne Art']);
}
public function test_the_server_rejects_a_kind_that_is_not_meant_for_media_and_creates_nothing(): void
{
$this->actingAs($this->editor(), 'staff');
foreach (['programm' => 'nicht vorgesehen', 'uebungsabschnitt' => 'nicht vorgesehen'] as $slug => $fragment) {
try {
MediumForm::create(['working_title' => 'Falsch', 'shape' => 'text', 'body' => 'Text', 'editorial_content_kind_id' => $this->kind($slug)], hold: false);
$this->fail('Die Materialart '.$slug.' darf für ein Medium nicht gewählt werden.');
} catch (DomainRuleException $exception) {
$this->assertStringContainsString($fragment, $exception->getMessage());
}
}
$this->assertDatabaseMissing('content_elements', ['working_title' => 'Falsch']);
}
public function test_the_offered_kinds_are_the_active_medium_kinds_without_the_automatic_one(): void
{
$options = app(EditorialVocabulary::class)->kindOptions('medium');
$this->assertContains('Merkblatt', $options);
$this->assertNotContains('Übungsabschnitt', $options);
$this->assertNotContains('Programm', $options);
}
// ---------------------------------------------------------------- 2. Abschnitte automatisch einordnen
public function test_a_section_created_in_the_exercise_editor_is_an_exercise_section_with_its_exercise(): void
{
$exercise = $this->exerciseComposition('Wohlfühlabstand');
Livewire::actingAs($this->editor(), 'staff')
->test(EditPractice::class, ['record' => $exercise->getKey()])
->set('newTextTitle', 'Ablauf')
->set('newTextBody', '<p>Die Kinder gehen aufeinander zu.</p>')
->call('addText');
$element = ContentElement::query()->where('working_title', 'Ablauf')->firstOrFail();
$this->assertSame($this->kind('uebungsabschnitt'), $element->editorial_content_kind_id);
$this->assertSame($exercise->getKey(), $element->origin_composition_id);
$card = $this->card($element);
$this->assertSame('Übungsabschnitt', $card['editorialKind']);
$this->assertSame('Wohlfühlabstand', $card['exercise']['title']);
$this->assertStringEndsWith('/fachuebungen/'.$exercise->getKey(), (string) $card['exercise']['url']);
}
public function test_a_text_created_in_a_module_stays_an_ordinary_text(): void
{
$module = app(ContentService::class)->createComposition('Ein Modul', CompositionKind::Uebung);
Livewire::actingAs($this->editor(), 'staff')
->test(EditExercise::class, ['record' => $module->getKey()])
->set('newTextTitle', 'Modultext')
->set('newTextBody', '<p>Gilt für das Modul.</p>')
->call('addText');
$element = ContentElement::query()->where('working_title', 'Modultext')->firstOrFail();
$this->assertNull($element->editorial_content_kind_id);
$this->assertNull($element->origin_composition_id);
}
public function test_sections_from_shinkan_are_exercise_sections_of_their_own_exercise_and_stay_so_on_repetition(): void
{
$import = app(ShinkanImport::class);
$first = $import->adopt($import->record($this->document('6f1c1c52-0a53-4f6b-8e0e-3f0c2f6b9a11', 'Sicher stehen', 'h1')));
$second = $import->adopt($import->record($this->document('9a8b7c6d-1111-4222-8333-444455556666', 'Abstand halten', 'h2')));
$import->adopt($import->record($this->document('9a8b7c6d-1111-4222-8333-444455556666', 'Abstand halten', 'h2')));
$sections = ContentElement::query()->where('source_ref', 'like', 'shinkan:%')->get();
$this->assertCount(4, $sections, 'Zwei Übungen mit je Durchführung und Vorbereitung.');
foreach ($sections as $section) {
$this->assertSame($this->kind('uebungsabschnitt'), $section->editorial_content_kind_id);
$owner = str_contains((string) $section->source_ref, '6f1c1c52') ? $first : $second;
$this->assertSame($owner->composition_id, $section->origin_composition_id, 'Jeder Abschnitt gehört zu seiner eigenen Übung.');
}
$cards = app(MediaLibrary::class)->cards(['arten' => MaterialKindSelection::encode(['k'.$this->kind('uebungsabschnitt')])], true);
$this->assertCount(4, $cards);
$this->assertSame(['Abstand halten', 'Abstand halten', 'Sicher stehen', 'Sicher stehen'], collect($cards)->map(fn (array $card): string => $card['exercise']['title'])->sort()->values()->all());
}
public function test_existing_texts_are_assigned_only_when_their_origin_is_proven(): void
{
$content = app(ContentService::class);
$exercise = $this->exerciseComposition('Alte Übung');
$other = $this->exerciseComposition('Andere Übung');
$module = $content->createComposition('Ein Modul', CompositionKind::Uebung);
$own = $this->section('Nur in der Übung', 'Text');
$shared = $this->section('In zwei Übungen', 'Text');
$direct = $this->section('Auch direkt im Modul', 'Text');
$classified = $this->section('Eigenes Merkblatt', 'Text');
$classified->element->forceFill(['editorial_content_kind_id' => $this->kind('merkblatt')])->save();
$film = $this->film('Demonstrationsfilm');
$film->element->forceFill(['editorial_content_kind_id' => $this->kind('merkblatt')])->save();
$loose = $this->section('Ohne Verwendung', 'Text');
$content->publishComposition($exercise, [
['role' => 'Ablauf', 'target' => $own],
['role' => 'Geteilt', 'target' => $shared],
['role' => 'Auch direkt', 'target' => $direct],
['role' => 'Merkblatt', 'target' => $classified],
['role' => 'Film', 'target' => $film],
]);
$content->publishComposition($other, [['role' => 'Geteilt', 'target' => $shared]]);
$content->publishComposition($module, [['role' => 'Text', 'target' => $direct]]);
$assigned = app(ExerciseSections::class)->backfill();
$this->assertSame(1, $assigned);
$this->assertSame($this->kind('uebungsabschnitt'), $own->element->fresh()->editorial_content_kind_id);
$this->assertSame($exercise->getKey(), $own->element->fresh()->origin_composition_id);
foreach ([$shared, $direct, $loose] as $unclear) {
$this->assertNull($unclear->element->fresh()->editorial_content_kind_id, 'Bei unklarer Herkunft bleibt die Einordnung bestehen: '.$unclear->element->working_title);
$this->assertNull($unclear->element->fresh()->origin_composition_id);
}
$this->assertSame($this->kind('merkblatt'), $classified->element->fresh()->editorial_content_kind_id, 'Eine gesetzte Materialart bleibt.');
$this->assertSame($this->kind('merkblatt'), $film->element->fresh()->editorial_content_kind_id);
$this->assertSame(0, app(ExerciseSections::class)->backfill(), 'Die Zuordnung ist wiederholbar.');
}
public function test_shinkan_sections_of_the_existing_stock_get_their_exercise_even_if_a_kind_was_set(): void
{
$import = app(ShinkanImport::class);
$version = $import->adopt($import->record($this->document('6f1c1c52-0a53-4f6b-8e0e-3f0c2f6b9a11', 'Sicher stehen', 'h1')));
// Stand vor der Einführung: Abschnitte ohne Zuordnung; eine Redaktion hat einen davon bewusst eingeordnet.
ContentElement::query()->update(['editorial_content_kind_id' => null, 'origin_composition_id' => null]);
$kept = ContentElement::query()->where('source_ref', 'like', '%:execution')->firstOrFail();
$kept->forceFill(['editorial_content_kind_id' => $this->kind('merkblatt')])->save();
app(ExerciseSections::class)->backfill();
$this->assertSame($version->composition_id, $kept->fresh()->origin_composition_id);
$this->assertSame($this->kind('merkblatt'), $kept->fresh()->editorial_content_kind_id);
$preparation = ContentElement::query()->where('source_ref', 'like', '%:preparation')->firstOrFail();
$this->assertSame($this->kind('uebungsabschnitt'), $preparation->editorial_content_kind_id);
$this->assertSame(ExerciseSource::query()->value('composition_id'), $preparation->origin_composition_id);
}
// ---------------------------------------------------------------- 3. Mehrfachauswahl im Medienmanager
public function test_the_start_view_shows_regular_media_and_old_entries_without_exercise_sections(): void
{
$this->library();
$this->assertSame(
['Alter Text ohne Art', 'Merkblatt Abstand', 'Trailer Park'],
$this->titles(Livewire::actingAs($this->editor(), 'staff')->test(ListContentElements::class)),
);
}
public function test_switching_on_exercise_sections_shows_them_at_once_and_two_kinds_show_together(): void
{
$this->library();
$component = Livewire::actingAs($this->editor(), 'staff')->test(ListContentElements::class);
$this->toggle($component, 'k'.$this->kind('uebungsabschnitt'));
$this->assertSame(['Ablauf der Übung', 'Alter Text ohne Art', 'Merkblatt Abstand', 'Trailer Park'], $this->titles($component));
// Auf Merkblatt und Übungsabschnitt eingrenzen: Trailer und der Text ohne Art fallen weg.
$this->toggle($component, MaterialKindSelection::WITHOUT);
$this->toggle($component, 'k'.$this->kind('trailer'));
$this->assertSame(['Ablauf der Übung', 'Merkblatt Abstand'], $this->titles($component));
// Die Suche grenzt die Treffer weiter ein, die Auswahl bleibt.
$component->set('suche', 'ablauf');
$this->assertSame(['Ablauf der Übung'], $this->titles($component));
$component->assertSet('arten', fn (string $value): bool => str_contains($value, 'k'.$this->kind('merkblatt')) && str_contains($value, 'k'.$this->kind('uebungsabschnitt')));
// Kacheln zeigen dieselbe Auswahl.
$component->set('suche', '')->set('ansicht', 'kacheln');
$this->assertSame(['Ablauf der Übung', 'Merkblatt Abstand'], $this->titles($component));
}
public function test_the_row_names_the_exercise_and_leads_to_its_editor(): void
{
$this->library();
$component = Livewire::actingAs($this->editor(), 'staff')->test(ListContentElements::class);
$this->toggle($component, 'k'.$this->kind('uebungsabschnitt'));
$component
->assertSee('Übung: Wohlfühlabstand')
->assertSee('Zur Übung');
}
public function test_select_all_includes_exercise_sections_and_texts_without_a_kind(): void
{
$this->library();
$component = Livewire::actingAs($this->editor(), 'staff')->test(ListContentElements::class)->call('selectAllArten');
$this->assertContains('Ablauf der Übung', $this->titles($component));
$this->assertContains('Alter Text ohne Art', $this->titles($component));
$this->assertContains(MaterialKindSelection::WITHOUT, $component->instance()->selectedArten());
$this->assertContains('k'.$this->kind('uebungsabschnitt'), $component->instance()->selectedArten());
}
public function test_without_any_check_the_list_says_so_and_the_choice_stays_visible(): void
{
$this->library();
$component = Livewire::actingAs($this->editor(), 'staff')->test(ListContentElements::class);
foreach (array_keys($component->instance()->artChoices()) as $key) {
if (in_array($key, $component->instance()->selectedArten(), true)) {
$this->toggle($component, $key);
}
}
$component->assertSet('arten', MaterialKindSelection::NONE)
->assertSee('Keine Materialart ausgewählt')
->assertSee('Wähle oben mindestens eine Materialart aus')
->assertSee('Ohne Materialart')
->assertSee('Übungsabschnitt');
$this->assertSame([], $this->titles($component));
}
public function test_the_old_address_with_one_kind_still_works(): void
{
$this->library();
$this->assertSame(
['Trailer Park'],
$this->titles(Livewire::withQueryParams(['inhaltsart' => (string) $this->kind('trailer')])->actingAs($this->editor(), 'staff')->test(ListContentElements::class)),
);
}
// ---------------------------------------------------------------- 4. Persönlicher Standard
public function test_the_personal_default_is_saved_restored_kept_across_logins_and_deleted(): void
{
$this->library();
$mine = $this->editor();
$other = $this->editor();
$component = Livewire::actingAs($mine, 'staff')->test(ListContentElements::class);
$this->toggle($component, 'k'.$this->kind('uebungsabschnitt'));
$this->toggle($component, MaterialKindSelection::WITHOUT);
$component->set('suche', 'etwas Vorübergehendes')
->call('saveDefault');
$saved = UserViewDefault::filtersFor($mine->id, UserViewDefault::MEDIA);
$this->assertNotNull($saved);
$this->assertArrayNotHasKey('suche', $saved, 'Die Suche gehört nicht zum Standard.');
// Vorübergehend geändert, dann wiederhergestellt.
$component->call('selectAllArten');
$this->toggle($component, 'k'.$this->kind('trailer'));
$component->call('restoreDefault')->assertSet('suche', '');
$this->assertSame(['Ablauf der Übung', 'Merkblatt Abstand', 'Trailer Park'], $this->titles($component));
// Neue Anmeldung (neue Seite ohne Vorgaben in der Adresse): dieselbe Auswahl.
$this->assertSame(
['Ablauf der Übung', 'Merkblatt Abstand', 'Trailer Park'],
$this->titles(Livewire::actingAs($mine, 'staff')->test(ListContentElements::class)),
);
// Ein zweites Konto sieht die allgemeine Startansicht.
$this->assertSame(
['Alter Text ohne Art', 'Merkblatt Abstand', 'Trailer Park'],
$this->titles(Livewire::actingAs($other, 'staff')->test(ListContentElements::class)),
);
// Löschen: allgemeine Auswahl, sofort und beim nächsten Öffnen.
Livewire::actingAs($mine, 'staff')->test(ListContentElements::class)->call('deleteDefault')->assertSet('arten', '');
$this->assertNull(UserViewDefault::filtersFor($mine->id, UserViewDefault::MEDIA));
$this->assertSame(
['Alter Text ohne Art', 'Merkblatt Abstand', 'Trailer Park'],
$this->titles(Livewire::actingAs($mine, 'staff')->test(ListContentElements::class)),
);
}
public function test_an_address_with_its_own_filters_wins_over_the_personal_default(): void
{
$this->library();
$mine = $this->editor();
UserViewDefault::remember($mine->id, UserViewDefault::MEDIA, ['arten' => MaterialKindSelection::encode(['k'.$this->kind('trailer')]), 'ansicht' => 'kacheln']);
$this->assertSame(['Trailer Park'], $this->titles(Livewire::actingAs($mine, 'staff')->test(ListContentElements::class)));
$this->assertSame(
['Alter Text ohne Art', 'Merkblatt Abstand', 'Trailer Park'],
$this->titles(Livewire::withQueryParams(['suche' => ''])->actingAs($mine, 'staff')->test(ListContentElements::class)->set('arten', '')),
);
}
public function test_the_standard_actions_that_need_a_saved_standard_are_disabled_without_one(): void
{
$this->library();
$mine = $this->editor();
$page = Livewire::actingAs($mine, 'staff')->test(ListContentElements::class);
$this->assertFalse($page->instance()->hasSavedDefault());
$page->assertSee('Als Standard speichern')->assertSeeHtml('wire:click="restoreDefault" disabled');
$page->call('saveDefault');
$this->assertTrue($page->instance()->hasSavedDefault());
}
// ---------------------------------------------------------------- Hilfen
/**
* Medien: ein Merkblatt, ein Trailer, ein alter Text ohne Art und ein Übungsabschnitt.
*/
private function library(): void
{
$content = app(ContentService::class);
$exercise = $this->exerciseComposition('Wohlfühlabstand');
$merkblatt = $content->createElement('dokument', 'document', 'Merkblatt Abstand');
$merkblatt->forceFill(['editorial_content_kind_id' => $this->kind('merkblatt')])->save();
$trailer = $content->createElement('film', 'film', 'Trailer Park');
$trailer->forceFill(['editorial_content_kind_id' => $this->kind('trailer')])->save();
$content->createElement('text', 'text', 'Alter Text ohne Art');
$section = $content->createElement('text', 'text', 'Ablauf der Übung');
app(ExerciseSections::class)->mark($section, $exercise);
}
/** Ein Häkchen setzen oder entfernen, wie im Browser. */
private function toggle($component, string $key): void
{
$current = $component->instance()->artenAuswahl;
$component->set('artenAuswahl', in_array($key, $current, true) ? array_values(array_diff($current, [$key])) : [...$current, $key]);
}
/**
* @return list<string>
*/
private function titles($component): array
{
return array_column($component->instance()->cards(), 'title');
}
/**
* @return array<string, mixed>
*/
private function card(ContentElement $element): array
{
return app(MediaLibrary::class)->cardFor($element->fresh(), true);
}
private function kind(string $slug): int
{
return (int) EditorialContentKind::query()->where('slug', $slug)->value('id') ?: $this->makeKind($slug);
}
/** Testdaten für Arten, die die Migrationen nicht anlegen. */
private function makeKind(string $slug): int
{
return (int) EditorialContentKind::query()->create([
'slug' => $slug,
'label' => ucfirst($slug),
'sort_order' => 50,
'is_active' => true,
'contexts' => ['medium'],
])->id;
}
private function editor(): User
{
$editor = User::factory()->redakteur()->create();
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
return $editor;
}
/**
* @return array<string, mixed>
*/
private function document(string $id, string $title, string $hash): array
{
return [
'source_id' => $id,
'title' => $title,
'summary' => 'Kurzbeschreibung',
'goal' => 'Lernziel '.$hash,
'execution' => 'Durchführung der Übung '.$hash,
'preparation' => 'Vorbereitung der Übung '.$hash,
'trainer_notes' => '',
'equipment' => '',
'duration_min' => 10,
'duration_max' => 10,
'variants' => [],
'media' => [],
'content_hash' => str_repeat($hash[1], 64),
];
}
}
+5
View File
@@ -5,6 +5,7 @@
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Entitlement\Grant;
use App\Domain\Media\PresentationFile;
use App\Domain\Media\ThumbnailDeriver;
@@ -50,6 +51,7 @@ public function test_the_web_process_does_not_write_to_the_derived_store_but_han
$element = MediumForm::create([
'working_title' => 'Trailer',
'editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'merkblatt')->value('id'),
'shape' => 'film',
'incoming' => 'inhalte/trailer.mp4',
'without_version' => true,
@@ -68,6 +70,7 @@ public function test_the_queue_places_the_file_and_the_film_can_then_be_released
$element = MediumForm::create([
'working_title' => 'Trailer',
'editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'merkblatt')->value('id'),
'shape' => 'film',
'incoming' => 'inhalte/trailer.mp4',
'without_version' => true,
@@ -92,6 +95,7 @@ public function test_a_film_format_the_browser_cannot_play_is_refused_before_any
try {
MediumForm::create([
'working_title' => 'Trailer als MOV',
'editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'merkblatt')->value('id'),
'shape' => 'film',
'incoming' => 'inhalte/trailer.mov',
'without_version' => true,
@@ -171,6 +175,7 @@ public function test_a_versionless_film_shows_its_website_file_in_the_media_mana
$this->actingAs($this->editor(), 'staff');
$film = MediumForm::create([
'working_title' => 'Trailer',
'editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'merkblatt')->value('id'),
'shape' => 'film',
'incoming' => 'inhalte/trailer.mp4',
'without_version' => true,