Eine Fassung bleibt nummeriert und kann deaktiviert werden. Beschreibung und fachliche Säulen gehören zum Medium und legen keine neue Fassung an. Co-authored-by: Cursor <cursoragent@cursor.com>
75 lines
2.7 KiB
PHP
75 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Domain\Catalog\CompositionKind;
|
|
use App\Domain\Catalog\ContentService;
|
|
use App\Domain\Catalog\DomainRuleException;
|
|
use App\Domain\Catalog\PillarService;
|
|
use App\Filament\Resources\Pillars\PillarResource;
|
|
use App\Filament\Support\CatalogReading;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class PillarAssignmentTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_a_medium_can_belong_to_several_pillars_and_a_course_keeps_them(): void
|
|
{
|
|
$pillars = app(PillarService::class);
|
|
$grenzen = $pillars->create('Grenzen');
|
|
$hilfe = $pillars->create('Hilfe holen');
|
|
$pillars->create('Alltag');
|
|
$content = app(ContentService::class);
|
|
$filmElement = $content->createElement('film', 'film', 'Film');
|
|
$film = $content->publishElementVersion($filmElement, 'Text');
|
|
$sheet = $content->publishElementVersion($content->createElement('pdf', 'pdf', 'Blatt'), 'Hinweis');
|
|
$pillars->assign($filmElement, [$hilfe->id, $grenzen->id]);
|
|
$pillars->assign($sheet->element, [$grenzen->id]);
|
|
|
|
$this->assertSame(1, $filmElement->versions()->count());
|
|
$this->assertSame(['Grenzen', 'Hilfe holen'], $filmElement->pillars()->pluck('name')->all());
|
|
|
|
$exercise = $content->publishComposition(
|
|
$content->createComposition('Übung Grenzen', CompositionKind::Uebung),
|
|
[
|
|
['role' => 'Film', 'target' => $film],
|
|
['role' => 'Blatt', 'target' => $sheet],
|
|
],
|
|
);
|
|
$course = $content->publishComposition(
|
|
$content->createComposition('Kurs Alltag', CompositionKind::Kurs),
|
|
[['role' => 'Übung', 'target' => $exercise]],
|
|
);
|
|
|
|
$this->assertSame([
|
|
'Film — Grenzen, Hilfe holen',
|
|
'Blatt — Grenzen',
|
|
], app(CatalogReading::class)->memberPillars($course->composition));
|
|
|
|
$editor = User::factory()->redakteur()->create();
|
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
|
|
|
$this->actingAs($editor, 'staff')
|
|
->get(PillarResource::getUrl('index'))
|
|
->assertOk()
|
|
->assertSee('Grenzen')
|
|
->assertSee('Alltag')
|
|
->assertSee('weitere hinzukommen');
|
|
}
|
|
|
|
public function test_a_pillar_with_media_cannot_be_deleted(): void
|
|
{
|
|
$pillars = app(PillarService::class);
|
|
$pillar = $pillars->create('Grenzen');
|
|
$element = app(ContentService::class)->createElement('text', 'text', 'Hinweis');
|
|
$pillars->assign($element, [$pillar->id]);
|
|
|
|
$this->expectException(DomainRuleException::class);
|
|
|
|
$pillars->delete($pillar);
|
|
}
|
|
}
|