create(['email_verified_at' => null]); $this->actingAs($user) ->get('email/verify') ->assertOk() ->assertInertia(fn (Assert $page) => $page->component('auth/VerifyEmail')); }); test('already verified user is redirected from notice page', function () { $user = User::factory()->create(['email_verified_at' => Carbon::now()]); $this->actingAs($user) ->get('email/verify') ->assertRedirect('/'); }); test('signed verification link marks email as verified', function () { Event::fake([Verified::class]); $user = User::factory()->create(['email_verified_at' => null]); $signedUrl = URL::temporarySignedRoute( 'verification.verify', Carbon::now()->addMinutes(60), ['id' => $user->id, 'hash' => sha1($user->email)] ); $this->actingAs($user) ->get($signedUrl) ->assertRedirect('/'); $this->assertNotNull($user->fresh()->email_verified_at); Event::assertDispatched(Verified::class); }); test('verification link with invalid signature fails', function () { $user = User::factory()->create(['email_verified_at' => null]); $this->actingAs($user) ->get(route('verification.verify', ['id' => $user->id, 'hash' => sha1($user->email)])) ->assertStatus(403); $this->assertNull($user->fresh()->email_verified_at); }); test('resend verification email', function () { Notification::fake(); $user = User::factory()->create(['email_verified_at' => null]); $this->actingAs($user) ->post('email/resend') ->assertRedirect(); Notification::assertSentTo($user, VerifyEmail::class); }); test('resend does nothing for already verified user', function () { Notification::fake(); $user = User::factory()->create(['email_verified_at' => Carbon::now()]); $this->actingAs($user) ->post('email/resend') ->assertRedirect('/'); Notification::assertNothingSent(); }); test('guest cannot access verification routes', function () { $this->get('email/verify')->assertRedirect('login'); $this->post('email/resend')->assertRedirect('login'); });