Files
alrahma_sunday_school/tests/_support/DBReset.php
T
root f83ebe66b9
Tests / PHPUnit (push) Failing after 43s
fix tests issues
2026-07-12 20:36:40 -04:00

29 lines
618 B
PHP

<?php
namespace Tests\Support;
use CodeIgniter\Test\CIUnitTestCase;
use Config\Database;
class DBReset
{
protected static array $excludeTables = ['migrations'];
public static function resetDatabase(): void
{
$db = Database::connect();
$db->disableForeignKeyChecks();
// Get all table names
$tables = $db->listTables();
foreach ($tables as $table) {
if (!in_array($table, self::$excludeTables)) {
$db->query('TRUNCATE TABLE ' . $db->escapeIdentifiers($table));
}
}
$db->enableForeignKeyChecks();
}
}