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

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Tests\Support;
use PDO;
/**
* Fabrique légère pour les bases SQLite de test.
*/
final class TestDatabaseFactory
{
public static function createInMemory(): PDO
{
return new PDO('sqlite::memory:', options: [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
}
public static function createFileBacked(string $name): PDO
{
$path = TestRuntimeFactory::path('database/' . $name . '.sqlite');
if (is_file($path)) {
@unlink($path);
}
return new PDO('sqlite:' . $path, options: [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
}
}