Files
laraundfelix/tests/Feature/LibraryProgramTest.php
T
LarsandCursor 7b54c38623
Deploy Test / test (push) Successful in 17s
Deploy Test / deploy (push) Successful in 21s
Zeige freigegebene Programme als Aufbau in der Bibliothek
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-16 08:09:37 +01:00

71 lines
2.7 KiB
PHP

<?php
namespace Tests\Feature;
use App\Domain\Catalog\ArticleService;
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 LibraryProgramTest extends TestCase
{
use RefreshDatabase;
public function test_a_released_program_shows_its_structure_and_an_unreleased_one_stays_material(): void
{
$content = app(ContentService::class);
$film = $content->publishElementVersion(
$content->createElement('film', 'film', 'Hofszene'),
null,
['file' => 'inhalte/hof.mp4'],
);
$programm = EditorialContentKind::query()->where('slug', 'programm')->firstOrFail();
$released = $content->publishComposition(
tap($content->createComposition('Sicher auf dem Schulweg'), function ($item) use ($programm): void {
$item->editorial_content_kind_id = $programm->id;
$item->save();
}),
[['role' => 'Film', 'target' => $film]],
);
$hidden = $content->publishComposition(
$content->createComposition('Noch nicht zeigen'),
[['role' => 'Film', 'target' => $film]],
);
$articles = app(ArticleService::class);
$visibleArticle = $articles->create('sichtbar');
$articles->publishRelease($visibleArticle, $released, 'Programmartikel.');
$hiddenArticle = $articles->create('verborgen');
$articles->publishRelease($hiddenArticle, $hidden, 'Nicht freigegeben.');
$offers = app(OfferService::class);
$rights = $offers->createRightsProfile('Film', 'ehrenamtlich', ['film' => ['streamen', 'laden']]);
$offer = $offers->create('Programmzugang');
$offers->activate($offer, [
['target' => $visibleArticle->fresh(), 'rights' => $rights],
], ['grant_kind' => 'auf_abruf']);
$member = User::factory()->create();
app(GrantIssuer::class)->claim($member, $offer);
app(CompositionDisplayRelease::class)->release($released, $member);
$this->actingAs($member)
->get(route('member.library'))
->assertOk()
->assertSee('Sicher auf dem Schulweg')
->assertDontSee('Noch nicht zeigen');
$this->actingAs($member)
->get(route('member.program', $released->composition))
->assertOk()
->assertSee('Film: Hofszene')
->assertSee('Laden')
->assertSee('<video', false);
}
}