TenantAtlas/tests/Feature/ManagedTenants/OpenArchivedTenantTest.php
2026-02-01 10:49:19 +01:00

27 lines
871 B
PHP

<?php
declare(strict_types=1);
use App\Models\Tenant;
use App\Support\ManagedTenants\ManagedTenantContext;
it('shows a status screen (not 404) when opening an archived managed tenant', function (): void {
$tenant = Tenant::factory()->create(['status' => 'active']);
[$user] = createUserWithTenant($tenant, role: 'readonly');
$tenant->delete();
$this->actingAs($user)
->get("/admin/managed-tenants/{$tenant->id}/open")
->assertRedirect('/admin/managed-tenants/archived')
->assertSessionHas(ManagedTenantContext::ARCHIVED_TENANT_ID_SESSION_KEY, $tenant->id);
$this->withSession([
ManagedTenantContext::ARCHIVED_TENANT_ID_SESSION_KEY => $tenant->id,
])->actingAs($user)
->get('/admin/managed-tenants/archived')
->assertOk()
->assertSee('Archived')
->assertSee($tenant->name);
});