这就是我在测试用例中得到响应的方式
$response = $this->call('POST','/api/auth/login',['username'=>'xx','password'=>'xxx'], [/* cookies */], [/* files */], ['HTTP_ClientSecret' => 'xxxx']);
然后我们可以这样获取响应内容
$response->getContents()
我想知道如何获取响应头数据?
最佳答案
做类似的事情:
$response->headers->get('content-type');
或者任何你需要的。如果您想查看响应 header 中的内容,dd($response->headers);
也可能对您有用。
$this->call()
返回 Response这是扩展 Symfony 的 Response并且 headers
是一个对象 ResponseHeaderBag
,它具有 following methods .
关于php - 如何在 laravel 测试中获取 header 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38095289/