@@ -45,6 +45,8 @@ public function test_email_is_not_verified_with_invalid_hash()
4545 {
4646 $ user = User::factory ()->unverified ()->create ();
4747
48+ Event::fake ();
49+
4850 $ verificationUrl = URL ::temporarySignedRoute (
4951 'verification.verify ' ,
5052 now ()->addMinutes (60 ),
@@ -53,14 +55,15 @@ public function test_email_is_not_verified_with_invalid_hash()
5355
5456 $ this ->actingAs ($ user )->get ($ verificationUrl );
5557
58+ Event::assertNotDispatched (Verified::class);
5659 $ this ->assertFalse ($ user ->fresh ()->hasVerifiedEmail ());
5760 }
5861
5962 public function test_email_is_not_verified_with_invalid_user_id (): void
6063 {
61- $ user = User::factory ()->create ([
62- ' email_verified_at ' => null ,
63- ] );
64+ $ user = User::factory ()->unverified ()-> create ();
65+
66+ Event:: fake ( );
6467
6568 $ verificationUrl = URL ::temporarySignedRoute (
6669 'verification.verify ' ,
@@ -70,25 +73,25 @@ public function test_email_is_not_verified_with_invalid_user_id(): void
7073
7174 $ this ->actingAs ($ user )->get ($ verificationUrl );
7275
76+ Event::assertNotDispatched (Verified::class);
7377 $ this ->assertFalse ($ user ->fresh ()->hasVerifiedEmail ());
7478 }
7579
7680 public function test_verified_user_is_redirected_to_dashboard_from_verification_prompt (): void
7781 {
78- $ user = User::factory ()->create ([
79- ' email_verified_at ' => now (),
80- ] );
82+ $ user = User::factory ()->create ();
83+
84+ Event:: fake ( );
8185
8286 $ response = $ this ->actingAs ($ user )->get (route ('verification.notice ' ));
8387
88+ Event::assertNotDispatched (Verified::class);
8489 $ response ->assertRedirect (route ('dashboard ' , absolute: false ));
8590 }
8691
8792 public function test_already_verified_user_visiting_verification_link_is_redirected_without_firing_event_again (): void
8893 {
89- $ user = User::factory ()->create ([
90- 'email_verified_at ' => now (),
91- ]);
94+ $ user = User::factory ()->create ();
9295
9396 Event::fake ();
9497
@@ -101,7 +104,7 @@ public function test_already_verified_user_visiting_verification_link_is_redirec
101104 $ this ->actingAs ($ user )->get ($ verificationUrl )
102105 ->assertRedirect (route ('dashboard ' , absolute: false ).'?verified=1 ' );
103106
104- $ this ->assertTrue ($ user ->fresh ()->hasVerifiedEmail ());
105107 Event::assertNotDispatched (Verified::class);
108+ $ this ->assertTrue ($ user ->fresh ()->hasVerifiedEmail ());
106109 }
107110}
0 commit comments