laravel 4で引数を使用してファサードをモックするにはどうすればよいですか? たとえば、ユーザーコントローラーと「ログイン」メソッドをテストしようとしています。
私のコントローラーメソッド
public function login(){
$this->beforeFilter('guest');
$creds = array(
'email' => Input::get('email'),
'password' => Input::get('password'),
);
if(Auth::attempt($creds, true)){
return "successful";
} else {
return Redirect::to('user/login')->with('error', true);
}
}
動作しないリダイレクト テスト
public function testPostLogin(){
Redirect::shouldReceive('to')->once()->with('error', true);
$response = $this->action('POST', 'UserController@login');
$this->assertRedirectedTo('user/login');
}
次の例外が発生しています。「user/login」パラメーターを Redirect モックに挿入する方法がわかりません
Mockery\Exception\NoMatchingExpectationException : Illuminate\Routing\Redirector::to("user/login") に一致するハンドラが見つかりません