Filament rendert beim Öffnen einer Aktion nicht neu; der Dialog wird deshalb nach der Antwort per $wire geöffnet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
519 lines
22 KiB
PHP
519 lines
22 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Domain\Catalog\ArticleService;
|
|
use App\Domain\Catalog\CompositionKind;
|
|
use App\Domain\Catalog\ContentElement;
|
|
use App\Domain\Catalog\ContentService;
|
|
use App\Domain\Catalog\EditorialTextVariant;
|
|
use App\Domain\Catalog\PresentationAssignment;
|
|
use App\Domain\Catalog\PresentationMedia;
|
|
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
|
|
use App\Filament\Resources\Exercises\Pages\EditExercise;
|
|
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
|
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
|
use App\Models\User;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
class VerwaltungArbeitsplatzTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
|
}
|
|
|
|
public function test_saving_keeps_an_assignment_that_someone_else_added_meanwhile(): void
|
|
{
|
|
$film = $this->film();
|
|
$mine = $this->picture('Meine Galerie');
|
|
$theirs = $this->picture('Fremde Galerie');
|
|
|
|
$page = Livewire::actingAs($this->editor(), 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->call('openRedaktion', 'medien');
|
|
|
|
app(PresentationMedia::class)->assign($film, 'galerie', $theirs->id, null);
|
|
|
|
$page->call('openPresentationPicker', 'galerie')
|
|
->call('assignFromPicker', 'medium:'.$mine->id)
|
|
->call('saveRedaktion');
|
|
|
|
$this->assertEqualsCanonicalizing([$theirs->id, $mine->id], $this->order($film, 'galerie'));
|
|
}
|
|
|
|
public function test_adding_to_an_occupied_single_role_is_an_exchange(): void
|
|
{
|
|
$film = $this->film();
|
|
$old = $this->picture('Altes Titelbild');
|
|
$new = $this->picture('Neues Titelbild');
|
|
app(PresentationMedia::class)->assign($film, 'titelbild', $old->id, null);
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->call('openRedaktion', 'medien')
|
|
->call('openPresentationPicker', 'titelbild')
|
|
->assertSee('Wird ersetzt')
|
|
->assertSee('Diese Rolle hat nur ein Medium.')
|
|
->call('markPicker', 'medium:'.$new->id, true)
|
|
->assertSee('Austauschen')
|
|
->call('confirmPicker')
|
|
->assertSee('„Neues Titelbild“ ersetzt „Altes Titelbild“ an derselben Stelle')
|
|
->call('saveRedaktion');
|
|
|
|
$this->assertSame([$new->id], $this->order($film, 'titelbild'));
|
|
$this->assertNotNull($old->fresh());
|
|
}
|
|
|
|
public function test_a_stock_image_can_become_the_preview_image_through_the_shared_picker(): void
|
|
{
|
|
$film = $this->film();
|
|
$image = $this->picture('Szenenbild');
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->call('openThumbnailPicker')
|
|
->assertSee('Vorschaubild aus dem Bestand')
|
|
->assertSee('Szenenbild')
|
|
->call('markPicker', 'medium:'.$image->id, true)
|
|
->assertSee('Als Vorschaubild übernehmen')
|
|
->call('confirmPicker')
|
|
->assertSet('pickerOpen', false)
|
|
->assertSet('pictureFeedback', 'Vorschaubild übernommen. Es gibt keine neue Fassung. Für die Website ist es damit nicht freigegeben.');
|
|
|
|
$this->assertSame($image->thumbnail_path, $film->fresh()->thumbnail_path);
|
|
$this->assertSame(1, $film->fresh()->versions()->count());
|
|
}
|
|
|
|
public function test_confirmations_use_the_shared_dialog_and_only_known_actions(): void
|
|
{
|
|
$film = $this->film();
|
|
$film->teaser = 'Gespeichert';
|
|
$film->save();
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->call('openRedaktion')
|
|
->set('teaser', 'Offen')
|
|
->call('askConfirmation', 'discardRedaktion')
|
|
->assertSee('Änderungen der Redaktion verwerfen?')
|
|
->call('cancelConfirmation')
|
|
->assertSet('teaser', 'Offen')
|
|
->call('askConfirmation', 'discardRedaktion')
|
|
->call('confirmConfirmation')
|
|
->assertSet('teaser', 'Gespeichert')
|
|
->call('askConfirmation', 'saveRedaktionTexte')
|
|
->assertSet('bestaetigung', null);
|
|
}
|
|
|
|
public function test_only_editors_change_the_redaktion_and_the_address_does_not_bypass_it(): void
|
|
{
|
|
$film = $this->film();
|
|
$keeper = User::factory()->katalogverwalter()->create();
|
|
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
|
|
|
Livewire::actingAs($keeper, 'staff')
|
|
->withQueryParams(['redaktion' => '1'])
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->assertSet('redaktionOpen', false)
|
|
->assertDontSee('Redaktion bearbeiten')
|
|
->call('saveRedaktion')
|
|
->assertForbidden();
|
|
|
|
foreach (['removePresentation' => ['a1'], 'confirmPicker' => [], 'openPresentationPicker' => []] as $method => $arguments) {
|
|
Livewire::actingAs($keeper, 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->set('pickerMarked', ['medium:1' => 'x'])
|
|
->call($method, ...$arguments)
|
|
->assertForbidden();
|
|
}
|
|
|
|
$this->assertSame(0, PresentationAssignment::query()->count());
|
|
}
|
|
|
|
public function test_the_license_article_needs_the_catalog_role_and_offers_no_global_release_there(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $this->film();
|
|
$version = $film->versions()->first();
|
|
$articles = app(ArticleService::class);
|
|
$article = $articles->create('LARA-PARK', 'Alltag');
|
|
$articles->publishRelease($article, $version, 'Derselbe Unterrichtsfilm');
|
|
$image = $this->picture('Artikelbild');
|
|
app(PresentationMedia::class)->assign($article, 'titelbild', $image->id, null);
|
|
|
|
$this->actingAs($this->editor(), 'staff')
|
|
->get(LicenseArticleResource::getUrl('view', ['record' => $article]))
|
|
->assertForbidden();
|
|
|
|
$keeper = User::factory()->katalogverwalter()->create();
|
|
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
|
|
|
Livewire::actingAs($keeper, 'staff')
|
|
->test(ViewLicenseArticle::class, ['record' => $article->getKey()])
|
|
->call('openRedaktion', 'medien')
|
|
->assertSee('Artikelbild')
|
|
->assertSee('Medium öffnen')
|
|
->assertDontSee('Für die Website freigeben')
|
|
->assertDontSee('Website-Freigabe zurücknehmen');
|
|
}
|
|
|
|
public function test_creating_a_medium_from_the_picker_closes_the_picker_first(): void
|
|
{
|
|
$module = app(ContentService::class)->createComposition('Neues Medium', CompositionKind::Uebung);
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->call('openPicker')
|
|
->assertSee('Neues Medium anlegen')
|
|
->call('startCreateMedium')
|
|
->assertSet('pickerOpen', false)
|
|
->assertDontSee('Bestandteil auswählen');
|
|
}
|
|
|
|
public function test_redaktion_return_keeps_open_composition_inputs_and_saves_only_editorial_text(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis');
|
|
$version = $content->publishComposition(
|
|
$content->createComposition('Rueckweg', CompositionKind::Uebung),
|
|
[['role' => 'Unterlage', 'target' => $sheet]],
|
|
);
|
|
$editor = $this->editor();
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $version->composition_id])
|
|
->call('openPart', 0)
|
|
->set('roleDraft', 'Einstieg')
|
|
->set('learningGoal', 'Grenze erkennen')
|
|
->call('openRedaktion')
|
|
->assertSet('redaktionOpen', true)
|
|
->assertSet('partOpen', false)
|
|
->assertSee('Redaktion speichern')
|
|
->assertSee('Zurück zum Aufbau')
|
|
->assertSee('Präsentationsmedien')
|
|
->assertDontSee('In Mitgliederbibliothek anzeigen')
|
|
->assertDontSee('Vorschau für Trainer')
|
|
->assertSet('roleDraft', 'Einstieg')
|
|
->assertSet('learningGoal', 'Grenze erkennen')
|
|
->set('teaser', 'Kurzer Teaser im Manager')
|
|
->assertSee('Änderungen nicht gespeichert')
|
|
->call('closeRedaktion')
|
|
->assertSet('redaktionOpen', false)
|
|
->assertSee('Die Redaktion hat ungespeicherte Änderungen.')
|
|
->assertSet('teaser', 'Kurzer Teaser im Manager')
|
|
->assertSet('roleDraft', 'Einstieg')
|
|
->assertSet('learningGoal', 'Grenze erkennen')
|
|
->call('saveRedaktion')
|
|
->assertSee('Aufbau, Lernziel, Zeit und Fassungen bleiben unverändert.')
|
|
->assertSet('learningGoal', 'Grenze erkennen');
|
|
|
|
$composition = $version->composition->fresh();
|
|
$this->assertSame('Kurzer Teaser im Manager', $composition->teaser);
|
|
$this->assertSame(1, $composition->versions()->count());
|
|
$this->assertNull($composition->versions()->first()->learning_goal);
|
|
$this->assertSame('Unterlage', $composition->versions()->first()->members()->first()->role);
|
|
}
|
|
|
|
public function test_didactic_dialog_and_draft_discard_do_not_touch_open_redaktion_inputs(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis');
|
|
$version = $content->publishComposition(
|
|
$content->createComposition('Verdeckt', CompositionKind::Uebung),
|
|
[['role' => 'Unterlage', 'target' => $sheet]],
|
|
);
|
|
|
|
$page = Livewire::actingAs($this->editor(), 'staff')
|
|
->test(EditExercise::class, ['record' => $version->composition_id])
|
|
->call('openRedaktion')
|
|
->set('teaser', 'Noch nicht gespeichert')
|
|
->call('closeRedaktion')
|
|
->call('openModule')
|
|
->set('durationMinutes', '20')
|
|
->call('saveModule')
|
|
->assertSet('teaser', 'Noch nicht gespeichert');
|
|
|
|
$this->assertNull($version->composition->fresh()->teaser);
|
|
|
|
$page->call('discardDraft')
|
|
->assertSet('teaser', 'Noch nicht gespeichert');
|
|
|
|
$this->assertNull($version->composition->fresh()->teaser);
|
|
}
|
|
|
|
public function test_media_redaktion_return_keeps_the_open_version_text(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->createElement('film', 'film', 'Lara im Park');
|
|
$content->publishElementVersion($film, 'Filmfassung');
|
|
$editor = $this->editor();
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->set('bereich', 'inhalt')
|
|
->set('bodyDraft', 'Offener Lehrtext')
|
|
->set('thumbnailAlt', 'Offener Alternativtext')
|
|
->call('openRedaktion')
|
|
->assertSee('Zurück zur Medienbearbeitung')
|
|
->set('teaser', 'Neuer Teaser')
|
|
->call('closeRedaktion')
|
|
->assertSet('redaktionOpen', false)
|
|
->assertSet('bereich', 'inhalt')
|
|
->assertSet('bodyDraft', 'Offener Lehrtext')
|
|
->assertSet('thumbnailAlt', 'Offener Alternativtext')
|
|
->assertSet('teaser', 'Neuer Teaser')
|
|
->call('openRedaktion')
|
|
->assertSet('teaser', 'Neuer Teaser')
|
|
->call('saveRedaktion')
|
|
->call('closeRedaktion')
|
|
->assertSet('thumbnailAlt', 'Offener Alternativtext');
|
|
|
|
$film->refresh();
|
|
$this->assertSame('Neuer Teaser', $film->teaser);
|
|
$this->assertNull($film->thumbnail_alt);
|
|
}
|
|
|
|
public function test_the_redaktion_state_lives_in_the_address_for_browser_back(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->createElement('film', 'film', 'Lara im Park');
|
|
$content->publishElementVersion($film, 'Filmfassung');
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->withQueryParams(['redaktion' => '1'])
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->assertSet('redaktionOpen', true)
|
|
->assertSee('Zurück zur Medienbearbeitung')
|
|
->set('teaser', 'Offen beim Zurückblättern')
|
|
->set('redaktionOpen', false)
|
|
->assertDontSee('Zurück zur Medienbearbeitung')
|
|
->assertSee('Redaktion mit ungespeicherten Änderungen')
|
|
->assertSet('teaser', 'Offen beim Zurückblättern');
|
|
|
|
$this->assertNull($film->fresh()->teaser);
|
|
}
|
|
|
|
public function test_website_release_does_not_save_open_redaktion_inputs(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$image = $content->createElement('bild', 'bild', 'Szenenbild');
|
|
$editor = $this->editor();
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(ViewContentElement::class, ['record' => $image->getKey()])
|
|
->call('openRedaktion')
|
|
->set('websiteCredit', 'Offene Quellenzeile')
|
|
->set('teaser', 'Offener Teaser')
|
|
->call('closeRedaktion')
|
|
->set('bereich', 'website')
|
|
->call('releaseForWebsite')
|
|
->assertSet('websiteCredit', 'Offene Quellenzeile')
|
|
->assertSet('teaser', 'Offener Teaser');
|
|
|
|
$image->refresh();
|
|
$this->assertNull($image->website_credit);
|
|
$this->assertNull($image->teaser);
|
|
}
|
|
|
|
public function test_presentation_changes_are_staged_until_redaktion_is_saved(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->createElement('film', 'film', 'Lara im Park');
|
|
$content->publishElementVersion($film, 'Filmfassung');
|
|
$first = $this->picture('Galerie eins');
|
|
$second = $this->picture('Galerie zwei');
|
|
|
|
$page = Livewire::actingAs($this->editor(), 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->call('openRedaktion', 'medien')
|
|
->call('openPresentationPicker', 'galerie')
|
|
->call('markPicker', 'medium:'.$first->id, true)
|
|
->call('markPicker', 'medium:'.$second->id, true)
|
|
->set('pickerQuery', 'etwas ganz anderes')
|
|
->assertSet('pickerMarked', ['medium:'.$first->id => 'Galerie eins', 'medium:'.$second->id => 'Galerie zwei'])
|
|
->assertSee('2 Medien übernehmen')
|
|
->call('confirmPicker')
|
|
->assertSet('pickerOpen', false)
|
|
->assertSee('Neu zugeordnet')
|
|
->assertSee('Änderungen nicht gespeichert');
|
|
|
|
$this->assertSame(0, PresentationAssignment::query()->where('subject_id', $film->id)->count());
|
|
|
|
$page->call('saveRedaktion')->assertSee('Alle Änderungen gespeichert');
|
|
|
|
$this->assertSame([$first->id, $second->id], $this->order($film, 'galerie'));
|
|
}
|
|
|
|
public function test_cancelling_the_picker_keeps_the_existing_assignment(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->createElement('film', 'film', 'Lara im Park');
|
|
$content->publishElementVersion($film, 'Filmfassung');
|
|
$cover = $this->picture('Titel alt');
|
|
$other = $this->picture('Titel neu');
|
|
app(PresentationMedia::class)->assign($film, 'titelbild', $cover->id, null);
|
|
$key = 'a'.PresentationAssignment::query()->value('id');
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->call('openRedaktion', 'medien')
|
|
->call('beginExchange', $key)
|
|
->call('markPicker', 'medium:'.$other->id, true)
|
|
->call('closePicker')
|
|
->assertSee('Die vorhandene Zuordnung bleibt unverändert.')
|
|
->assertSee('Alle Änderungen gespeichert');
|
|
|
|
$this->assertSame([$cover->id], $this->order($film, 'titelbild'));
|
|
}
|
|
|
|
public function test_exchange_keeps_the_position_and_reordering_stays_within_its_role(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->createElement('film', 'film', 'Lara im Park');
|
|
$content->publishElementVersion($film, 'Filmfassung');
|
|
$one = $this->picture('Bild eins');
|
|
$two = $this->picture('Bild zwei');
|
|
$three = $this->picture('Bild drei');
|
|
$replacement = $this->picture('Bild neu');
|
|
$cover = $this->picture('Titel');
|
|
$media = app(PresentationMedia::class);
|
|
$media->assign($film, 'titelbild', $cover->id, null);
|
|
foreach ([$one, $two, $three] as $image) {
|
|
$media->assign($film, 'galerie', $image->id, null);
|
|
}
|
|
$keyOf = fn (ContentElement $image): string => 'a'.PresentationAssignment::query()->where('content_element_id', $image->id)->value('id');
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->call('openRedaktion', 'medien')
|
|
->call('beginExchange', $keyOf($two))
|
|
->call('markPicker', 'medium:'.$replacement->id, true)
|
|
->assertSee('Austauschen')
|
|
->call('confirmPicker')
|
|
->assertSee('ersetzt „Bild zwei“ an derselben Stelle')
|
|
->call('movePresentation', $keyOf($three), -1)
|
|
->call('movePresentation', $keyOf($one), -1)
|
|
->call('saveRedaktion');
|
|
|
|
$this->assertSame([$one->id, $three->id, $replacement->id], $this->order($film, 'galerie'));
|
|
$this->assertSame([$cover->id], $this->order($film, 'titelbild'));
|
|
$this->assertNotNull($two->fresh(), 'Entfernen einer Zuordnung löscht das Medium nicht.');
|
|
}
|
|
|
|
public function test_removing_an_assignment_keeps_the_medium_and_its_website_release(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->createElement('film', 'film', 'Lara im Park');
|
|
$content->publishElementVersion($film, 'Filmfassung');
|
|
$image = $this->picture('Freigegebenes Bild');
|
|
$image->website_released_at = now();
|
|
$image->save();
|
|
app(PresentationMedia::class)->assign($film, 'titelbild', $image->id, null);
|
|
$key = 'a'.PresentationAssignment::query()->value('id');
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->call('openRedaktion', 'medien')
|
|
->call('removePresentation', $key)
|
|
->assertSee('Änderungen nicht gespeichert')
|
|
->call('saveRedaktion');
|
|
|
|
$this->assertSame(0, PresentationAssignment::query()->where('subject_id', $film->id)->count());
|
|
$this->assertNotNull($image->fresh());
|
|
$this->assertNotNull($image->fresh()->website_released_at);
|
|
}
|
|
|
|
public function test_discarding_the_redaktion_restores_saved_values_only(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->createElement('film', 'film', 'Lara im Park');
|
|
$film->teaser = 'Gespeichert';
|
|
$film->save();
|
|
$content->publishElementVersion($film, 'Filmfassung');
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->set('bodyDraft', 'Offener Lehrtext')
|
|
->call('openRedaktion')
|
|
->set('teaser', 'Verworfen')
|
|
->set('variantBody', 'Nur für die Kachel')
|
|
->call('saveVariant')
|
|
->call('discardRedaktion')
|
|
->assertSet('teaser', 'Gespeichert')
|
|
->assertSet('bodyDraft', 'Offener Lehrtext')
|
|
->assertSee('Alle Änderungen gespeichert');
|
|
|
|
$this->assertSame(0, EditorialTextVariant::query()->count());
|
|
}
|
|
|
|
public function test_a_missing_working_title_is_shown_at_the_field_and_nothing_is_saved(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->createElement('film', 'film', 'Lara im Park');
|
|
$content->publishElementVersion($film, 'Filmfassung');
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->call('openRedaktion', 'medien')
|
|
->set('workingTitle', '')
|
|
->set('teaser', 'Bleibt offen')
|
|
->call('saveRedaktion')
|
|
->assertSet('redaktionTab', 'texte')
|
|
->assertSet('redaktionFehlerFeld', 'workingTitle')
|
|
->assertSee('Der Arbeitstitel fehlt.')
|
|
->assertSet('teaser', 'Bleibt offen');
|
|
|
|
$this->assertNull($film->fresh()->teaser);
|
|
$this->assertSame('Lara im Park', $film->fresh()->working_title);
|
|
}
|
|
|
|
private function film(): ContentElement
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->createElement('film', 'film', 'Lara im Park');
|
|
$content->publishElementVersion($film, 'Filmfassung');
|
|
|
|
return $film->fresh();
|
|
}
|
|
|
|
private function picture(string $title): ContentElement
|
|
{
|
|
$image = app(ContentService::class)->createElement('bild', 'bild', $title);
|
|
$image->thumbnail_path = 'vorschau/'.md5($title).'.jpg';
|
|
$image->save();
|
|
|
|
return $image;
|
|
}
|
|
|
|
/**
|
|
* @return list<int>
|
|
*/
|
|
private function order(ContentElement $subject, string $role): array
|
|
{
|
|
return PresentationAssignment::query()
|
|
->where('subject_type', $subject->getMorphClass())
|
|
->where('subject_id', $subject->id)
|
|
->whereHas('role', fn ($query) => $query->where('slug', $role))
|
|
->orderBy('position')
|
|
->pluck('content_element_id')
|
|
->map(fn ($id): int => (int) $id)
|
|
->all();
|
|
}
|
|
|
|
private function editor(): User
|
|
{
|
|
$editor = User::factory()->redakteur()->create();
|
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
|
|
|
return $editor;
|
|
}
|
|
}
|