@@ -10,6 +10,7 @@ class DBReset
|
||||
private const DB_GROUP = 'tests';
|
||||
|
||||
protected static array $excludeTables = ['migrations', 'school_years'];
|
||||
private static bool $migrated = false;
|
||||
|
||||
public static function resetDatabase(): void
|
||||
{
|
||||
@@ -34,6 +35,8 @@ class DBReset
|
||||
);
|
||||
}
|
||||
|
||||
self::migrateTestDatabase($db);
|
||||
|
||||
$db->disableForeignKeyChecks();
|
||||
|
||||
$tables = $db->resetDataCache()->listTables();
|
||||
@@ -47,6 +50,18 @@ class DBReset
|
||||
$db->enableForeignKeyChecks();
|
||||
}
|
||||
|
||||
private static function migrateTestDatabase($db): void
|
||||
{
|
||||
if (self::$migrated) {
|
||||
return;
|
||||
}
|
||||
|
||||
$runner = \Config\Services::migrations(config('Migrations'), $db, false);
|
||||
$runner->setNamespace('App')->latest();
|
||||
|
||||
self::$migrated = true;
|
||||
}
|
||||
|
||||
private static function assertSafeTestDatabase(array $defaultConfig, array $testConfig): void
|
||||
{
|
||||
$defaultDatabase = (string) ($defaultConfig['database'] ?? '');
|
||||
|
||||
Reference in New Issue
Block a user