Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PasswordUpdateTest.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use App\Models\User;
  3. use Illuminate\Support\Facades\Hash;
  4. test('password can be updated', function () {
  5. $user = User::factory()->create();
  6. $response = $this
  7. ->actingAs($user)
  8. ->from('/profile')
  9. ->put('/password', [
  10. 'current_password' => 'password',
  11. 'password' => 'new-password',
  12. 'password_confirmation' => 'new-password',
  13. ]);
  14. $response
  15. ->assertSessionHasNoErrors()
  16. ->assertRedirect('/profile');
  17. $this->assertTrue(Hash::check('new-password', $user->refresh()->password));
  18. });
  19. test('correct password must be provided to update password', function () {
  20. $user = User::factory()->create();
  21. $response = $this
  22. ->actingAs($user)
  23. ->from('/profile')
  24. ->put('/password', [
  25. 'current_password' => 'wrong-password',
  26. 'password' => 'new-password',
  27. 'password_confirmation' => 'new-password',
  28. ]);
  29. $response
  30. ->assertSessionHasErrorsIn('updatePassword', 'current_password')
  31. ->assertRedirect('/profile');
  32. });