Skip to content

Instantly share code, notes, and snippets.

@DCzajkowski
Last active May 22, 2018 20:57
Show Gist options
  • Save DCzajkowski/7caa2cee90d883812c7f1c0de6b9da1c to your computer and use it in GitHub Desktop.
Save DCzajkowski/7caa2cee90d883812c7f1c0de6b9da1c to your computer and use it in GitHub Desktop.
<?php
// ...
class LoginTest extends TestCase
{
// ...
public function test_user_cannot_login_with_incorrect_password()
{
$user = factory(User::class)->create([
'password' => bcrypt('i-love-laravel'),
]);
$response = $this->from('/login')->post('/login', [
'email' => $user->email,
'password' => 'invalid-password',
]);
$response->assertRedirect('/login');
$response->assertSessionHasErrors('email');
$this->assertTrue(session()->hasOldInput('email'));
$this->assertFalse(session()->hasOldInput('password'));
$this->assertGuest();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment