Files
ots/tests/Feature/TeamPolicyTest.php
T
Twyco e9fc8cabb5
CI/CD / test_and_check_app (push) Failing after 58s
CI/CD / Publish immutable image (push) Skipped
Fix team authorization, invite revocation, and slug handling
2026-09-19 05:54:18 +02:00

30 lines
984 B
PHP

<?php
use App\Enums\TeamMemberRole;
use App\Models\Team;
use App\Models\User;
use Database\Factories\TeamFactory;
test('team permissions follow membership and role', function (?TeamMemberRole $role, bool $canView, bool $canManage) {
$user = User::factory()->create();
$team = TeamFactory::new()->create();
if ($role !== null) {
$team->members()->attach($user, ['role' => $role]);
}
expect($user->can('view', $team))->toBe($canView);
expect($user->can('manage', $team))->toBe($canManage);
})->with([
'outsider' => [null, false, false],
'member' => [TeamMemberRole::Member, true, false],
'admin' => [TeamMemberRole::Admin, true, true],
]);
test('team creation requires a verified email', function () {
$verified = User::factory()->create();
$unverified = User::factory()->unverified()->create();
expect($verified->can('create', Team::class))->toBeTrue();
expect($unverified->can('create', Team::class))->toBeFalse();
});