]> git.localhorst.tv Git - alttp.git/blob - tests/Feature/Auth/AuthenticationTest.php
add discord auth
[alttp.git] / tests / Feature / Auth / AuthenticationTest.php
1 <?php
2
3 namespace Tests\Feature\Auth;
4
5 use App\Models\User;
6 use App\Providers\RouteServiceProvider;
7 use Illuminate\Foundation\Testing\RefreshDatabase;
8 use Tests\TestCase;
9
10 class AuthenticationTest extends TestCase
11 {
12     use RefreshDatabase;
13
14     public function test_login_screen_can_be_rendered()
15     {
16         $response = $this->get('/login');
17
18         $response->assertStatus(200);
19     }
20
21     public function test_users_can_authenticate_using_the_login_screen()
22     {
23         $user = User::factory()->create();
24
25         $response = $this->post('/login', [
26             'email' => $user->email,
27             'password' => 'password',
28         ]);
29
30         $this->assertAuthenticated();
31         $response->assertRedirect(RouteServiceProvider::HOME);
32     }
33
34     public function test_users_can_not_authenticate_with_invalid_password()
35     {
36         $user = User::factory()->create();
37
38         $this->post('/login', [
39             'email' => $user->email,
40             'password' => 'wrong-password',
41         ]);
42
43         $this->assertGuest();
44     }
45 }