'PHPUnit asserting exception
I am trying to handle an exception and assert that it is thrown but everytime an error is thrown:
public function testUserAuthenticationWithoutToken(): void
{
$this->expectExceptionCode(401);
$this->expectErrorMessage("No API token provided");
$this->authenticator->authenticate($this->request);
}
Testing .F
2 / 2 (100%)Time: 00:00.826, Memory: 10.00 MB
There was 1 failure:
1) App\Tests\Security\ApiTokenAuthenticatorTest::testUserAuthenticationWithoutToken Failed asserting that 0 is equal to expected exception code 401.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
