File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 7
7
use Illuminate \Foundation \Testing \RefreshDatabase ;
8
8
use Illuminate \Support \Facades \Event ;
9
9
use Illuminate \Support \Facades \URL ;
10
+ use Livewire \Livewire ;
11
+ use Livewire \Volt \Volt ;
10
12
use Tests \TestCase ;
11
13
12
14
class EmailVerificationTest extends TestCase
@@ -56,4 +58,25 @@ public function test_email_is_not_verified_with_invalid_hash(): void
56
58
57
59
$ this ->assertFalse ($ user ->fresh ()->hasVerifiedEmail ());
58
60
}
61
+
62
+ public function test_already_verified_user_visiting_verification_link_is_redirected_without_firing_event_again (): void
63
+ {
64
+ $ user = User::factory ()->create ([
65
+ 'email_verified_at ' => now (),
66
+ ]);
67
+
68
+ Event::fake ();
69
+
70
+ $ verificationUrl = URL ::temporarySignedRoute (
71
+ 'verification.verify ' ,
72
+ now ()->addMinutes (60 ),
73
+ ['id ' => $ user ->id , 'hash ' => sha1 ($ user ->email )]
74
+ );
75
+
76
+ $ this ->actingAs ($ user )->get ($ verificationUrl )
77
+ ->assertRedirect (route ('dashboard ' , absolute: false ).'?verified=1 ' );
78
+
79
+ $ this ->assertTrue ($ user ->fresh ()->hasVerifiedEmail ());
80
+ Event::assertNotDispatched (Verified::class);
81
+ }
59
82
}
You can’t perform that action at this time.
0 commit comments