mardi 21 novembre 2017

Laravel 5.5 Testing JSON header doesn't work

I have a problem in testing Laravel 5.5. I need to send a Bearer Token in TEST HEADER, but doesn't work

public function testAuthCheckinvalidToken()
    {
        $response = $this->withHeaders([
            'Accept' => 'application/json',
            'Content-Type' => 'application/json',
            'Authorization' => 'Bearer ' . $this->token,
        ])->json('GET', 'auth/check');
    ...
    }

When I dd($response), only the default HEADERS is set:

#headers: array:5 [
            "cache-control" => array:1 [
              0 => "no-cache, private"
            ]
            "date" => array:1 [
              0 => "Tue, 21 Nov 2017 18:48:27 GMT"
            ]
            "content-type" => array:1 [
              0 => "application/json"
            ]
            "x-ratelimit-limit" => array:1 [
              0 => 60
            ]
            "x-ratelimit-remaining" => array:1 [
              0 => 59
            ]
          ]

My HEADERS doesn't appear. I think that I am right

Aucun commentaire:

Enregistrer un commentaire