From 8ab6ac202a65e0730c3d7fbb23c0f025d9a51eec Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 8 Feb 2023 14:47:51 -0800 Subject: [PATCH] CiviTestListener - Headless tests should have initialized timezone Before ------ * `CiviUnitTestCase` calls `setMySQLTimeZone()` * Headless tests (which are initialized via `CiviTestListener`) do not call `setMySQLTimeZone()` * If you have a test like 5.57's flavor of `QueueTest`, then the tests pass or fail depending on happenstance of server timezone configuration. After ----- * `CiviUnitTestCase` and `CiviTestListener` both call `setMySQLTimeZone()` * If you have a test like 5.57's flavor of `QueueTest`, then the tests pass more consistently. Comments -------- This branch should work cleanly as PR for `5.59` (rc) or `master`. I'd rather like to use this in `5.57-esr` (so that tests run more cleanly). So maybe `5.59` is the better target (but it doesn't strictly have to be). --- Civi/Test/CiviTestListener.php | 1 + Civi/Test/CiviTestListenerPHPUnit7.php | 1 + Civi/Test/Legacy/CiviTestListener.php | 1 + 3 files changed, 3 insertions(+) diff --git a/Civi/Test/CiviTestListener.php b/Civi/Test/CiviTestListener.php index 6e3b4cdc08..fbd6fd8878 100644 --- a/Civi/Test/CiviTestListener.php +++ b/Civi/Test/CiviTestListener.php @@ -121,6 +121,7 @@ else { \CRM_Core_Session::singleton()->set('userID', NULL); // ugh, performance $config = \CRM_Core_Config::singleton(TRUE, TRUE); + $config->userSystem->setMySQLTimeZone(); if (property_exists($config->userPermissionClass, 'permissions')) { $config->userPermissionClass->permissions = NULL; diff --git a/Civi/Test/CiviTestListenerPHPUnit7.php b/Civi/Test/CiviTestListenerPHPUnit7.php index 8b4b9af92e..c29c572e81 100644 --- a/Civi/Test/CiviTestListenerPHPUnit7.php +++ b/Civi/Test/CiviTestListenerPHPUnit7.php @@ -114,6 +114,7 @@ class CiviTestListenerPHPUnit7 implements \PHPUnit\Framework\TestListener { \CRM_Core_Session::singleton()->set('userID', NULL); // ugh, performance $config = \CRM_Core_Config::singleton(TRUE, TRUE); + $config->userSystem->setMySQLTimeZone(); if (property_exists($config->userPermissionClass, 'permissions')) { $config->userPermissionClass->permissions = NULL; diff --git a/Civi/Test/Legacy/CiviTestListener.php b/Civi/Test/Legacy/CiviTestListener.php index 93fb4ac8fb..4889da722b 100644 --- a/Civi/Test/Legacy/CiviTestListener.php +++ b/Civi/Test/Legacy/CiviTestListener.php @@ -111,6 +111,7 @@ class CiviTestListener extends \PHPUnit_Framework_BaseTestListener { \CRM_Core_Session::singleton()->set('userID', NULL); // ugh, performance $config = \CRM_Core_Config::singleton(TRUE, TRUE); + $config->userSystem->setMySQLTimeZone(); if (property_exists($config->userPermissionClass, 'permissions')) { $config->userPermissionClass->permissions = NULL; -- 2.25.1