fix tests issues
Tests / PHPUnit (push) Failing after 1m16s

This commit is contained in:
root
2026-07-13 00:24:00 -04:00
parent 439a695727
commit a56aca4342
17 changed files with 349 additions and 40 deletions
+23 -3
View File
@@ -2,19 +2,39 @@
namespace Tests\Support;
use CodeIgniter\Test\CIUnitTestCase;
use Config\Database;
use Throwable;
class DBReset
{
private const DB_GROUP = 'tests';
protected static array $excludeTables = ['migrations'];
public static function resetDatabase(): void
{
$db = Database::connect();
$config = config('Database');
$dbConfig = $config->{self::DB_GROUP} ?? [];
try {
$db = Database::connect(self::DB_GROUP);
$db->initialize();
} catch (Throwable $exception) {
throw new \RuntimeException(
sprintf(
'Test database connection failed: group=%s host=%s port=%s database=%s',
self::DB_GROUP,
$dbConfig['hostname'] ?? '',
$dbConfig['port'] ?? '',
$dbConfig['database'] ?? ''
),
0,
$exception
);
}
$db->disableForeignKeyChecks();
// Get all table names
$tables = $db->listTables();
foreach ($tables as $table) {