feat: extend module platform with UI slots, runtime components, CLI tooling and {{userId}} search support

Completes the generic module platform that enables modules to contribute
UI elements, runtime JS components, and search resources without any
core hardcoding.

New generic UI slot types:
- topbar.right_item: module-contributed topbar buttons
- layout.body_end_template: module-contributed dialog/overlay templates
- layout.head_style: module-contributed global CSS
- runtime.component: declarative JS component registration with phase ordering

New infrastructure:
- ModuleAutoloader: PSR-4 autoloading for module-local PHP classes
- ModuleRuntimePageBuilder: symlinks module pages into runtime directory
- ModuleRuntimeAssetPublisher: publishes module CSS/JS to web/modules/
- ModulePermissionSynchronizer: syncs module permissions to DB
- CLI scripts: module-runtime-sync, module-build, module-migrate,
  module-permissions-sync, module-assets-sync
- {{userId}} placeholder in SearchDataService for user-scoped search queries
- Component runtime with phased initialization (early/default/late)
- AppContainer.protectExistingBindings() to prevent module→core overwrites
- Architecture tests: ModuleStructureContractTest, CoreTemplateIsolationTest,
  FrontendComponentRuntimeContractTest, AppContainerIsolationContractTest

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-18 22:19:56 +01:00
parent c364e2b46d
commit c7b8fd516a
139 changed files with 7591 additions and 2535 deletions

View File

@@ -11,6 +11,97 @@ use PHPUnit\Framework\TestCase;
class ScheduledJobServiceTest extends TestCase
{
public function testEnsureSystemJobsCreatesModuleJobDefinition(): void
{
$jobRepository = $this->createMock(ScheduledJobRepository::class);
$runRepository = $this->createMock(ScheduledJobRunRepository::class);
$registry = $this->createMock(ScheduledJobRegistry::class);
$calculator = new ScheduleCalculator();
$registry->expects($this->once())->method('definitions')->willReturn([
'addressbook.sync' => [
'label' => 'Addressbook Sync',
'description' => 'Syncs address book data',
'default_enabled' => 1,
'default_timezone' => 'UTC',
'default_schedule_type' => 'daily',
'default_schedule_interval' => 1,
'default_schedule_time' => '03:00',
'default_schedule_weekdays_csv' => null,
'default_catchup_once' => 1,
'allowed_schedule_types' => ['hourly', 'daily', 'weekly'],
],
]);
$jobRepository->expects($this->once())
->method('findByKey')
->with('addressbook.sync')
->willReturn(null);
$jobRepository->expects($this->once())
->method('create')
->with($this->callback(static function (array $job): bool {
return ($job['job_key'] ?? null) === 'addressbook.sync'
&& ($job['label'] ?? null) === 'Addressbook Sync'
&& ($job['timezone'] ?? null) === 'UTC'
&& ($job['schedule_type'] ?? null) === 'daily';
}))
->willReturn(99);
$jobRepository->expects($this->never())->method('updateJobMeta');
$service = new ScheduledJobService($jobRepository, $runRepository, $registry, $calculator);
$service->ensureSystemJobs();
}
public function testEnsureSystemJobsUpdatesExistingModuleJobMetadata(): void
{
$jobRepository = $this->createMock(ScheduledJobRepository::class);
$runRepository = $this->createMock(ScheduledJobRunRepository::class);
$registry = $this->createMock(ScheduledJobRegistry::class);
$calculator = new ScheduleCalculator();
$registry->expects($this->once())->method('definitions')->willReturn([
'addressbook.sync' => [
'label' => 'Addressbook Sync',
'description' => 'Syncs address book data',
'default_enabled' => 1,
'default_timezone' => 'UTC',
'default_schedule_type' => 'daily',
'default_schedule_interval' => 1,
'default_schedule_time' => '03:00',
'default_schedule_weekdays_csv' => null,
'default_catchup_once' => 1,
'allowed_schedule_types' => ['hourly', 'daily', 'weekly'],
],
]);
$jobRepository->expects($this->once())
->method('findByKey')
->with('addressbook.sync')
->willReturn([
'id' => 12,
'job_key' => 'addressbook.sync',
'label' => 'Old Label',
'description' => 'Old description',
'enabled' => 1,
'timezone' => 'UTC',
'schedule_type' => 'daily',
'schedule_interval' => 1,
'schedule_time' => '03:00',
'schedule_weekdays_csv' => null,
'catchup_once' => 1,
'next_run_at' => '2026-01-01 03:00:00',
]);
$jobRepository->expects($this->once())
->method('updateJobMeta')
->with(12, $this->callback(static function (array $job): bool {
return ($job['label'] ?? null) === 'Addressbook Sync'
&& ($job['description'] ?? null) === 'Syncs address book data';
}))
->willReturn(true);
$jobRepository->expects($this->never())->method('create');
$service = new ScheduledJobService($jobRepository, $runRepository, $registry, $calculator);
$service->ensureSystemJobs();
}
public function testUpdateFromAdminReturnsValidationErrorForWeeklyWithoutWeekdays(): void
{
$jobRepository = $this->createMock(ScheduledJobRepository::class);