From 0ac69d8237687e63234fe2b2e590c47375352315 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Tue, 27 Sep 2016 14:09:56 +0000 Subject: [PATCH] CRM-19419: Add API test for option.language in multilingual. --- tests/phpunit/api/v3/MultilingualTest.php | 108 ++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 tests/phpunit/api/v3/MultilingualTest.php diff --git a/tests/phpunit/api/v3/MultilingualTest.php b/tests/phpunit/api/v3/MultilingualTest.php new file mode 100644 index 0000000000..d7070320d3 --- /dev/null +++ b/tests/phpunit/api/v3/MultilingualTest.php @@ -0,0 +1,108 @@ +useTransaction(TRUE); + } + + public function tearDown() { + CRM_Core_I18n_Schema::makeSinglelingual('en_US'); + parent::tearDown(); + } + + public function testOptionLanguage() { + civicrm_api3('Setting', 'create', [ + 'lcMessages' => 'en_US', + 'languageLimit' => [ + 'en_US' => 1, + ], + ]); + + CRM_Core_I18n_Schema::makeMultilingual('en_US'); + + global $dbLocale; + $dbLocale = '_en_US'; + + CRM_Core_I18n_Schema::addLocale('fr_CA', 'en_US'); + + civicrm_api3('Setting', 'create', array( + 'languageLimit' => array( + 'en_US', + 'fr_CA', + ), + )); + + // Take a semi-random OptionGroup and test manually changing its label + // in one language, while making sure it stays the same in English. + $group = civicrm_api3('OptionGroup', 'getsingle', array( + 'name' => 'contact_edit_options' + )); + + $english_original = civicrm_api3('OptionValue', 'getsingle', array( + 'option_group_id' => $group['id'], + 'name' => 'IM' + )); + + civicrm_api3('OptionValue', 'create', array( + 'id' => $english_original['id'], + 'name' => 'IM', + 'label' => 'Messagerie instantanée', + 'option.language' => 'fr_CA', + )); + + $french = civicrm_api3('OptionValue', 'getsingle', array( + 'option_group_id' => $group['id'], + 'name' => 'IM', + 'option.language' => 'fr_CA', + )); + + $default = civicrm_api3('OptionValue', 'getsingle', array( + 'option_group_id' => $group['id'], + 'name' => 'IM', 'option.language' => 'en_US', + )); + + $this->assertEquals($french['label'], 'Messagerie instantanée'); + $this->assertEquals($default['label'], $english_original['label']); + } + +} -- 2.25.1