Refactor core test runtime and simplify project documentation

This commit is contained in:
julien
2026-03-20 22:52:02 +01:00
parent 9b1dd9417c
commit 24b3bb4177
19 changed files with 266 additions and 132 deletions

View File

@@ -6,40 +6,40 @@ namespace Tests\Kernel;
use Netig\Netslim\Kernel\Runtime\RuntimePaths;
use PHPUnit\Framework\TestCase;
use Tests\Support\TestRuntimeFactory;
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
final class RuntimePathsTest extends TestCase
{
protected function tearDown(): void
{
RuntimePaths::resetApplicationRoot();
RuntimePaths::resetProjectRoot();
TestRuntimeFactory::resetRuntime();
}
public function testGetProjectRootReturnsRepositoryRoot(): void
public function testGetProjectRootReturnsIsolatedTestProjectRoot(): void
{
self::assertSame(dirname(__DIR__, 2), RuntimePaths::getProjectRoot());
self::assertSame(TestRuntimeFactory::projectRoot(), RuntimePaths::getProjectRoot());
}
public function testGetConfigPathReturnsRootConfigDirectoryAndFilePath(): void
{
self::assertSame(dirname(__DIR__, 2) . '/config', RuntimePaths::getConfigPath());
self::assertSame(dirname(__DIR__, 2) . '/config/modules.php', RuntimePaths::getConfigPath('modules.php'));
self::assertSame(TestRuntimeFactory::path('config'), RuntimePaths::getConfigPath());
self::assertSame(TestRuntimeFactory::path('config/modules.php'), RuntimePaths::getConfigPath('modules.php'));
}
public function testApplicationRootDefaultsToProjectRoot(): void
{
self::assertSame(dirname(__DIR__, 2), RuntimePaths::getApplicationRoot());
self::assertSame(dirname(__DIR__, 2) . '/config', RuntimePaths::getApplicationConfigPath());
self::assertSame(TestRuntimeFactory::applicationRoot(), RuntimePaths::getApplicationRoot());
self::assertSame(TestRuntimeFactory::path('config'), RuntimePaths::getApplicationConfigPath());
}
public function testApplicationRootCanPointToFixtureApplication(): void
public function testApplicationRootCanPointToTheIsolatedFixtureApplication(): void
{
RuntimePaths::setApplicationRoot(dirname(__DIR__, 2) . '/tests/Fixtures/Application');
RuntimePaths::setApplicationRoot(TestRuntimeFactory::applicationRoot());
self::assertSame(dirname(__DIR__, 2) . '/tests/Fixtures/Application', RuntimePaths::getApplicationRoot());
self::assertSame(dirname(__DIR__, 2) . '/tests/Fixtures/Application/config/modules.php', RuntimePaths::getApplicationConfigPath('modules.php'));
self::assertSame(dirname(__DIR__, 2) . '/tests/Fixtures/Application/templates/Kernel', RuntimePaths::getApplicationPath('templates/Kernel'));
self::assertSame(TestRuntimeFactory::applicationRoot(), RuntimePaths::getApplicationRoot());
self::assertSame(TestRuntimeFactory::path('config/modules.php'), RuntimePaths::getApplicationConfigPath('modules.php'));
self::assertSame(TestRuntimeFactory::path('templates/Kernel'), RuntimePaths::getApplicationPath('templates/Kernel'));
}
public function testGetTwigCacheReturnsFalseInDev(): void
@@ -57,7 +57,7 @@ final class RuntimePathsTest extends TestCase
public function testGetDatabasePathCreatesDatabaseFileWhenMissing(): void
{
$dbFile = dirname(__DIR__, 2) . '/database/app.sqlite';
$dbFile = TestRuntimeFactory::path('database/app.sqlite');
$dbDir = dirname($dbFile);
$backup = $dbFile . '.bak-test';