Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-01-08 13:45:02 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-01-08 13:45:19 +0300
commitf0c6cfde3afd25f56f399a3d0afa47281ab11833 (patch)
tree538277d32bbc4d17c2825ce62ce719a7ce07827a /tests
parentdc00c8ac31793f8facb6dbb764820dbe06786679 (diff)
Rollback failed transactions in TestCase.php to not break followup tests
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/TestCase.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php
index 69cf2a39792..6cadf9693c3 100644
--- a/tests/lib/TestCase.php
+++ b/tests/lib/TestCase.php
@@ -261,7 +261,12 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
}
$dataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data-autotest');
if (self::$wasDatabaseAllowed && \OC::$server->getDatabaseConnection()) {
- $queryBuilder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $db = \OC::$server->getDatabaseConnection();
+ if ($db->inTransaction()) {
+ $db->rollBack();
+ throw new \Exception('There was a transaction still in progress and needed to be rolled back. Please fix this in your test.');
+ }
+ $queryBuilder = $db->getQueryBuilder();
self::tearDownAfterClassCleanShares($queryBuilder);
self::tearDownAfterClassCleanStorages($queryBuilder);