3 namespace Tests\Feature\Auth;
6 use Illuminate\Auth\Notifications\ResetPassword;
7 use Illuminate\Foundation\Testing\RefreshDatabase;
8 use Illuminate\Support\Facades\Notification;
11 class PasswordResetTest extends TestCase
15 public function test_reset_password_link_screen_can_be_rendered()
17 $response = $this->get('/forgot-password');
19 $response->assertStatus(200);
22 public function test_reset_password_link_can_be_requested()
26 $user = User::factory()->create();
28 $this->post('/forgot-password', ['email' => $user->email]);
30 Notification::assertSentTo($user, ResetPassword::class);
33 public function test_reset_password_screen_can_be_rendered()
37 $user = User::factory()->create();
39 $this->post('/forgot-password', ['email' => $user->email]);
41 Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
42 $response = $this->get('/reset-password/'.$notification->token);
44 $response->assertStatus(200);
50 public function test_password_can_be_reset_with_valid_token()
54 $user = User::factory()->create();
56 $this->post('/forgot-password', ['email' => $user->email]);
58 Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
59 $response = $this->post('/reset-password', [
60 'token' => $notification->token,
61 'email' => $user->email,
62 'password' => 'password',
63 'password_confirmation' => 'password',
66 $response->assertSessionHasNoErrors();