|
0
|
1 <?php
|
|
|
2
|
|
|
3 use App\Models\User;
|
|
|
4
|
|
|
5 test('login screen can be rendered', function () {
|
|
|
6 $response = $this->get('/login');
|
|
|
7
|
|
|
8 $response->assertStatus(200);
|
|
|
9 });
|
|
|
10
|
|
|
11 test('users can authenticate using the login screen', function () {
|
|
|
12 $user = User::factory()->create();
|
|
|
13
|
|
|
14 $response = $this->post('/login', [
|
|
|
15 'email' => $user->email,
|
|
|
16 'password' => 'password',
|
|
|
17 ]);
|
|
|
18
|
|
|
19 $this->assertAuthenticated();
|
|
|
20 $response->assertRedirect(route('dashboard', absolute: false));
|
|
|
21 });
|
|
|
22
|
|
|
23 test('users can not authenticate with invalid password', function () {
|
|
|
24 $user = User::factory()->create();
|
|
|
25
|
|
|
26 $this->post('/login', [
|
|
|
27 'email' => $user->email,
|
|
|
28 'password' => 'wrong-password',
|
|
|
29 ]);
|
|
|
30
|
|
|
31 $this->assertGuest();
|
|
|
32 });
|
|
|
33
|
|
|
34 test('users can logout', function () {
|
|
|
35 $user = User::factory()->create();
|
|
|
36
|
|
|
37 $response = $this->actingAs($user)->post('/logout');
|
|
|
38
|
|
|
39 $this->assertGuest();
|
|
|
40 $response->assertRedirect('/');
|
|
|
41 });
|