If you use Passport::actingAs() in a test while in the tested API route needs to revoke the authenticated user's current access token, then that causes an error in the test. That is because Eloquent can not revoke a token that does not exist in database.
Passport::actingAs($user);
auth()->user()->token()->revoke(); // This currently causes an error
This PR fixes that by creating and saving an access and refresh token in the database.
I also create a refresh token because of #1739 so the following works as well:
This might be a breaking change to existing applications. I would recommend maybe creating the tokens yourself in the few tests that need to actually revoke. 👍
If you use
Passport::actingAs()
in a test while in the tested API route needs to revoke the authenticated user's current access token, then that causes an error in the test. That is because Eloquent can not revoke a token that does not exist in database.This PR fixes that by creating and saving an access and refresh token in the database.
I also create a refresh token because of #1739 so the following works as well: