lernschiff/tests/Feature/License/EnsureActiveLicenseTest.php

28 lines
1.0 KiB
PHP

<?php
use App\Models\License;
use App\Models\Tenant;
use App\Models\User;
use function Pest\Laravel\actingAs;
uses(\Illuminate\Foundation\Testing\RefreshDatabase::class);
it('blockt child-Zugriff bei abgelaufener Lizenz', function () {
$tenant = Tenant::factory()->create();
$license = License::factory()->for($tenant)->expired()->create();
$child = User::factory()->for($tenant)->withRole('child')->withLicense($license)->create();
actingAs($child)->get('/dashboard')->assertRedirect('/lizenz-abgelaufen');
});
it('erlaubt child-Zugriff bei aktiver Lizenz', function () {
$tenant = Tenant::factory()->create();
$license = License::factory()->for($tenant)->active()->create();
$child = User::factory()->for($tenant)->withRole('child')->withLicense($license)->create();
actingAs($child)->get('/dashboard')->assertOk();
});
it('erlaubt Lehrer-Zugriff ohne Lizenz-Check', function () {
$teacher = User::factory()->withRole('teacher')->create();
actingAs($teacher)->get('/dashboard')->assertOk();
});