Skip to content

Commit

Permalink
- Changed actingAsApiUser to accept guard
Browse files Browse the repository at this point in the history
  • Loading branch information
dash8x committed Mar 17, 2024
1 parent 6315d65 commit 2493eae
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,18 @@ public function jsonApi($method, $uri, array $data = [], string $access_cookie =
* @param mixed $email
* @param array $scopes
*/
protected function actingAsApiUser($email, $scopes = ['read', 'write'])
protected function actingAsApiUser($email, $scopes = ['read', 'write'], $guard = null)
{
$this->seedDatabase();

//find the user
$user = is_object($email) ? $email : $this->getActiveAdminUser($email);

Passport::actingAs($user, $scopes);
if (! $guard) {
$guard = $user instanceof User ? 'api_admin' : 'api_' . ($user->getMorphClass());
}

Passport::actingAs($user, $scopes, $guard);
}

/**
Expand Down

0 comments on commit 2493eae

Please sign in to comment.