feat: complete jobcard management workflows and UI
This commit is contained in:
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../app/Domain/User/RoleRecord.php';
|
||||
require_once __DIR__ . '/../app/Domain/User/PermissionMatrix.php';
|
||||
require_once __DIR__ . '/../app/Domain/User/RolePermissionService.php';
|
||||
|
||||
use App\Domain\User\PermissionMatrix;
|
||||
use App\Domain\User\RoleRecord;
|
||||
@@ -64,6 +65,23 @@ role_permission_assert_throws(
|
||||
role_permission_assert_same(true, $roles->canRename(['name' => 'Accounts'], 'Support'), 'Custom roles should be renameable.');
|
||||
role_permission_assert_same(false, $roles->canDelete(['name' => 'Administrator']), 'Administrator deletion safeguard should be queryable.');
|
||||
|
||||
// ID 1 is authoritative for the protected role; current name is not required.
|
||||
$adminEdit = (new App\Domain\User\RolePermissionService())->validateEdit(1, [
|
||||
'name' => 'Renamed Administrator', 'description' => 'changed', 'permissions' => ['clients.view'],
|
||||
]);
|
||||
role_permission_assert_same(false, $adminEdit['valid'], 'Role ID 1 must remain protected without current_name.');
|
||||
if (!isset($adminEdit['errors']['role'])) throw new RuntimeException('Administrator rename/permission changes must be rejected from ID alone.');
|
||||
role_permission_assert_same(false, $roles->canDelete(['id' => 1]), 'Role ID 1 must not be deletable without a name.');
|
||||
|
||||
$customCreate = (new App\Domain\User\RolePermissionService())->validateForCreate([
|
||||
'name' => ' Dispatch ', 'description' => ' Handles dispatch ', 'permissions' => ['CLIENTS.VIEW'],
|
||||
], ['clients.view']);
|
||||
role_permission_assert_same(true, $customCreate['valid'], 'Custom role create DTO should validate and normalize permissions.');
|
||||
role_permission_assert_same('Dispatch', $customCreate['name'], 'Custom role names should be normalized in create DTOs.');
|
||||
role_permission_assert_same(['clients.view'], $customCreate['permissions'], 'Create DTO should include canonical permissions.');
|
||||
$customDelete = (new App\Domain\User\RolePermissionService())->validateDelete(4, ['id' => 4, 'name' => 'Dispatch']);
|
||||
role_permission_assert_same(['valid' => true, 'id' => 4, 'errors' => []], $customDelete, 'Custom role delete DTO should be safe and controller-ready.');
|
||||
|
||||
$display = $roles->display([
|
||||
'id' => 4,
|
||||
'name' => 'Support Team',
|
||||
|
||||
Reference in New Issue
Block a user