- 新增后台 RBAC 相关文档,提供权限目录与维护命令说明。 - 移除不必要的角色资源同步检查,简化权限审计命令。 - 更新权限描述与同步逻辑,确保一致性与可维护性。 - 统一权限注册表,替换过时的权限别名,增强代码可读性。
33 lines
985 B
PHP
33 lines
985 B
PHP
<?php
|
|
|
|
use App\Support\AdminPermissionBridge;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
test('normalizeCanonicalLegacySlugs maps deprecated audit and report slugs', function (): void {
|
|
$normalized = AdminPermissionBridge::normalizeCanonicalLegacySlugs([
|
|
'prd.audit.finance',
|
|
'prd.report.player',
|
|
'prd.users.manage',
|
|
]);
|
|
|
|
expect($normalized)->toBe([
|
|
'prd.audit.view',
|
|
'prd.report.view',
|
|
'prd.users.manage',
|
|
]);
|
|
});
|
|
|
|
test('legacy permission slugs are derived from role menu actions only', function (): void {
|
|
$role = \App\Models\AdminRole::query()->create([
|
|
'slug' => 'derived_only',
|
|
'name' => 'Derived',
|
|
]);
|
|
|
|
$role->syncLegacyPermissionSlugs(['prd.report.view']);
|
|
|
|
expect($role->fresh()->legacyPermissionSlugs())->toBe(['prd.report.view']);
|
|
expect(\Illuminate\Support\Facades\Schema::hasTable('admin_role_legacy_permissions'))->toBeFalse();
|
|
});
|