Level 37
I think the correct way is to use a fourth argument in the json function:
$this->json('POST', 'users/3', ['name' => 'Sally'], ['HTTP_Authorization' => $this->token]);
Try it.
2 likes
I'm using Lumen, but there is no information in the Lumen documentation on how to do this. So I followed the Laravel docs:
public function testUpdateMethodSuccess()
{
$response = $this->withHeaders([
'HTTP_Authorization', $this->token
])->json('POST', 'users/3', ['name' => 'Sally']);
$response->assertResponseStatus(422);
}
Whether I use ->header or ->withHeaders I get a 'call to undefined method error' from phpunit
I think the correct way is to use a fourth argument in the json function:
$this->json('POST', 'users/3', ['name' => 'Sally'], ['HTTP_Authorization' => $this->token]);
Try it.
Please or to participate in this conversation.