From 9d38a9235018c8f1dec0afde221a0527e4f268ec Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 16 Mar 2023 20:54:26 -0700 Subject: [PATCH] CiviUnitTestCase - Complain if setup steps are flipped around --- tests/phpunit/CiviTest/CiviUnitTestCase.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 9930747914..8e2a7a4fb9 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -269,6 +269,10 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Common setup functions for all unit tests. */ protected function setUp(): void { + if ($this->tx !== NULL) { + throw new \RuntimeException("CiviUnitTestCase requires that parent::setUp() run before useTransaction()"); + } + CRM_Core_I18n::clearLocale(); parent::setUp(); CRM_Core_Session::singleton()->set('userID'); -- 2.25.1