Skip to content

Commit 3e20576

Browse files
committed
minor test improvements
1 parent 142efdc commit 3e20576

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

tests/TenantUserImpersonationTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
->assertRedirect('/login');
151151
});
152152

153-
test('stopImpersonating can keep the user authenticated', function() {
153+
test('stopImpersonating can keep the user authenticated', function () {
154154
makeLoginRoute();
155155

156156
Route::middleware(InitializeTenancyByPath::class)->prefix('/{tenant}')->group(getRoutes(false));
@@ -191,7 +191,7 @@
191191
->assertSee('You are logged in as Joe');
192192
});
193193

194-
test('stopImpersonating logs out the user from the impersonation guard stored in session', function() {
194+
test('stopImpersonating logs out the user from the impersonation guard stored in session', function () {
195195
Route::middleware(InitializeTenancyByPath::class)->prefix('/{tenant}')->group(getRoutes(false));
196196

197197
$tenant = Tenant::create([
@@ -225,11 +225,10 @@
225225
'provider' => 'users',
226226
]]);
227227

228-
// Switch guard from 'web' to 'test' and manually log in the user through 'test'
229-
auth()->shouldUse('test');
230-
auth()->loginUsingId($user->id);
228+
// Manually log the user in through the 'test' guard
229+
auth('test')->loginUsingId($user->id);
231230

232-
// Should log out the user from the guard used for impersonation ('web')
231+
// Should log the user out from the guard used for impersonation ('web')
233232
UserImpersonation::stopImpersonating();
234233

235234
expect(auth('web')->check())->toBeFalse();
@@ -241,7 +240,7 @@
241240
// stopImpersonating should throw an exception instead of logging out
242241
expect(fn() => UserImpersonation::stopImpersonating())->toThrow(Exception::class);
243242

244-
expect(auth()->check())->toBeTrue();
243+
expect(auth('test')->check())->toBeTrue();
245244
});
246245

247246
test('tokens have a limited ttl', function () {

0 commit comments

Comments
 (0)