Split module structure contracts

This commit is contained in:
2026-03-19 18:30:14 +01:00
parent 1e993e470c
commit ee5fdaaff7
8 changed files with 683 additions and 711 deletions

View File

@@ -0,0 +1,53 @@
<?php
namespace MintyPHP\Tests\Architecture;
use MintyPHP\App\Module\ModuleManifest;
use PHPUnit\Framework\TestCase;
abstract class AbstractModuleStructureContractTestCase extends TestCase
{
use ProjectFileAssertionSupport;
/** @var list<array{id: string, path: string, manifest: ModuleManifest, raw: array<string, mixed>}> */
protected static array $modules = [];
public static function setUpBeforeClass(): void
{
$modulesDir = realpath(__DIR__ . '/../../modules');
if ($modulesDir === false || !is_dir($modulesDir)) {
return;
}
$entries = scandir($modulesDir);
if ($entries === false) {
return;
}
self::$modules = [];
foreach ($entries as $entry) {
if ($entry === '.' || $entry === '..' || !is_dir($modulesDir . '/' . $entry)) {
continue;
}
$manifestFile = $modulesDir . '/' . $entry . '/module.php';
if (!is_file($manifestFile)) {
continue;
}
$raw = require $manifestFile;
if (!is_array($raw)) {
continue;
}
$manifest = ModuleManifest::fromArray($raw, $modulesDir . '/' . $entry);
self::$modules[] = [
'id' => $entry,
'path' => $modulesDir . '/' . $entry,
'manifest' => $manifest,
'raw' => $raw,
];
}
}
}