Level 5
You can "pretend" to be logged in as a user, using actingAs() on your tests:
$user = \App\User::find($id);
$this->actingAs($user);
$this->get('/my-route'); // Will pass the authentication checks.
1 like
Hi,
I'm trying to create unit tests for my rest controllers (with and without auth guard).
How can I mock the authenticate middleware ? Can some please provide me an example.
Roy
Please or to participate in this conversation.