3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Test class for the option.language API parameter in multilingual.
34 class api_v3_MultilingualTest
extends CiviUnitTestCase
{
35 protected $_apiversion = 3;
36 public $DBResetRequired = FALSE;
39 * Sets up the fixture, for example, opens a network connection.
41 * This method is called before a test is executed.
43 protected function setUp() {
45 $this->useTransaction(TRUE);
48 public function tearDown() {
49 CRM_Core_I18n_Schema
::makeSinglelingual('en_US');
53 public function testOptionLanguage() {
54 $this->enableMultilingual();
56 CRM_Core_I18n_Schema
::addLocale('fr_CA', 'en_US');
58 $this->callAPISuccess('Setting', 'create', array(
59 'languageLimit' => array(
65 // Take a semi-random OptionGroup and test manually changing its label
66 // in one language, while making sure it stays the same in English.
67 $group = $this->callAPISuccess('OptionGroup', 'getsingle', array(
68 'name' => 'contact_edit_options',
71 $english_original = $this->callAPISuccess('OptionValue', 'getsingle', array(
72 'option_group_id' => $group['id'],
76 $this->callAPISuccess('OptionValue', 'create', array(
77 'id' => $english_original['id'],
79 'label' => 'Messagerie instantanée',
80 'option.language' => 'fr_CA',
83 $french = $this->callAPISuccess('OptionValue', 'getsingle', array(
84 'option_group_id' => $group['id'],
86 'option.language' => 'fr_CA',
89 $default = $this->callAPISuccess('OptionValue', 'getsingle', array(
90 'option_group_id' => $group['id'],
92 'option.language' => 'en_US',
95 $this->assertEquals($french['label'], 'Messagerie instantanée');
96 $this->assertEquals($default['label'], $english_original['label']);
100 * CRM-19677: Ensure that entity apis are not affected on Multilingual setup
101 * with check_permissions = TRUE
103 public function testAllEntities() {
104 $this->enableMultilingual();
106 // list of entities which has mandatory attributes
107 $specialEntities = array(
108 'Attachment' => array('id' => 13),
109 'CustomValue' => array('entity_id' => 13),
110 'MailingContact' => array('contact_id' => 13),
111 'Profile' => array('profile_id' => 13),
112 'MailingGroup' => array('mailing_id' => 13),
114 // deprecated or API.Get is not supported/implemented
115 $skippableEntities = array(
117 'MailingEventConfirm',
118 'MailingEventResubscribe',
119 'MailingEventSubscribe',
120 'MailingEventUnsubscribe',
124 'UFField', // throw error for help_post column
125 'UFGroup', //throw error for title
126 'User', // need loggedIn user id
128 // fetch all entities
129 $entities = $this->callAPISuccess('Entity', 'get', array());
130 $skippableEntities = array_merge($skippableEntities, $entities['deprecated']);
132 foreach ($entities['values'] as $entity) {
133 $params = array('check_permissions' => 1);
134 if (in_array($entity, $skippableEntities) && $entity != 'MailingGroup') {
137 if (array_key_exists($entity, $specialEntities)) {
138 $params = array_merge($params, $specialEntities[$entity]);
140 $this->callAPISuccess($entity, 'get', $params);