TenantAtlas/tests/Unit/Auth/UnknownCapabilityGuardTest.php
2026-01-28 22:04:45 +01:00

21 lines
617 B
PHP

<?php
use App\Models\Tenant;
use App\Models\User;
use App\Services\Auth\CapabilityResolver;
use App\Support\TenantRole;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('fails fast on unknown capability strings', function () {
$tenant = Tenant::factory()->create();
$user = User::factory()->create();
$user->tenants()->attach($tenant->getKey(), ['role' => TenantRole::Owner->value, 'source' => 'manual']);
$resolver = app(CapabilityResolver::class);
$resolver->can($user, $tenant, 'tenant_membership.managee');
})->throws(InvalidArgumentException::class);