Find out cause of 403 error in Symfony PHPUnit test
20 May 2025 (Updated 20 May 2025)
Suppose you wrote this PHPUnit test for a Symfony HTTP endpoint:
public function testMeEndpoint() {
$response = $this->client->request('GET', '/v1/users/me', [
'auth_bearer' => 'some-token',
]);
}
And that resulted in a AccessDeniedException
and this failed test:

To find out what caused the AccessDeniedException
, you can do this:

Tagged:
Symfony recipes