Mercurial > packages > auth
diff stubs/default/pest-tests/Feature/Auth/AuthenticationTest.php @ 0:90e38de8f2ba
Initial Commit
| author | luka |
|---|---|
| date | Wed, 13 Aug 2025 22:17:20 -0400 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stubs/default/pest-tests/Feature/Auth/AuthenticationTest.php Wed Aug 13 22:17:20 2025 -0400 @@ -0,0 +1,41 @@ +<?php + +use App\Models\User; + +test('login screen can be rendered', function () { + $response = $this->get('/login'); + + $response->assertStatus(200); +}); + +test('users can authenticate using the login screen', function () { + $user = User::factory()->create(); + + $response = $this->post('/login', [ + 'email' => $user->email, + 'password' => 'password', + ]); + + $this->assertAuthenticated(); + $response->assertRedirect(route('dashboard', absolute: false)); +}); + +test('users can not authenticate with invalid password', function () { + $user = User::factory()->create(); + + $this->post('/login', [ + 'email' => $user->email, + 'password' => 'wrong-password', + ]); + + $this->assertGuest(); +}); + +test('users can logout', function () { + $user = User::factory()->create(); + + $response = $this->actingAs($user)->post('/logout'); + + $this->assertGuest(); + $response->assertRedirect('/'); +});
