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

[8.x] Add a Passport Client factory to Passport publishing #1171

Merged
merged 3 commits into from
Jan 27, 2020

Conversation

Orrison
Copy link
Contributor

@Orrison Orrison commented Jan 24, 2020

In the help documentation for 6.x and up there is reference in the testing section to test Client access with the method Passport::actingAsClient and that it takes a Client model created by a factory to be passed in. https://laravel.com/docs/6.x/passport#testing

use Laravel\Passport\Client;
use Laravel\Passport\Passport;

public function testGetOrders()
{
    Passport::actingAsClient(
        factory(Client::class)->create(),
        ['check-status']
    );

    $response = $this->get('/api/orders');

    $response->assertStatus(200);
}

Just trying that code out of the box fails since there is no published asset for a Laravel\Passport\Client factory. The user is left to make one on their own.
This will publish a Client factory that the user can use for this.

I don't believe it will break any existing features as it is just publishing a factory for the user. It could possibly overwrite one the user has already created if it was the same filename?
I think it will make testing this feature easier for Laravel users as they don't have to reference the oauth_clients table and create the factory themselves.

I don't have any tests included as I am not sure how to test the publish functionality and it seems the other publishes are not tested. If you would like me to write some tests please let me know. I could try harder to find a way to test that.

Thank you!

Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
@driesvints driesvints changed the title Add a Passport Client factory to Passport publishing [8.x] Add a Passport Client factory to Passport publishing Jan 27, 2020
@driesvints
Copy link
Member

driesvints commented Jan 27, 2020

If you bump the minimum Laravel components versions to v6.12.0 we can use the new loadFactoriesFrom method. But then they can't be adjusted so it's probably best to do a combination of both.

laravel/framework#31133

@taylorotwell taylorotwell merged commit e467443 into laravel:8.x Jan 27, 2020
@Orrison Orrison deleted the clientFactory branch January 27, 2020 16:58
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.

3 participants