From e314f51db2404d4d9f947f3c5a0103f3a88ba06e Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 16 Mar 2023 20:51:34 -0700 Subject: [PATCH] test/phpunit/api/v3 - Fix spooky interaction This fixes an issue observed in review of 25673. With that patch included, `JobProcessMailingTest` would still pass... but only in isolation. When combined with `ExceptionTest`, it would fail. I tried disabling the entire substance of `ExceptionTest`, and it still failed. Say what? The problem was _the order_ in which `ExceptionTest` does its initialization (`parent::setUp()` and `$this->useTransaction()`). I suppose that order determines the effectiveness of the transaction. Most tests call `setup()` then `useTransaction()`. I looked for outliers which flipped the order -- and found `EntityTagACLTest` has the same init and the same spooky interaction. After fixing the outliers, I'm getting the expected results on `JobProcessMailingTest`. --- tests/phpunit/api/v3/EntityTagACLTest.php | 2 +- tests/phpunit/api/v3/ExceptionTest.php | 2 +- tests/phpunit/api/v3/PaymentTokenTest.php | 2 +- tests/phpunit/api/v3/SurveyTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/api/v3/EntityTagACLTest.php b/tests/phpunit/api/v3/EntityTagACLTest.php index b7c06fa651..66623d2f53 100644 --- a/tests/phpunit/api/v3/EntityTagACLTest.php +++ b/tests/phpunit/api/v3/EntityTagACLTest.php @@ -46,8 +46,8 @@ class api_v3_EntityTagACLTest extends CiviUnitTestCase { * Set up permissions for test. */ public function setUp(): void { - $this->useTransaction(TRUE); parent::setUp(); + $this->useTransaction(TRUE); $individualID = $this->individualCreate(); $daoObj = new CRM_Core_DAO(); $this->callAPISuccess('Attachment', 'create', [ diff --git a/tests/phpunit/api/v3/ExceptionTest.php b/tests/phpunit/api/v3/ExceptionTest.php index 1a5e38baf0..cd52cc2ab6 100644 --- a/tests/phpunit/api/v3/ExceptionTest.php +++ b/tests/phpunit/api/v3/ExceptionTest.php @@ -23,8 +23,8 @@ class api_v3_ExceptionTest extends CiviUnitTestCase { * This method is called before a test is executed. */ protected function setUp(): void { - $this->useTransaction(TRUE); parent::setUp(); + $this->useTransaction(TRUE); } /** diff --git a/tests/phpunit/api/v3/PaymentTokenTest.php b/tests/phpunit/api/v3/PaymentTokenTest.php index 51f5401cd0..d5219f4ff3 100644 --- a/tests/phpunit/api/v3/PaymentTokenTest.php +++ b/tests/phpunit/api/v3/PaymentTokenTest.php @@ -23,8 +23,8 @@ class api_v3_PaymentTokenTest extends CiviUnitTestCase { * @throws \CRM_Core_Exception */ public function setUp(): void { - $this->useTransaction(); parent::setUp(); + $this->useTransaction(); $contactID = $this->individualCreate(); $this->params = [ 'token' => "fancy-token-xxxx", diff --git a/tests/phpunit/api/v3/SurveyTest.php b/tests/phpunit/api/v3/SurveyTest.php index 6713719e47..e9bedd7061 100644 --- a/tests/phpunit/api/v3/SurveyTest.php +++ b/tests/phpunit/api/v3/SurveyTest.php @@ -33,6 +33,7 @@ class api_v3_SurveyTest extends CiviUnitTestCase { protected $entity = 'survey'; public function setUp(): void { + parent::setUp(); $phoneBankActivityTypeID = $this->callAPISuccessGetValue('Option_value', [ 'label' => 'PhoneBank', 'return' => 'value', @@ -45,7 +46,6 @@ class api_v3_SurveyTest extends CiviUnitTestCase { 'max_number_of_contacts' => 12, 'instructions' => "Call people, ask for money", ]; - parent::setUp(); } /** -- 2.25.1