get(route('password.request')); $response->assertOk(); } public function test_reset_password_link_can_be_requested(): void { Notification::fake(); $user = User::factory()->create(); $this->post(route('password.request'), ['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.request'), ['email' => $user->email]); Notification::assertSentTo($user, ResetPassword::class, function ($notification) { $response = $this->get(route('password.reset', $notification->token)); $response->assertOk(); return true; }); } public function test_password_can_be_reset_with_valid_token(): void { Notification::fake(); $user = User::factory()->create(); $this->post(route('password.request'), ['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', absolute: false)); return true; }); } }