knubbe
knubbe

Reputation: 1182

Laravel passport test fails after update to laravel 8

After update to laravel 8 my passport tests fail because of factory and for all test I get message like this:

BadMethodCallException: Call to undefined method Laravel\Passport\Client::factory()

Upvotes: 0

Views: 570

Answers (2)

knubbe
knubbe

Reputation: 1182

I finally solve this issue by removing namespace for api routes in RoutesServiceProvider. I also use \Illuminate\Routing\Middleware\SubstituteBindings::class instead of bindings in api middleware groups (Kernel.php) and I use controller class in api routes

Upvotes: 0

lagbox
lagbox

Reputation: 50541

The Laravel\Passport\Client model does not use the HasFactory trait. You will have to call the factory directly:

Laravel\Passport\Database\Factories\ClientFactory::new()->count(3)->make();

Laravel 8.x Docs - Database Testing - Model Factories - Creating Models

Upvotes: 1

Related Questions