|
1 | 1 | <?php
|
| 2 | + |
| 3 | +use App\Models\User; |
| 4 | +use Illuminate\Auth\Notifications\ResetPassword; |
| 5 | +use Illuminate\Support\Facades\Notification; |
| 6 | + |
| 7 | +test('reset password link screen can be rendered', function () { |
| 8 | + visit(route('password.request')) |
| 9 | + ->assertSee('Forgot password') |
| 10 | + ->assertSee('Enter your email to receive a password reset link') |
| 11 | + ->assertNoConsoleLogs() |
| 12 | + ->assertNoJavaScriptErrors(); |
| 13 | +}); |
| 14 | + |
| 15 | +test('test_reset_password_link_can_be_requested', function () { |
| 16 | + Notification::fake(); |
| 17 | + |
| 18 | + $user = User::factory()->create(); |
| 19 | + |
| 20 | + visit(route('password.request')) |
| 21 | + ->fill('email', $user->email) |
| 22 | + ->press('Email password reset link') |
| 23 | + ->assertSee('A reset link will be sent if the account exists.'); |
| 24 | + |
| 25 | + Notification::assertSentTo($user, ResetPassword::class); |
| 26 | +}); |
| 27 | + |
| 28 | + // public function test_reset_password_screen_can_be_rendered() |
| 29 | + // { |
| 30 | + // Notification::fake(); |
| 31 | + |
| 32 | + // $user = User::factory()->create(); |
| 33 | + |
| 34 | + // $this->post(route('password.email'), ['email' => $user->email]); |
| 35 | + |
| 36 | + // Notification::assertSentTo($user, ResetPassword::class, function ($notification) { |
| 37 | + // $response = $this->get(route('password.request', $notification->token)); |
| 38 | + |
| 39 | + // $response->assertStatus(200); |
| 40 | + |
| 41 | + // return true; |
| 42 | + // }); |
| 43 | + // } |
| 44 | + |
| 45 | + // public function test_password_can_be_reset_with_valid_token() |
| 46 | + // { |
| 47 | + // Notification::fake(); |
| 48 | + |
| 49 | + // $user = User::factory()->create(); |
| 50 | + |
| 51 | + // $this->post(route('password.email'), ['email' => $user->email]); |
| 52 | + |
| 53 | + // Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { |
| 54 | + // $response = $this->post(route('password.store'), [ |
| 55 | + // 'token' => $notification->token, |
| 56 | + // 'email' => $user->email, |
| 57 | + // 'password' => 'password', |
| 58 | + // 'password_confirmation' => 'password', |
| 59 | + // ]); |
| 60 | + |
| 61 | + // $response |
| 62 | + // ->assertSessionHasNoErrors() |
| 63 | + // ->assertRedirect(route('login')); |
| 64 | + |
| 65 | + // return true; |
| 66 | + // }); |
| 67 | + // } |
| 68 | + |
| 69 | + // public function test_password_cannot_be_reset_with_invalid_token(): void |
| 70 | + // { |
| 71 | + // $user = User::factory()->create(); |
| 72 | + |
| 73 | + // $response = $this->post(route('password.store'), [ |
| 74 | + // 'token' => 'invalid-token', |
| 75 | + // 'email' => $user->email, |
| 76 | + // 'password' => 'newpassword123', |
| 77 | + // 'password_confirmation' => 'newpassword123', |
| 78 | + // ]); |
| 79 | + |
| 80 | + // $response->assertSessionHasErrors('email'); |
| 81 | + // } |
0 commit comments