Skip to content

Commit

Permalink
Merge pull request #11674 from nanaya/test-user-null-reset
Browse files Browse the repository at this point in the history
Fix acting as null user not reset existing user in test
  • Loading branch information
notbakaneko authored Nov 22, 2024
2 parents 2cba1e2 + bf52479 commit 2b827cd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ protected function actAsUserWithToken(Token $token, $driver = null): static
$guard = app('auth')->guard($driver);
$user = $token->getResourceOwner();

if ($user !== null) {
// guard doesn't accept null user.
if ($user === null) {
$guard->logout();
} else {
$guard->setUser($user);
$user->withAccessToken($token);
}
Expand Down

0 comments on commit 2b827cd

Please sign in to comment.