Laravel 5.1/phpunit-使用get/post调用发送标头

Laravel 5.1/phpunit-使用get/post调用发送标头,phpunit,laravel-5.1,Phpunit,Laravel 5.1,我正在寻找一种解决方案,在phpunit测试中发送给服务器的get/post请求中嵌入jwt令牌作为头。 是否有任何选项可将标题添加到GET/POST调用?我目前正在使用以下方法向服务器发送GET请求 content=$this->get('users/logout')->response->getContent() 您需要在标题前面加上HTTP.。例如: $server = ['HTTP_X-Requested-With' => 'XMLHttpRequest']; $this->

我正在寻找一种解决方案,在phpunit测试中发送给服务器的get/post请求中嵌入jwt令牌作为头。 是否有任何选项可将标题添加到GET/POST调用?我目前正在使用以下方法向服务器发送GET请求

content=$this->get('users/logout')->response->getContent()


您需要在标题前面加上
HTTP.
。例如:

$server = ['HTTP_X-Requested-With' => 'XMLHttpRequest'];
$this->call('get', '/users/logout', [], [], $server);
替代语法::

$this->client->setServerParameter('HTTP_X-Requested-With', 'XMLHttpRequest');
$this->call('get', '/users/logout');

希望获得此帮助

您需要在标题前面加上
HTTP
。例如:

$server = ['HTTP_X-Requested-With' => 'XMLHttpRequest'];
$this->call('get', '/users/logout', [], [], $server);
替代语法::

$this->client->setServerParameter('HTTP_X-Requested-With', 'XMLHttpRequest');
$this->call('get', '/users/logout');
希望这有帮助