I guys ! I have a problem when i'm trying to make some unit test with Laravel and Passport.
I have some route protected by the auth:api middleware, but some other protected by the Passport scope middleware.
For exemple, this is one of my unit test :
public function testGetPublishedPost(){
$user = factory(\App\User::class)->create();
$this->actingAs($user, 'api');
$article1 = factory(\App\Article::class)->create();
$article2 = factory(\App\Article::class)->create();
$article3 = factory(\App\Article::class)->create( ['published' => false);
$json = $this->call('get', '/api/articles');
$articles = json_decode($json->getContent());
$this->assertEquals(200, $json->getStatusCode());
$this->assertEquals(2, count($articles));
}
All is working fine with this one, but now, I would like to make some test including a scope.
How can i do that ?
Thanks !
If you are not concerned about testing the auth middleware, you can just skip the passport auth altogether by defining a temporary route to your function: