1
0
Files
breadcrumb-the-shire/tests/Architecture/AbstractModuleStructureContractTestCase.php

54 lines
1.4 KiB
PHP
Raw Normal View History

2026-03-19 18:30:14 +01:00
<?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,
];
}
}
}