mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-09-28 04:01:59 +02:00
test: add comprehensive test suite covering all P2–P4 audit phases (242 tests)
New test files: - ModuleLoaderBootTest — 11 tests: boot lifecycle, event subscribers, BaseModule compat - ModuleManagerMigrationsTest — 8 tests: versioned migrations, semver ordering, install/uninstall state - ModuleStateEnumTest — 12 tests: fromRaw(), isLoadable(), ModuleManager integration - ComposerDiscoveryTest — 7 tests: Composer 1/2 format, xcvm-module filter, deduplication, module-path - CronProviderTest — 8 tests: BaseModule default, collectCronEntries aggregation, format validation - ExceptionHierarchyTest — hierarchy correctness, PSR-11 NotFoundException compliance - InterfaceContractTest — 29 reflection tests verifying all documented interface signatures - ListensToAttributeTest — 8 tests: attribute shape, ModuleLoader integration, IS_REPEATABLE, hybrid mode - ArchitectureTest — enforces no global \$db in modules or domain, BaseModule contract Updated ModuleLoaderTest and ModuleLoaderPriorityTest for namespaced class generation and resolveClassName() removal.
This commit is contained in:
@@ -102,7 +102,8 @@ final class ModuleLoaderPriorityTest extends TestCase {
|
||||
$modulePath = $root . '/' . $name;
|
||||
mkdir($modulePath, 0775, true);
|
||||
|
||||
$className = $this->resolveClassName($name);
|
||||
$pascal = implode('', array_map('ucfirst', explode('-', $name)));
|
||||
$className = $pascal . 'Module';
|
||||
|
||||
$manifest = array_merge([
|
||||
'name' => $name,
|
||||
@@ -122,7 +123,15 @@ final class ModuleLoaderPriorityTest extends TestCase {
|
||||
json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
|
||||
);
|
||||
|
||||
$namespace = 'XcVm\\Module\\' . $pascal;
|
||||
|
||||
$php = '<?php' . "\n"
|
||||
. 'namespace ' . $namespace . ';' . "\n"
|
||||
. 'use ModuleInterface;' . "\n"
|
||||
. 'use ServiceContainer;' . "\n"
|
||||
. 'use Router;' . "\n"
|
||||
. 'use CommandRegistry;' . "\n"
|
||||
. 'use NavbarRegistry;' . "\n"
|
||||
. 'class ' . $className . ' implements ModuleInterface {' . "\n"
|
||||
. "\tpublic function getName(): string { return '{$name}'; }" . "\n"
|
||||
. "\tpublic function getVersion(): string { return '1.0.0'; }" . "\n"
|
||||
@@ -132,14 +141,9 @@ final class ModuleLoaderPriorityTest extends TestCase {
|
||||
. "\tpublic function getEventSubscribers(): array { return []; }" . "\n"
|
||||
. "\tpublic function install(): void {}" . "\n"
|
||||
. "\tpublic function uninstall(): void {}" . "\n"
|
||||
. "\tpublic function registerNavbar(): void {}" . "\n"
|
||||
. "\tpublic function registerNavbar(NavbarRegistry \$registry): void {}" . "\n"
|
||||
. '}' . "\n";
|
||||
|
||||
file_put_contents($modulePath . '/' . $className . '.php', $php);
|
||||
}
|
||||
|
||||
private function resolveClassName(string $name): string {
|
||||
$parts = explode('-', $name);
|
||||
return implode('', array_map('ucfirst', $parts)) . 'Module';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user