【发布时间】:2019-03-10 09:50:39
【问题描述】:
我正在尝试将响应内容作为字符串从具有流明响应的单元测试中获取:
class MovieQueryTest extends TestCase
{
use DatabaseMigrations;
public function testCanSearch()
{
Movie::create([
'name' => 'Fast & Furious 8',
'alias' => 'Fast and Furious 8',
'year' => 2016
]);
$response = $this->post('/graphql', [
'query' => '{movies(search: "Fast & Furious"){data{name}}}'
]);
$response->getContent(); // Error: Call to undefined method MovieQueryTest::getContent()
$response->getOriginalContent(); // Error: Call to undefined method MovieQueryTest::getOriginalContent()
$response->content; // ErrorException: Undefined property: MovieQueryTest::$content
}
}
但我无法弄清楚如何获取响应内容。
我不想使用 Lumen TestCase->seeJson() 方法。
我只需要获取响应内容。
【问题讨论】:
标签: php api phpunit response lumen