82 lines
1.6 KiB
PHP
82 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Unit\Shared\Module;
|
|
|
|
use App\Shared\Domain\Module\ModuleInterface;
|
|
use App\Shared\Domain\Module\ModuleRegistry;
|
|
use PHPUnit\Framework\TestCase;
|
|
use stdClass;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
final class ModuleRegistryTest extends TestCase
|
|
{
|
|
public function testIdsExtractsDeclaredModuleIds(): void
|
|
{
|
|
$classes = [FakeAlphaModule::class, FakeBetaModule::class];
|
|
|
|
self::assertSame(['alpha', 'beta'], ModuleRegistry::ids($classes));
|
|
}
|
|
|
|
public function testIdsIgnoresClassesNotImplementingModuleInterface(): void
|
|
{
|
|
$classes = [FakeAlphaModule::class, stdClass::class];
|
|
|
|
self::assertSame(['alpha'], ModuleRegistry::ids($classes));
|
|
}
|
|
|
|
public function testIdsReturnsEmptyArrayForNoModules(): void
|
|
{
|
|
self::assertSame([], ModuleRegistry::ids([]));
|
|
}
|
|
}
|
|
|
|
final class FakeAlphaModule implements ModuleInterface
|
|
{
|
|
public static function id(): string
|
|
{
|
|
return 'alpha';
|
|
}
|
|
|
|
public static function label(): string
|
|
{
|
|
return 'Alpha';
|
|
}
|
|
|
|
public static function isRequired(): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public static function permissions(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|
|
|
|
final class FakeBetaModule implements ModuleInterface
|
|
{
|
|
public static function id(): string
|
|
{
|
|
return 'beta';
|
|
}
|
|
|
|
public static function label(): string
|
|
{
|
|
return 'Beta';
|
|
}
|
|
|
|
public static function isRequired(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public static function permissions(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|