您好我正在尝试编写 PHPUnit 测试来测试我的登录控制器,并且我的代码似乎在浏览器中运行良好但是当我运行 php 单元测试时出现以下错误
错误:
Call to a member function with() on a non-object
方法:
public function store()
{
$input = Input::only('email', 'password');
$attempt = Auth::attempt($input);
if($attempt){
return Redirect::intended('/')
->with('flash_message', Lang::get('sessions.you_have_logged_in'));
}
}
单元测试:
public function testStore()
{
Auth::shouldReceive('attempt')
->once()
->andReturn(true);
Redirect::shouldReceive('intended')
->once();
$this->call('POST', 'session');
}
在使用嘲笑方面我有点菜鸟,所以我想问题可能在于我如何嘲笑重定向对象?