mirror of https://github.com/kcal-app/kcal.git
Add missing user authentication tests
This commit is contained in:
parent
8788c39d44
commit
3c2c5ce610
|
|
@ -14,32 +14,33 @@ class AuthenticationTest extends TestCase
|
||||||
public function testLoginScreenCanRendered()
|
public function testLoginScreenCanRendered()
|
||||||
{
|
{
|
||||||
$response = $this->get('/login');
|
$response = $this->get('/login');
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUsersCanAuthenticateUsingLoginScreen()
|
public function testUserCanAuthenticateUsingLoginScreen()
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$response = $this->post('/login', [
|
$response = $this->post('/login', [
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'password' => 'password',
|
'password' => 'password',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertAuthenticated();
|
$this->assertAuthenticated();
|
||||||
$response->assertRedirect(RouteServiceProvider::HOME);
|
$response->assertRedirect(RouteServiceProvider::HOME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUsersCannotAuthenticateWithInvalidPassword()
|
public function testUserCannotAuthenticateWithInvalidPassword()
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$this->post('/login', [
|
$this->post('/login', [
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'password' => 'wrong-password',
|
'password' => 'wrong-password',
|
||||||
]);
|
]);
|
||||||
|
$this->assertGuest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUserCanLogout()
|
||||||
|
{
|
||||||
|
$this->followingRedirects()->post('/logout');
|
||||||
$this->assertGuest();
|
$this->assertGuest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue