Php laravel从路由返回了无效的JSON。可能引发了异常?
这是我对存储功能的测试Php laravel从路由返回了无效的JSON。可能引发了异常?,php,json,unit-testing,testing,laravel-5.1,Php,Json,Unit Testing,Testing,Laravel 5.1,这是我对存储功能的测试 /** @test */ public function storeTest() { $this->be($this->user); $response = $this->json('POST', '/client/ocp/profile/247/route-', [ 'name' => 'Test store', 'speed' => 4.5, 'crea
/** @test */
public function storeTest()
{
$this->be($this->user);
$response = $this->json('POST', '/client/ocp/profile/247/route-', [
'name' => 'Test store',
'speed' => 4.5,
'created_by' => $this->user->id,
'client_id' => '262',
]);
$response
->seeStatusCode(302)
->seeJson(['status' => 'OK']);
}
当我运行它时,我得到了这个错误
Invalid JSON was returned from the route. Perhaps an exception was thrown?
我尝试添加此标题以解决问题['X-request-With'=>'XMLHttpRequest'] 但这并不能解决问题
我如何解决这个问题?你在构建无效的json你是什么意思?你能展示一下实际返回json的
Route
或controller方法吗?这是控制器,这是Route | | POST | client/{clientAlias}/page/{pageId}/routData client。{clientAlias}.profile.{pageId}.routData.store | App\Http\Controllers\RouteDataController@store | |