From 096f0e1a00a8a9f87028f34abfd514b947624eb0 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 26 Aug 2021 02:12:00 -0700 Subject: [PATCH] LocaleTest - Add example for loading localized labels --- tests/phpunit/CRM/Core/I18n/LocaleTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/phpunit/CRM/Core/I18n/LocaleTest.php b/tests/phpunit/CRM/Core/I18n/LocaleTest.php index 49a044444c..eff8a8ae96 100644 --- a/tests/phpunit/CRM/Core/I18n/LocaleTest.php +++ b/tests/phpunit/CRM/Core/I18n/LocaleTest.php @@ -82,6 +82,18 @@ class CRM_Core_I18n_LocaleTest extends CiviUnitTestCase { } } + \CRM_Core_DAO::executeQuery('UPDATE civicrm_option_value SET label_fr_CA = \'Planifié\' WHERE name = \'Scheduled\'', + [], TRUE, NULL, FALSE, FALSE); + + // If you switch back and forth among these languages, labels should follow suit. + for ($trial = 0; $trial < 3; $trial++) { + \CRM_Core_I18n::singleton()->setLocale('en_US'); + $this->assertEquals('Scheduled', \CRM_Core_PseudoConstant::getLabel("CRM_Activity_BAO_Activity", "status_id", 1)); + + \CRM_Core_I18n::singleton()->setLocale('fr_CA'); + $this->assertEquals('Planifié', \CRM_Core_PseudoConstant::getLabel("CRM_Activity_BAO_Activity", "status_id", 1)); + } + CRM_Core_I18n::singleton()->setLocale('en_US'); CRM_Core_I18n_Schema::makeSinglelingual('en_US'); Civi::$statics['CRM_Core_I18n']['singleton'] = []; -- 2.25.1