@@ -55,4 +55,53 @@ public function test_email_is_not_verified_with_invalid_hash()
5555
5656 $ this ->assertFalse ($ user ->fresh ()->hasVerifiedEmail ());
5757 }
58+
59+ public function test_email_is_not_verified_with_invalid_user_id (): void
60+ {
61+ $ user = User::factory ()->create ([
62+ 'email_verified_at ' => null ,
63+ ]);
64+
65+ $ verificationUrl = URL ::temporarySignedRoute (
66+ 'verification.verify ' ,
67+ now ()->addMinutes (60 ),
68+ ['id ' => 123 , 'hash ' => sha1 ($ user ->email )]
69+ );
70+
71+ $ this ->actingAs ($ user )->get ($ verificationUrl );
72+
73+ $ this ->assertFalse ($ user ->fresh ()->hasVerifiedEmail ());
74+ }
75+
76+ public function test_verified_user_is_redirected_to_dashboard_from_verification_prompt (): void
77+ {
78+ $ user = User::factory ()->create ([
79+ 'email_verified_at ' => now (),
80+ ]);
81+
82+ $ response = $ this ->actingAs ($ user )->get ('/verify-email ' );
83+
84+ $ response ->assertRedirect (route ('dashboard ' , absolute: false ));
85+ }
86+
87+ public function test_already_verified_user_visiting_verification_link_is_redirected_without_firing_event_again (): void
88+ {
89+ $ user = User::factory ()->create ([
90+ 'email_verified_at ' => now (),
91+ ]);
92+
93+ Event::fake ();
94+
95+ $ verificationUrl = URL ::temporarySignedRoute (
96+ 'verification.verify ' ,
97+ now ()->addMinutes (60 ),
98+ ['id ' => $ user ->id , 'hash ' => sha1 ($ user ->email )]
99+ );
100+
101+ $ this ->actingAs ($ user )->get ($ verificationUrl )
102+ ->assertRedirect (route ('dashboard ' , absolute: false ).'?verified=1 ' );
103+
104+ $ this ->assertTrue ($ user ->fresh ()->hasVerifiedEmail ());
105+ Event::assertNotDispatched (Verified::class);
106+ }
58107}
0 commit comments