How to add headers to test?

Posted 1 year ago by chillcaw

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

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.