Mercurial > packages > auth
comparison stubs/default/pest-tests/Feature/Auth/PasswordUpdateTest.php @ 0:90e38de8f2ba
Initial Commit
| author | luka |
|---|---|
| date | Wed, 13 Aug 2025 22:17:20 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:90e38de8f2ba |
|---|---|
| 1 <?php | |
| 2 | |
| 3 use App\Models\User; | |
| 4 use Illuminate\Support\Facades\Hash; | |
| 5 | |
| 6 test('password can be updated', function () { | |
| 7 $user = User::factory()->create(); | |
| 8 | |
| 9 $response = $this | |
| 10 ->actingAs($user) | |
| 11 ->from('/profile') | |
| 12 ->put('/password', [ | |
| 13 'current_password' => 'password', | |
| 14 'password' => 'new-password', | |
| 15 'password_confirmation' => 'new-password', | |
| 16 ]); | |
| 17 | |
| 18 $response | |
| 19 ->assertSessionHasNoErrors() | |
| 20 ->assertRedirect('/profile'); | |
| 21 | |
| 22 $this->assertTrue(Hash::check('new-password', $user->refresh()->password)); | |
| 23 }); | |
| 24 | |
| 25 test('correct password must be provided to update password', function () { | |
| 26 $user = User::factory()->create(); | |
| 27 | |
| 28 $response = $this | |
| 29 ->actingAs($user) | |
| 30 ->from('/profile') | |
| 31 ->put('/password', [ | |
| 32 'current_password' => 'wrong-password', | |
| 33 'password' => 'new-password', | |
| 34 'password_confirmation' => 'new-password', | |
| 35 ]); | |
| 36 | |
| 37 $response | |
| 38 ->assertSessionHasErrorsIn('updatePassword', 'current_password') | |
| 39 ->assertRedirect('/profile'); | |
| 40 }); |
