From de022564b319ca4df1bdbcb66c9a913586077093 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 15 Jan 2024 22:32:25 +0000 Subject: [PATCH] make sure every test happens inside a transaction --- core/testcase.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/testcase.php b/core/testcase.php index 3bfd47bc..984e0f1a 100644 --- a/core/testcase.php +++ b/core/testcase.php @@ -14,12 +14,12 @@ if(class_exists("\\PHPUnit\\Framework\\TestCase")) { public static function setUpBeforeClass(): void { - parent::setUpBeforeClass(); - global $_tracer; + global $_tracer, $database; $_tracer->begin(get_called_class()); - + $database->begin_transaction(); self::create_user(self::$admin_name); self::create_user(self::$user_name); + parent::setUpBeforeClass(); } public function setUp(): void @@ -56,7 +56,8 @@ if(class_exists("\\PHPUnit\\Framework\\TestCase")) { public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); - global $_tracer; + global $_tracer, $database; + $database->rollback(); $_tracer->end(); # get_called_class() $_tracer->clear(); $_tracer->flush("data/test-trace.json");