【发布时间】:2018-05-05 08:43:50
【问题描述】:
我在测试 Laravel 5.5 时遇到问题。我需要在 TEST HEADER 中发送不记名令牌,但不起作用
public function testAuthCheckinvalidToken()
{
$response = $this->withHeaders([
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $this->token,
])->json('GET', 'auth/check');
...
}
当我dd($response)时,只设置了默认的HEADERS:
#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
]
]
我的标题没有出现。 我认为我是对的
【问题讨论】:
标签: laravel-5 phpunit laravel-5.5 laravel-request laravel-response