From b2068c9ba5a5f681e78f03de1b31a6ff6863f00a Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 26 Aug 2022 13:40:11 -0700 Subject: [PATCH] CiviUnitTestCase - Clear locale vars between all tests --- CRM/Core/I18n.php | 4 ++++ tests/phpunit/CiviTest/CiviUnitTestCase.php | 1 + 2 files changed, 5 insertions(+) diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index fa96c601b6..d14716b0b8 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -677,6 +677,10 @@ class CRM_Core_I18n { CRM_Core_I18n::singleton()->reactivate(); } + public static function clearLocale(): void { + unset($GLOBALS['tsLocale'], $GLOBALS['dbLocale'], $GLOBALS['civicrmLocale']); + } + /** * Static instance provider - return the instance for the current locale. * diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index bab7810251..1470abda52 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -357,6 +357,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Common setup functions for all unit tests. */ protected function setUp(): void { + CRM_Core_I18n::clearLocale(); parent::setUp(); $session = CRM_Core_Session::singleton(); $session->set('userID', NULL); -- 2.25.1