Hey everyone,
So I was looking at doing some units tests on my Laravel application but I am unable to find a solution on how to pass an authenticated user to the the test so we can test protected routes, no user data is stored locally other than there auth0 id. All user management is done via the management API so mitigate any chance of data becoming out of sync.
Example test below
public function the_dashboard_route_returns_a_successful_response(): void
{
// Unauthenticated user
$response = $this->get(route('Dashboard'));
$response
->assertStatus(302)
->assertRedirectToRoute('Login');
// Authenticated User
$user = ""; // <-- How can I generate an authenticated user
$response = $this->actingAs($user)->get(route('Dashboard'))
->assertOk()
->assertViewIs('pages.dashboard');
}
All the Auth0 blog posts seem to be down and I have had no response for the support, so hoping the community can help.
Thanks in advance!