get('/login') ->assertOk() ->assertInertia(fn (Assert $page) => $page->component('Auth/Login')); } public function test_guests_are_redirected_to_login(): void { $this->get('/')->assertRedirect('/login'); $this->get('/admin')->assertRedirect('/login'); } public function test_active_users_can_log_in_and_last_login_is_recorded(): void { $user = User::factory()->create(); $this->post('/login', ['email' => $user->email, 'password' => 'password']) ->assertRedirect('/'); $this->assertAuthenticatedAs($user); $this->assertNotNull($user->fresh()->last_login_at); } public function test_email_is_case_insensitive(): void { $user = User::factory()->create(['email' => 'max@example.com']); $this->post('/login', ['email' => 'Max@Example.com', 'password' => 'password']); $this->assertAuthenticatedAs($user); } public function test_wrong_password_is_rejected(): void { $user = User::factory()->create(); $this->post('/login', ['email' => $user->email, 'password' => 'falsch']) ->assertSessionHasErrors('email'); $this->assertGuest(); } public function test_inactive_users_cannot_log_in(): void { $user = User::factory()->inactive()->create(); $this->post('/login', ['email' => $user->email, 'password' => 'password']) ->assertSessionHasErrors('email'); $this->assertGuest(); } public function test_users_without_local_password_cannot_log_in_with_password(): void { $user = User::factory()->create(['password' => null]); $this->post('/login', ['email' => $user->email, 'password' => 'irgendwas']) ->assertSessionHasErrors('email'); $this->assertGuest(); } public function test_users_can_log_out(): void { $this->actingAs(User::factory()->create()) ->post('/logout') ->assertRedirect('/'); $this->assertGuest(); } public function test_there_is_no_self_registration(): void { $this->get('/register')->assertNotFound(); } }