From 30a43598ef235a6f441e531b20791ee321a55623 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 1 Mar 2022 17:51:00 -0800 Subject: [PATCH] (NFC) LoggingDetailTest - Improve reliability of test Before ----------------- If you run this test repeatedly, it may alternately pass and fail. The percentage of passes-vs-fails can vary widely (depending on the computer where you execute). To test this, I went to a deployment (on `test-3`) which had a fairly high probability of failure (*failure in roughly 3/4 invocations*). After ----------------- On the same system, it passes consistently (*no failures after 15 invocations*). --- tests/phpunit/CRM/Report/Form/Contact/LoggingDetailTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/phpunit/CRM/Report/Form/Contact/LoggingDetailTest.php b/tests/phpunit/CRM/Report/Form/Contact/LoggingDetailTest.php index 0f812befb9..67c7171994 100644 --- a/tests/phpunit/CRM/Report/Form/Contact/LoggingDetailTest.php +++ b/tests/phpunit/CRM/Report/Form/Contact/LoggingDetailTest.php @@ -22,8 +22,14 @@ class CRM_Report_Form_Contact_LoggingDetailTest extends CiviReportTestCase { public function setUp(): void { parent::setUp(); + + // Setup logging. This may create a series of backfilled log records. $this->callAPISuccess('Setting', 'create', ['logging' => TRUE]); $this->quickCleanup($this->_tablesToTruncate); + + // The test needs to create+read some log records. We want this to have a new/separate `log_conn_id`. + unset(\Civi::$statics['CRM_Utils_Request']['id']); + CRM_Core_DAO::init(CIVICRM_DSN); } public function tearDown(): void { -- 2.25.1