From 65b98aa2a41a8499d01c3abb3912cac1c73a1d15 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Thu, 1 Nov 2018 13:42:30 -0400 Subject: [PATCH 1/2] Add phpunit test for getLocale/setLocale. --- tests/phpunit/CRM/Core/I18n/LocaleTest.php | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/phpunit/CRM/Core/I18n/LocaleTest.php diff --git a/tests/phpunit/CRM/Core/I18n/LocaleTest.php b/tests/phpunit/CRM/Core/I18n/LocaleTest.php new file mode 100644 index 000000000000..cb1e88fb6f0c --- /dev/null +++ b/tests/phpunit/CRM/Core/I18n/LocaleTest.php @@ -0,0 +1,55 @@ +enableMultilingual(); + CRM_Core_I18n_Schema::addLocale('fr_CA', 'en_US'); + + CRM_Core_I18n::singleton()->setLocale('fr_CA'); + $locale = CRM_Core_I18n::getLocale(); + + $this->assertEquals($locale, 'fr_CA'); + } + +} From 96cb9196ef324449842bd59ab8a1c5852ce565b2 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Thu, 1 Nov 2018 16:12:11 -0400 Subject: [PATCH 2/2] CRM_Core_I18n::setLocale should also change the tsLocale global variable --- CRM/Core/I18n.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index 40107e9824c0..6dfbe23b566c 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -649,6 +649,9 @@ public function setLocale($locale) { global $dbLocale; $dbLocale = "_{$locale}"; + // For self::getLocale() + global $tsLocale; + $tsLocale = $locale; } /**