TenantAtlas/tests/Feature/Workspaces/ManagedTenantUniquenessTest.php
2026-02-01 12:19:57 +01:00

21 lines
629 B
PHP

<?php
declare(strict_types=1);
use App\Models\Tenant;
use Illuminate\Database\QueryException;
it('enforces globally unique Entra tenant id (tenants.tenant_id)', function () {
Tenant::factory()->create([
'tenant_id' => '00000000-0000-0000-0000-000000000001',
'external_id' => '00000000-0000-0000-0000-000000000001',
'is_current' => true,
]);
expect(fn () => Tenant::factory()->create([
'tenant_id' => '00000000-0000-0000-0000-000000000001',
'external_id' => '00000000-0000-0000-0000-000000000002',
'is_current' => false,
]))->toThrow(QueryException::class);
});