From 12895505332425b0ef704d390909e4e71c1e1a96 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 13 Apr 2026 10:41:21 +0200 Subject: [PATCH] Rename test and use different current guard Originally, we just authenticated the user using a different guard, without actually switching to that guard. Now, we fully switch to the 'test' guard. --- tests/TenantUserImpersonationTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/TenantUserImpersonationTest.php b/tests/TenantUserImpersonationTest.php index 2bb3b910..e4ef9a80 100644 --- a/tests/TenantUserImpersonationTest.php +++ b/tests/TenantUserImpersonationTest.php @@ -191,7 +191,7 @@ test('stopImpersonating can keep the user authenticated', function() { ->assertSee('You are logged in as Joe'); }); -test('stopImpersonating logs out the user from the guard used while starting impersonation', function() { +test('stopImpersonating logs out the user from tenancy_impersonation_guard stored in session', function() { Route::middleware(InitializeTenancyByPath::class)->prefix('/{tenant}')->group(getRoutes(false)); $tenant = Tenant::create([ @@ -225,8 +225,9 @@ test('stopImpersonating logs out the user from the guard used while starting imp 'provider' => 'users', ]]); - // Manually log in the user using a different guard - auth('test')->loginUsingId($user->id); + // Switch guard from 'web' to 'test' and manually log in the user through 'test' + auth()->shouldUse('test'); + auth()->loginUsingId($user->id); // Should log out the user from the guard used for impersonation ('web') UserImpersonation::stopImpersonating();