24 lines
834 B
PHP
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);
|
|
});
|