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

24 lines
834 B
PHP

<?php
declare(strict_types=1);
use App\Models\Tenant;
use App\Support\ManagedTenants\ManagedTenantContext;
it('stores session selection and redirects deterministically when opening an active managed tenant', function (): void {
$tenant = Tenant::factory()->create(['status' => 'active']);
[$user] = createUserWithTenant($tenant, role: 'readonly');
$this->actingAs($user)
->get("/admin/managed-tenants/{$tenant->id}/open")
->assertRedirect('/admin/managed-tenants/current')
->assertSessionHas(ManagedTenantContext::CURRENT_TENANT_ID_SESSION_KEY, $tenant->id);
$this->withSession([
ManagedTenantContext::CURRENT_TENANT_ID_SESSION_KEY => $tenant->id,
])->actingAs($user)
->get('/admin/managed-tenants/current')
->assertOk()
->assertSee($tenant->name);
});