first commit
This commit is contained in:
50
tests/Kernel/ModuleSchemaTest.php
Normal file
50
tests/Kernel/ModuleSchemaTest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Kernel;
|
||||
|
||||
use Netig\Netslim\Kernel\Runtime\Module\ModuleRegistry;
|
||||
use Netig\Netslim\Kernel\Runtime\Module\ProvidesSchemaInterface;
|
||||
use Netig\Netslim\Kernel\Runtime\RuntimePaths;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class ModuleSchemaTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
RuntimePaths::setApplicationRoot(dirname(__DIR__, 2) . '/tests/Fixtures/Application');
|
||||
ModuleRegistry::reset();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
RuntimePaths::resetApplicationRoot();
|
||||
RuntimePaths::resetProjectRoot();
|
||||
ModuleRegistry::reset();
|
||||
}
|
||||
|
||||
public function testFeatureModulesDeclareOwnedMigrationDirectoriesAndTables(): void
|
||||
{
|
||||
$schemaModules = array_values(array_filter(
|
||||
ModuleRegistry::modules(),
|
||||
static fn (object $module): bool => $module instanceof ProvidesSchemaInterface,
|
||||
));
|
||||
|
||||
self::assertCount(6, $schemaModules);
|
||||
|
||||
foreach ($schemaModules as $module) {
|
||||
foreach ($module->migrationDirectories() as $directory) {
|
||||
self::assertDirectoryExists($directory, $module::class . ' should expose an existing migration directory.');
|
||||
self::assertNotSame([], glob(rtrim($directory, '/') . '/*.php') ?: [], $module::class . ' should expose at least one migration file.');
|
||||
}
|
||||
|
||||
self::assertNotSame([], $module->requiredTables(), $module::class . ' should expose owned tables for readiness checks.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testLegacyGlobalMigrationsDirectoryIsNoLongerUsed(): void
|
||||
{
|
||||
self::assertSame([], glob(dirname(__DIR__, 2) . '/database/migrations/*.php') ?: []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user