X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2FDatabaseTestTrait.php;h=9d46259ed1431fb1b35a894b720613a0c898444a;hb=9d8a420391153a9c8f9ffaad75822c78bd06b67f;hp=5f753f3152e3d4688ea2505165240fbe9dcd7c19;hpb=13a10b8f20ac7c5927c39d9e80e1a7d515385736;p=friendica.git diff --git a/tests/DatabaseTestTrait.php b/tests/DatabaseTestTrait.php index 5f753f3152..9d46259ed1 100644 --- a/tests/DatabaseTestTrait.php +++ b/tests/DatabaseTestTrait.php @@ -1,6 +1,6 @@ rollBack(); // Start the first, outer transaction StaticDatabase::getGlobConnection()->beginTransaction(); - - parent::setUp(); } - protected function tearDown() + protected function tearDownDb() { - // Rollbacks every DB usage so we don't commit anything into the DB - StaticDatabase::statRollback(); - - parent::tearDown(); + try { + // Rollbacks every DB usage so we don't commit anything into the DB + StaticDatabase::statRollback(); + } catch (\PDOException $exception) { + print_r("Found already rolled back transaction"); + } } /** @@ -61,13 +63,17 @@ trait DatabaseTestTrait $data = include $fixture; foreach ($data as $tableName => $rows) { + if (is_numeric($tableName)) { + continue; + } + if (!is_array($rows)) { - $dba->p('TRUNCATE TABLE `' . $tableName . '``'); + $dba->e('TRUNCATE TABLE `' . $tableName . '``'); continue; } foreach ($rows as $row) { - $dba->insert($tableName, $row); + $dba->insert($tableName, $row, true); } } }