This repository has been archived on 2025-12-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Caramel-CRM-Backup/tests/Feature/Settings/PasswordUpdateTest.php
T

50 lines
1.3 KiB
PHP
Raw Normal View History

2025-10-20 08:57:51 +02:00
<?php
use App\Models\User;
use Illuminate\Support\Facades\Hash;
test('password update page is displayed', function () {
$user = User::factory()->create();
$response = $this
->actingAs($user)
->get(route('password.edit'));
$response->assertStatus(200);
});
test('password can be updated', function () {
$user = User::factory()->create();
$response = $this
->actingAs($user)
->from(route('password.edit'))
->put(route('password.update'), [
'current_password' => 'password',
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);
$response
->assertSessionHasNoErrors()
->assertRedirect(route('password.edit'));
expect(Hash::check('new-password', $user->refresh()->password))->toBeTrue();
});
test('correct password must be provided to update password', function () {
$user = User::factory()->create();
$response = $this
->actingAs($user)
->from(route('password.edit'))
->put(route('password.update'), [
'current_password' => 'wrong-password',
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);
$response
->assertSessionHasErrors('current_password')
->assertRedirect(route('password.edit'));
});