Skip to content

Instantly share code, notes, and snippets.

@jesseschutt
Created January 8, 2015 17:57
Show Gist options
  • Save jesseschutt/d73d078a4c7aab5f1752 to your computer and use it in GitHub Desktop.
Save jesseschutt/d73d078a4c7aab5f1752 to your computer and use it in GitHub Desktop.
public function test()
{
$mock = Mockery::mock('Illuminate\Contracts\Auth\Guard');
app()->instance('Illuminate\Contracts\Auth\Guard', $mock);
$this->call('POST', 'auth\login', ['email' => 'example@gmail.com', 'password' => 'asasdsdfb']);
$mock->shouldReceive('attempt')->once()->andReturn('false');
}
//within the AuthenticatesAndRegistersUsers Trait
public function postLogin(Request $request)
{
$this->validate($request, [
'email' => 'required', 'password' => 'required',
]);
$credentials = $request->only('email', 'password');
if ($this->auth->attempt($credentials, $request->has('remember')))
{
return redirect()->intended($this->redirectPath());
}
return redirect('/auth/login')
->withInput($request->only('email'))
->withErrors([
'email' => 'These credentials do not match our records.',
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment