78 lines
3.3 KiB
PHP
78 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Domain\Catalog\ArticleService;
|
|
use App\Domain\Catalog\Composition;
|
|
use App\Domain\Catalog\CompositionDisplayRelease;
|
|
use App\Domain\Catalog\ContentService;
|
|
use App\Domain\Catalog\EditorialContentKind;
|
|
use App\Domain\Catalog\OfferService;
|
|
use App\Domain\Entitlement\GrantIssuer;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class LibraryCompletionTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_didactic_fields_partial_coverage_and_public_page_follow_the_released_version(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->publishElementVersion($content->createElement('film', 'film', 'Hof'), null, ['file' => 'inhalte/hof.mp4']);
|
|
$sheet = $content->publishElementVersion($content->createElement('text', 'document', 'Blatt'), 'Text');
|
|
$programm = EditorialContentKind::query()->where('slug', 'programm')->firstOrFail();
|
|
$version = $content->publishComposition(
|
|
tap($content->createComposition('Öffentliches Programm'), function ($item) use ($programm): void {
|
|
$item->editorial_content_kind_id = $programm->id;
|
|
$item->thumbnail_error = 'Kein Bild erzeugt.';
|
|
$item->save();
|
|
}),
|
|
[
|
|
['role' => 'Film', 'target' => $film],
|
|
['role' => 'Blatt', 'target' => $sheet],
|
|
],
|
|
null,
|
|
null,
|
|
['learning_goal' => 'Abstand halten', 'duration_minutes' => 20, 'material_note' => 'Ein Blatt'],
|
|
);
|
|
$articles = app(ArticleService::class);
|
|
$filmArticle = $articles->create('nur-film-fertig');
|
|
$articles->publishRelease($filmArticle, $film, 'Nur Film.');
|
|
$offers = app(OfferService::class);
|
|
$rights = $offers->createRightsProfile('Film', 'ehrenamtlich', ['film' => ['streamen']]);
|
|
$offer = $offers->create('Teilprogramm');
|
|
$offers->activate($offer, [['target' => $filmArticle->fresh(), 'rights' => $rights]], ['grant_kind' => 'auf_abruf']);
|
|
$member = User::factory()->create();
|
|
app(GrantIssuer::class)->claim($member, $offer);
|
|
app(CompositionDisplayRelease::class)->release($version, $member);
|
|
|
|
$this->actingAs($member)->get(route('member.program', $version->composition))
|
|
->assertOk()
|
|
->assertSee('teilweise')
|
|
->assertSee('Abstand halten')
|
|
->assertSee('Kein Bild erzeugt.')
|
|
->assertSee('Platzhalter');
|
|
|
|
$this->get(route('public.program', $version->composition))
|
|
->assertOk()
|
|
->assertSee('Öffentliches Programm')
|
|
->assertSee('Abstand halten')
|
|
->assertDontSee('inhalte/hof.mp4');
|
|
|
|
$this->get('/medien/bibliothek/geheim.jpg')->assertNotFound();
|
|
}
|
|
|
|
public function test_review_fixture_can_be_repeated(): void
|
|
{
|
|
$actor = User::factory()->create();
|
|
|
|
$this->artisan('library:review-fixture', ['--actor' => $actor->id])->assertSuccessful();
|
|
$this->artisan('library:review-fixture', ['--actor' => $actor->id])->assertSuccessful();
|
|
|
|
$this->assertSame(1, Composition::query()->where('designation', 'Prüfprogramm Abstand')->count());
|
|
$this->assertNotNull(User::query()->where('email', 'trainer-pruefung@example.test')->first());
|
|
}
|
|
}
|