skipUnlessFortifyFeature(Features::resetPasswords()); } public function test_reset_password_link_screen_can_be_rendered(): void { $response = $this->get(route('password.request')); $response ->assertOk() ->assertInertia(fn (Assert $page) => $page ->component('auth/ForgotPassword') ->where('status', null), ); } public function test_reset_password_link_can_be_requested() { Notification::fake(); $user = User::factory()->create(); $this->post(route('password.email'), ['email' => $user->email]); Notification::assertSentTo($user, ResetPassword::class); } public function test_reset_password_screen_can_be_rendered(): void { Notification::fake(); $user = User::factory()->create(); $this->post(route('password.email'), ['email' => $user->email]); Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { $response = $this->get(route('password.reset', [ 'token' => $notification->token, 'email' => $user->email, ])); $response ->assertOk() ->assertInertia(fn (Assert $page) => $page ->component('auth/ResetPassword') ->where('email', $user->email) ->where('token', $notification->token), ); return true; }); } public function test_password_can_be_reset_with_valid_token() { Notification::fake(); $user = User::factory()->create(); $this->post(route('password.email'), ['email' => $user->email]); Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { $response = $this->post(route('password.update'), [ 'token' => $notification->token, 'email' => $user->email, 'password' => 'password', 'password_confirmation' => 'password', ]); $response ->assertSessionHasNoErrors() ->assertRedirect(route('login')); return true; }); } public function test_password_cannot_be_reset_with_invalid_token(): void { $user = User::factory()->create(); $response = $this->post(route('password.update'), [ 'token' => 'invalid-token', 'email' => $user->email, 'password' => 'newpassword123', 'password_confirmation' => 'newpassword123', ]); $response->assertSessionHasErrors('email'); } }