Skip to content

Commit 561472a

Browse files
committed
test: already verified user visiting verification link
1 parent cfcb688 commit 561472a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/Feature/Auth/EmailVerificationTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Illuminate\Foundation\Testing\RefreshDatabase;
88
use Illuminate\Support\Facades\Event;
99
use Illuminate\Support\Facades\URL;
10+
use Livewire\Livewire;
11+
use Livewire\Volt\Volt;
1012
use Tests\TestCase;
1113

1214
class EmailVerificationTest extends TestCase
@@ -56,4 +58,25 @@ public function test_email_is_not_verified_with_invalid_hash(): void
5658

5759
$this->assertFalse($user->fresh()->hasVerifiedEmail());
5860
}
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+
}
5982
}

0 commit comments

Comments
 (0)