【发布时间】:2016-10-19 22:12:03
【问题描述】:
我正在尝试以最简单的方式测试 store 方法。我不一定需要嘲弄,我可以实际添加到数据库中。无论如何,我无法让 Mockery 工作。
现在我有了这个:
public function testStore()
{
$data = ['name' => 'TestClub', 'code' => 'TCL'];
Input::replace($data);
$this->route('POST', 'clubs.store', $Input::all());
$this->assertResponseOk();
}
这是我的控制器方法:
public function store() {
$validator = Validator::make($data = Input::all(), Club::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
Club::create($data);
return redirect(Session::get('backUrl'));
}
我得到一个返回码 500,我不知道为什么。我能以某种方式看到它发送的请求吗?
我正在使用 Laravel 5.0
【问题讨论】:
-
您可以在测试中使用
$this->dump()打印出有关请求/响应的数据。
标签: php laravel testing phpunit