siakad-itm/tests/Feature/Admin/Settings/SecurityTest.php
Yoga Pangestu 70d37741ef
Some checks failed
tests / ci (pull_request) Has been cancelled
Refactor admin settings structure and implement profile and security management
- Moved profile and security settings from the general settings route to a dedicated admin settings route.
- Created new components and pages for managing user profile and security settings.
- Updated user menu to link to the new admin settings pages.
- Removed old settings pages and routes that are no longer in use.
- Added tests for profile and security settings functionality.
2026-08-25 17:57:47 +07:00

54 lines
1.6 KiB
PHP

<?php
use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Inertia\Testing\AssertableInertia as Assert;
test('security page is displayed', function () {
$user = User::factory()->create();
$this->actingAs($user)
->get(route('admin.settings.security.edit'))
->assertOk()
->assertInertia(fn (Assert $page) => $page
->component('admin/settings/security')
->has('passwordRules'),
);
});
test('password can be updated', function () {
$user = User::factory()->create();
$response = $this
->actingAs($user)
->from(route('admin.settings.security.edit'))
->put(route('admin.settings.password.update'), [
'current_password' => 'password',
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);
$response
->assertSessionHasNoErrors()
->assertRedirect(route('admin.settings.security.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('admin.settings.security.edit'))
->put(route('admin.settings.password.update'), [
'current_password' => 'wrong-password',
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);
$response
->assertSessionHasErrors('current_password')
->assertRedirect(route('admin.settings.security.edit'));
});