我正在测试Rest。
我想向我的请求传递一个参数。
在我的控制器里,我有:
public function index(Request $request)
{
$abuse = Abuse::where('bombId', $request->input('bombId'))->get();
}关于PhpUnit,我永远无法模拟bombId参数.
这是我的代码:
$data['bombId'] = 25; // I also tried $bombId = 25;
$this->get('api/v1/abuse', $data])
->seeJson(['total' => 11]);
$this->assertResponseStatus(200);编辑:
当我使用:
$this->call('GET','api/v1/abuse', $credentials);Param被传递,但我不能再使用SeeJson方法了:(
知道吗?
发布于 2015-11-19 00:26:55
我从Jeffrey Way:那里找到了答案
$response = $this->call('GET', 'api/v1/abuse', $credentials);
$data = $this->parseJson($response);
$this->assertIsJson($data);
$this->assertEquals(11, $data->total);https://stackoverflow.com/questions/33792753
复制相似问题