skipUnlessFortifyFeature(Features::emailVerification()); } public function test_sends_verification_notification(): void { Notification::fake(); $user = User::factory()->unverified()->create(); $this->actingAs($user) ->post(route('verification.send')) ->assertRedirect(route('home')) ->assertSessionHas('status', 'verification-link-sent'); Notification::assertSentTo($user, VerifyEmail::class); } public function test_does_not_send_verification_notification_if_email_is_verified(): void { Notification::fake(); $user = User::factory()->create(); $this->actingAs($user) ->post(route('verification.send')) ->assertRedirect(route('dashboard', absolute: false)); Notification::assertNothingSent(); } public function test_guests_cannot_request_a_verification_email(): void { Notification::fake(); $this->post(route('verification.send'))->assertRedirect(route('login')); Notification::assertNothingSent(); } public function test_resending_verification_emails_is_throttled(): void { Notification::fake(); $user = User::factory()->unverified()->create(); $this->actingAs($user); for ($attempt = 0; $attempt < 6; $attempt++) { $this->post(route('verification.send'))->assertRedirect(); } $this->post(route('verification.send'))->assertTooManyRequests(); Notification::assertSentToTimes($user, VerifyEmail::class, 6); } }