I'm trying to test my Laravel api with unit testing. But when I try to check for a status code it's not working the way I want it to.
This is my code:
public function testExample()
{
$client = new Client();
$res = $client->request('POST', 'domain.dev/api/v1/test/1', [
'form_params' => [
'currentUserId' => 13
]
]); //line 22
$this->assertEquals(500, $client->getResponse()->getStatusCode());
}
When I try this in for example postman I receive the following:
{"result":{"message":"Error show school"}}
with status code 500
If I run phpunit it shows:
/Users/jamie/Code/domain/tests/ExampleTest.php:22
(see comment for line 22)
What am I doing wrong here?