Move the row formatting that was duplicated between system-audit's data() and export() endpoints into a single presenter. Both endpoints now call presentAll() on the same object, so enum label translation, actor resolution, and timestamp formatting cannot drift between the Grid.js UI and the CSV download. - SystemAuditRowPresenter::present()/presentAll(): canonical row shape with outcome + outcome_label + outcome_badge, channel + channel_label, actor_user_label with display-name-then-email fallback, and safe defaults for every missing field. - data().php shrinks from ~45 to ~15 lines; export().php drops its inline outcome/channel/actor resolvers and reads the already- resolved fields from the presenter output. - AuditContainerRegistrar registers the presenter. - tests/Module/Audit/Service/SystemAuditRowPresenterTest: 9 cases covering enum normalization, unknown-value fallback, actor label precedence (display name → email → "-"), whitespace trimming, safe defaults for missing keys, and iterable input. - StatusTaxonomyContractFiles: the taxonomy data contract now points at the presenter (the single source of truth for badge/label resolution) instead of the thin data endpoint, and the presenter is added to the literal-guard file list. Gates: PHPUnit 1889 OK, PHPStan 0 errors, module:sync ok. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
132 lines
5.8 KiB
PHP
132 lines
5.8 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Tests\Architecture;
|
|
|
|
final class StatusTaxonomyContractFiles
|
|
{
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public static function taxonomyEnumFiles(): array
|
|
{
|
|
return [
|
|
'modules/audit/lib/Module/Audit/Domain/SystemAuditOutcome.php',
|
|
'modules/audit/lib/Module/Audit/Domain/SystemAuditChannel.php',
|
|
'modules/audit/lib/Module/Audit/Domain/UserLifecycleAction.php',
|
|
'modules/audit/lib/Module/Audit/Domain/UserLifecycleTriggerType.php',
|
|
'modules/audit/lib/Module/Audit/Domain/UserLifecycleStatus.php',
|
|
'modules/audit/lib/Module/Audit/Domain/ImportAuditStatus.php',
|
|
'core/Domain/Taxonomy/ScheduledJobStatus.php',
|
|
'core/Domain/Taxonomy/ScheduledJobRunStatus.php',
|
|
'core/Domain/Taxonomy/ScheduledJobTriggerType.php',
|
|
'core/Domain/Taxonomy/MailLogStatus.php',
|
|
'core/Domain/Taxonomy/TenantStatus.php',
|
|
'core/Domain/Taxonomy/SchedulerRuntimeResult.php',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string,list<string>>
|
|
*/
|
|
public static function taxonomySchemaExpectations(): array
|
|
{
|
|
return [
|
|
'modules/audit/pages/audit/system-audit/filter-schema.php' => [
|
|
'SystemAuditOutcome::values()',
|
|
'SystemAuditChannel::values()',
|
|
],
|
|
'modules/audit/pages/audit/user-lifecycle-audit/filter-schema.php' => [
|
|
'gridEnumSanitizer(UserLifecycleAction::class)',
|
|
'gridEnumSanitizer(UserLifecycleStatus::class)',
|
|
'gridEnumSanitizer(UserLifecycleTriggerType::class)',
|
|
],
|
|
'modules/audit/pages/audit/import-audit/filter-schema.php' => [
|
|
'ImportAuditStatus::values()',
|
|
],
|
|
'pages/admin/scheduled-jobs/filter-schema.php' => [
|
|
'ScheduledJobStatus::values()',
|
|
],
|
|
'pages/admin/scheduled-jobs/runs-filter-schema.php' => [
|
|
'ScheduledJobRunStatus::values()',
|
|
'ScheduledJobTriggerType::values()',
|
|
],
|
|
'pages/admin/mail-log/filter-schema.php' => [
|
|
'MailLogStatus::values()',
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public static function taxonomyDataEndpointFiles(): array
|
|
{
|
|
return [
|
|
// System audit: data + export endpoints delegate badge/label resolution
|
|
// to SystemAuditRowPresenter, which is the enforced source of truth.
|
|
'modules/audit/lib/Module/Audit/Service/SystemAuditRowPresenter.php',
|
|
'modules/audit/pages/audit/user-lifecycle-audit/data().php',
|
|
'modules/audit/pages/audit/import-audit/data().php',
|
|
'pages/admin/scheduled-jobs/data().php',
|
|
'pages/admin/scheduled-jobs/runs-data($id).php',
|
|
'pages/admin/mail-log/data().php',
|
|
'pages/admin/tenants/data().php',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public static function taxonomyLiteralGuardFiles(): array
|
|
{
|
|
return [
|
|
'modules/audit/lib/Module/Audit/Service/SystemAuditService.php',
|
|
'modules/audit/lib/Module/Audit/Service/SystemAuditRowPresenter.php',
|
|
'modules/audit/lib/Module/Audit/Repository/SystemAuditLogRepository.php',
|
|
'modules/audit/lib/Module/Audit/Http/ApiSystemAuditReporter.php',
|
|
'modules/audit/lib/Module/Audit/Service/UserLifecycleAuditService.php',
|
|
'modules/audit/lib/Module/Audit/Repository/UserLifecycleAuditRepository.php',
|
|
'modules/audit/lib/Module/Audit/Service/ImportAuditService.php',
|
|
'modules/audit/lib/Module/Audit/Repository/ImportAuditRunRepository.php',
|
|
'core/Service/Scheduler/SchedulerRunService.php',
|
|
'core/Repository/Scheduler/ScheduledJobRepository.php',
|
|
'core/Repository/Scheduler/ScheduledJobRunRepository.php',
|
|
'core/Repository/Scheduler/SchedulerRuntimeRepository.php',
|
|
'core/Service/Mail/MailService.php',
|
|
'core/Repository/Mail/MailLogRepository.php',
|
|
'core/Service/Tenant/TenantService.php',
|
|
'core/Repository/Tenant/TenantRepository.php',
|
|
'core/Repository/Stats/AdminStatsRepository.php',
|
|
'modules/audit/pages/audit/system-audit/data().php',
|
|
'modules/audit/pages/audit/user-lifecycle-audit/data().php',
|
|
'modules/audit/pages/audit/import-audit/data().php',
|
|
'pages/admin/scheduled-jobs/data().php',
|
|
'pages/admin/scheduled-jobs/runs-data($id).php',
|
|
'pages/admin/mail-log/data().php',
|
|
'pages/admin/tenants/data().php',
|
|
'modules/audit/pages/audit/system-audit/index().php',
|
|
'modules/audit/pages/audit/user-lifecycle-audit/index().php',
|
|
'modules/audit/pages/audit/import-audit/index().php',
|
|
'pages/admin/scheduled-jobs/index().php',
|
|
'pages/admin/mail-log/index().php',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public static function forbiddenLiteralPatterns(): array
|
|
{
|
|
return [
|
|
"/\\bstatus\\s*=\\s*'(running|success|partial|failed|skipped|queued|sent|active|inactive)'/",
|
|
"/\\boutcome\\s*=\\s*'(success|failed|denied)'/",
|
|
"/\\bchannel\\s*=\\s*'(web|api|scheduler|cli)'/",
|
|
"/\\btrigger_type\\s*=\\s*'(scheduler|manual|cron|system)'/",
|
|
"/\\baction\\s*=\\s*'(deactivate|delete|restore)'/",
|
|
"/['\\\"]statuses['\\\"]\\s*=>\\s*'failed,skipped'/",
|
|
"/['\\\"]actions['\\\"]\\s*=>\\s*'restore'/",
|
|
"/in_array\\([^\\n]*\\[(?:[^\\]]*'(?:success|failed|denied|running|partial|skipped|queued|sent|active|inactive|scheduler|manual|web|api|cli|deactivate|delete|restore|ok|lock_not_acquired|unexpected_error)')/",
|
|
];
|
|
}
|
|
}
|