@@ -45,6 +45,8 @@ public function test_email_is_not_verified_with_invalid_hash()
45
45
{
46
46
$ user = User::factory ()->unverified ()->create ();
47
47
48
+ Event::fake ();
49
+
48
50
$ verificationUrl = URL ::temporarySignedRoute (
49
51
'verification.verify ' ,
50
52
now ()->addMinutes (60 ),
@@ -53,14 +55,15 @@ public function test_email_is_not_verified_with_invalid_hash()
53
55
54
56
$ this ->actingAs ($ user )->get ($ verificationUrl );
55
57
58
+ Event::assertNotDispatched (Verified::class);
56
59
$ this ->assertFalse ($ user ->fresh ()->hasVerifiedEmail ());
57
60
}
58
61
59
62
public function test_email_is_not_verified_with_invalid_user_id (): void
60
63
{
61
- $ user = User::factory ()->create ([
62
- ' email_verified_at ' => null ,
63
- ] );
64
+ $ user = User::factory ()->unverified ()-> create ();
65
+
66
+ Event:: fake ( );
64
67
65
68
$ verificationUrl = URL ::temporarySignedRoute (
66
69
'verification.verify ' ,
@@ -70,25 +73,25 @@ public function test_email_is_not_verified_with_invalid_user_id(): void
70
73
71
74
$ this ->actingAs ($ user )->get ($ verificationUrl );
72
75
76
+ Event::assertNotDispatched (Verified::class);
73
77
$ this ->assertFalse ($ user ->fresh ()->hasVerifiedEmail ());
74
78
}
75
79
76
80
public function test_verified_user_is_redirected_to_dashboard_from_verification_prompt (): void
77
81
{
78
- $ user = User::factory ()->create ([
79
- ' email_verified_at ' => now (),
80
- ] );
82
+ $ user = User::factory ()->create ();
83
+
84
+ Event:: fake ( );
81
85
82
86
$ response = $ this ->actingAs ($ user )->get (route ('verification.notice ' ));
83
87
88
+ Event::assertNotDispatched (Verified::class);
84
89
$ response ->assertRedirect (route ('dashboard ' , absolute: false ));
85
90
}
86
91
87
92
public function test_already_verified_user_visiting_verification_link_is_redirected_without_firing_event_again (): void
88
93
{
89
- $ user = User::factory ()->create ([
90
- 'email_verified_at ' => now (),
91
- ]);
94
+ $ user = User::factory ()->create ();
92
95
93
96
Event::fake ();
94
97
@@ -101,7 +104,7 @@ public function test_already_verified_user_visiting_verification_link_is_redirec
101
104
$ this ->actingAs ($ user )->get ($ verificationUrl )
102
105
->assertRedirect (route ('dashboard ' , absolute: false ).'?verified=1 ' );
103
106
104
- $ this ->assertTrue ($ user ->fresh ()->hasVerifiedEmail ());
105
107
Event::assertNotDispatched (Verified::class);
108
+ $ this ->assertTrue ($ user ->fresh ()->hasVerifiedEmail ());
106
109
}
107
110
}
0 commit comments