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:
Divarion-D
2026-06-15 18:07:50 +03:00
parent 1548b25aed
commit 0d8607b17b
11 changed files with 2093 additions and 14 deletions
+11 -7
View File
@@ -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';
}
}