post(route('register.store'), [ 'name' => 'Ada Lovelace', 'email' => 'ada@example.com', 'password' => 'password', 'password_confirmation' => 'password', ]); $user = User::query()->where('email', 'ada@example.com')->firstOrFail(); $response->assertRedirect('/dashboard'); $this->assertAuthenticatedAs($user); $this->assertNull($user->email_verified_at); Notification::assertSentTo($user, VerifyEmail::class); } public function test_an_unverified_user_cannot_open_the_dashboard(): void { $user = User::factory()->unverified()->create(); $this->actingAs($user)->get(route('dashboard')) ->assertRedirect(route('verification.notice')); } public function test_a_verified_user_can_log_in_and_log_out(): void { $user = User::factory()->create(['password' => 'password']); $this->post(route('login.store'), [ 'email' => $user->email, 'password' => 'password', ])->assertRedirect('/dashboard'); $this->assertAuthenticatedAs($user); $this->post(route('logout'))->assertRedirect('/'); $this->assertGuest(); } }