1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-05-06 16:24:03 +00:00

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.
This commit is contained in:
lukinovec 2026-04-13 10:41:21 +02:00
parent 920cb06d1f
commit 1289550533

View file

@ -191,7 +191,7 @@ test('stopImpersonating can keep the user authenticated', function() {
->assertSee('You are logged in as Joe'); ->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)); Route::middleware(InitializeTenancyByPath::class)->prefix('/{tenant}')->group(getRoutes(false));
$tenant = Tenant::create([ $tenant = Tenant::create([
@ -225,8 +225,9 @@ test('stopImpersonating logs out the user from the guard used while starting imp
'provider' => 'users', 'provider' => 'users',
]]); ]]);
// Manually log in the user using a different guard // Switch guard from 'web' to 'test' and manually log in the user through 'test'
auth('test')->loginUsingId($user->id); auth()->shouldUse('test');
auth()->loginUsingId($user->id);
// Should log out the user from the guard used for impersonation ('web') // Should log out the user from the guard used for impersonation ('web')
UserImpersonation::stopImpersonating(); UserImpersonation::stopImpersonating();