Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for Laravel 9.x set the client on the TokenGuard when mocking the client #1680

Closed
wants to merge 1 commit into from

Conversation

systemsolutionweb
Copy link

Same as #1519 Stub client on guard when calling Passport::actingAsClient()

I'm trying testing a package laravel 9.x with passport 10.x (it has support for 10.x and 11.x)

This PR changes the Passport::actingAsClient() method. Currently when stubbing the client via Passport, the guard doesn't actually reflect the stub:

>>> $client = Laravel\Passport\Database\Factories\ClientFactory::new()->createOne()
=> Laravel\Passport\Client {#4807}
>>> Laravel\Passport\Passport::actingAsClient($client)
=> Laravel\Passport\Client {#4807}
>>> auth()->guard('api')->client()
=> null

After this PR the following happens:

>>> $client = Laravel\Passport\Database\Factories\ClientFactory::new()->createOne()
=> Laravel\Passport\Client {#4807}
>>> Laravel\Passport\Passport::actingAsClient($client, [], 'api')
=> Laravel\Passport\Client {#4807}
>>> auth()->guard('api')->client()
=> Laravel\Passport\Client {#4807}

I'm fairly sure this won't get merged 😖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant