VerificationNotificationTest.php 833 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. use App\Models\User;
  3. use Illuminate\Auth\Notifications\VerifyEmail;
  4. use Illuminate\Support\Facades\Notification;
  5. test('sends verification notification', function () {
  6. Notification::fake();
  7. $user = User::factory()->create([
  8. 'email_verified_at' => null,
  9. ]);
  10. $this->actingAs($user)
  11. ->post(route('verification.send'))
  12. ->assertRedirect(route('home'));
  13. Notification::assertSentTo($user, VerifyEmail::class);
  14. });
  15. test('does not send verification notification if email is verified', function () {
  16. Notification::fake();
  17. $user = User::factory()->create([
  18. 'email_verified_at' => now(),
  19. ]);
  20. $this->actingAs($user)
  21. ->post(route('verification.send'))
  22. ->assertRedirect(route('dashboard', absolute: false));
  23. Notification::assertNothingSent();
  24. });