问题描述
我有一个使用Botman的Laravel 8应用程序。当我从Postman呼叫端点时,我得到具有正确标题的正确内容。但是,当我在测试期间调用端点时,我得到的内容为空,因此测试无法通过。响应由HttpFoundation JsonResponse处理。奇怪的是,内容打印在测试控制台中(即使我不转储),但是$ response-> dump()返回Null。
我的测试方法
/** @test */
public function user_can_talk_to_coach()
{
Passport::actingAs($this->learner,$this->learnerScopes);
$response = $this->postJson(
'learner/v1/coach',[
'driver' => 'mobile','userId' => 1,'message' => null,'intent' => 'intent_testing',],$this->headers
);
var_dump('dump');
$response->dump();
var_dump('headers');
$response->dumpHeaders();
$response->assertStatus(200)
->assertJson([
'data' => [
[
'type' => 'text','text' => 'Hey','attachment' => null,'additionalParameters' => [
'node'=> 'testing',]);
}
消息发送方法
/**
* Send out message response.
*/
public function messagesHandled()
{
$messages = $this->buildReply($this->replies);
// Reset replies
$this->replies = [];
$response = new JsonResponse();
$response->setData(['data' => $messages]);
$response->send();
}
对这里发生的事情有任何想法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)