- Event-driven architecture with lazy module loading - ModuleScanner, ModuleRegistry, LazyModuleListener for module discovery - 7 lifecycle events: Web, Admin, API, Client, Console, MCP, FrameworkBooted - AdminMenuProvider and ServiceDefinition contracts - Artisan commands: make:mod, make:website, make:plug - Module stubs for rapid scaffolding - Comprehensive test suite with Orchestra Testbench - GitHub Actions CI for PHP 8.2-8.4 / Laravel 11-12 - EUPL-1.2 license Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
72 lines
1.9 KiB
PHP
72 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Tests\Feature;
|
|
|
|
use Core\Module\ModuleRegistry;
|
|
use Core\Module\ModuleScanner;
|
|
use Core\Tests\TestCase;
|
|
|
|
class ModuleRegistryTest extends TestCase
|
|
{
|
|
public function test_registry_starts_unregistered(): void
|
|
{
|
|
$registry = new ModuleRegistry(new ModuleScanner);
|
|
|
|
$this->assertFalse($registry->isRegistered());
|
|
}
|
|
|
|
public function test_registry_marks_as_registered_after_register(): void
|
|
{
|
|
$registry = new ModuleRegistry(new ModuleScanner);
|
|
|
|
$registry->register([]);
|
|
|
|
$this->assertTrue($registry->isRegistered());
|
|
}
|
|
|
|
public function test_registry_only_registers_once(): void
|
|
{
|
|
$registry = new ModuleRegistry(new ModuleScanner);
|
|
|
|
$registry->register([]);
|
|
$registry->register([$this->getFixturePath('Mod')]);
|
|
|
|
// Should still be empty since it only registers once
|
|
$this->assertEmpty($registry->getMappings());
|
|
}
|
|
|
|
public function test_get_mappings_returns_array(): void
|
|
{
|
|
$registry = new ModuleRegistry(new ModuleScanner);
|
|
|
|
$this->assertIsArray($registry->getMappings());
|
|
}
|
|
|
|
public function test_get_listeners_for_returns_empty_for_unknown_event(): void
|
|
{
|
|
$registry = new ModuleRegistry(new ModuleScanner);
|
|
|
|
$result = $registry->getListenersFor('Unknown\\Event');
|
|
|
|
$this->assertIsArray($result);
|
|
$this->assertEmpty($result);
|
|
}
|
|
|
|
public function test_get_events_returns_array(): void
|
|
{
|
|
$registry = new ModuleRegistry(new ModuleScanner);
|
|
$registry->register([]);
|
|
|
|
$this->assertIsArray($registry->getEvents());
|
|
}
|
|
|
|
public function test_get_modules_returns_array(): void
|
|
{
|
|
$registry = new ModuleRegistry(new ModuleScanner);
|
|
$registry->register([]);
|
|
|
|
$this->assertIsArray($registry->getModules());
|
|
}
|
|
}
|