So I want to unit test my API endpoints. I'm using Laravel 5.8 and api authentication is done with Passport I have the following test:
public function guest_can_login()
{
$user = factory(User::class)->create();
$response = $this->json('POST', 'api/login', [
'email' => $user->email,
'password' => 'secret',
]);
$response
->assertStatus(200)
->assertJson([
'success' => true,
]);
}
when i execute the request with Postman it works well, authenticates user and return a token but when i launch the test it fails with ("Expected status code 200 but received 500.")
So i searched a little deeper in the response and i found this:
"message": "Personal access client not found. Please create one."
no clue why this is happening, if anyone has insight on this
EDIT: fixed see my last answer below