2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
38 require_once 'modules/Calls/metadata/additionalDetails.php';
43 class Bug22882Test extends Sugar_PHPUnit_Framework_TestCase
46 private $file_fr_tmp = '';
47 private $file_en_tmp = '';
49 public function setUp()
51 if ( !is_dir('custom/include/language') )
52 @mkdir('custom/include/language', 0777, true);
53 sugar_cache_clear('app_list_strings.en_us');
54 sugar_cache_clear('app_list_strings.fr_test');
57 public function testMultiLanguagesDeletedValue()
59 $this->loadFilesDeletedValue();
60 $resultfr = return_app_list_strings_language('fr_test');
61 $resulten = return_app_list_strings_language('en_us');
62 $resultfr = array_keys($resultfr['account_type_dom']);
63 $resulten = array_keys($resulten['account_type_dom']);
64 if($this->isSameSize($resultfr, $resulten)){
65 $this->isEqual($resultfr, $resulten);
67 $this->cleanupFiles();
70 public function testMultiLanguagesDeletedValueFrOnly()
72 $this->loadFilesDeletedValueFrOnly();
73 $resultfr = return_app_list_strings_language('fr_test');
74 $resulten = return_app_list_strings_language('en_us');
75 $resultfr = array_keys($resultfr['account_type_dom']);
76 $resulten = array_keys($resulten['account_type_dom']);
77 $this->assertNotEquals(count($resultfr), count($resulten), 'The 2 drop down list have the same size.');
78 $this->cleanupFiles();
81 public function testMultiLanguagesDeletedValueEnOnly()
83 $this->loadFilesDeletedValueEnOnly();
84 $resultfr = return_app_list_strings_language('fr_test');
85 $resulten = return_app_list_strings_language('en_us');
86 $resultfr = array_keys($resultfr['account_type_dom']);
87 $resulten = array_keys($resulten['account_type_dom']);
88 $this->assertNotEquals(count($resultfr),count($resulten));
89 $this->assertFalse(in_array('Customer',$resulten));
90 $this->assertTrue(in_array('Customer',$resultfr));
91 $this->cleanupFiles();
94 public function testMultiLanguagesAddedValue()
96 $this->loadFilesAddedValueEn();
97 $resultfr = return_app_list_strings_language('fr_test');
98 $resulten = return_app_list_strings_language('en_us');
99 $resultfr = array_keys($resultfr['account_type_dom']);
100 $resulten = array_keys($resulten['account_type_dom']);
101 $this->assertNotEquals(count($resultfr), count($resulten), 'The 2 drop down list have the same size.');
102 $this->cleanupFiles();
105 public function loadFilesDeletedValue(){
108 \$app_list_strings['account_type_dom']=array (
109 //'Analyst' => 'Analyste', Line deleted
110 'Competitor' => 'Concurrent',
111 'Customer' => 'Client',
112 'Integrator' => 'Intégrateur',
113 'Investor' => 'Investisseur',
114 'Partner' => 'Partenaire',
116 'Prospect' => 'Prospect',
123 \$app_list_strings['account_type_dom']=array (
124 //'Analyst' => 'Analyst', Line deleted
125 'Competitor' => 'Competitor',
126 'Customer' => 'Customer',
127 'Integrator' => 'Integrator',
128 'Investor' => 'Investor',
129 'Partner' => 'Partner',
131 'Prospect' => 'Prospect',
136 if(!file_exists('include/language/fr_test.lang.php')){
137 $this->file = file_get_contents('include/language/en_us.lang.php');
138 file_put_contents('include/language/fr_test.lang.php', $this->file);
140 if(!file_exists('custom/include/language/fr_test.lang.php')){
141 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
143 $this->file_fr_tmp = file_get_contents('custom/include/language/fr_test.lang.php');
144 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
146 if(!file_exists('custom/include/language/en_us.lang.php')){
147 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
149 $this->file_en_tmp = file_get_contents('custom/include/language/en_us.lang.php');
150 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
154 public function loadFilesDeletedValueFrOnly(){
157 \$app_list_strings['account_type_dom']=array (
158 //'Analyst' => 'Analyste', Line deleted
159 'Competitor' => 'Concurrent',
160 'Customer' => 'Client',
161 'Integrator' => 'Intégrateur',
162 'Investor' => 'Investisseur',
163 'Partner' => 'Partenaire',
165 'Prospect' => 'Prospect',
172 \$app_list_strings['account_type_dom']=array (
173 'Analyst' => 'Analyst',
174 'Competitor' => 'Competitor',
175 'Customer' => 'Customer',
176 'Integrator' => 'Integrator',
177 'Investor' => 'Investor',
178 'Partner' => 'Partner',
180 'Prospect' => 'Prospect',
185 if(!file_exists('include/language/fr_test.lang.php')){
186 $this->file = file_get_contents('include/language/en_us.lang.php');
187 file_put_contents('include/language/fr_test.lang.php', $this->file);
189 if(!file_exists('custom/include/language/fr_test.lang.php')){
190 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
192 $this->file_fr_tmp = file_get_contents('custom/include/language/fr_test.lang.php');
193 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
195 if(!file_exists('custom/include/language/en_us.lang.php')){
196 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
198 $this->file_en_tmp = file_get_contents('custom/include/language/en_us.lang.php');
199 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
203 public function loadFilesDeletedValueEnOnly(){
206 \$app_list_strings['account_type_dom']=array (
207 'Analyst' => 'Analyste',
208 'Competitor' => 'Concurrent',
209 'Customer' => 'Client',
210 'Integrator' => 'Intégrateur',
211 'Investor' => 'Investisseur',
212 'Partner' => 'Partenaire',
214 'Prospect' => 'Prospect',
221 \$app_list_strings['account_type_dom']=array (
222 'Analyst' => 'Analyst',
223 'Competitor' => 'Competitor',
224 //'Customer' => 'Customer',
225 'Integrator' => 'Integrator',
226 'Investor' => 'Investor',
227 'Partner' => 'Partner',
229 'Prospect' => 'Prospect',
234 if(!file_exists('include/language/fr_test.lang.php')){
235 $this->file = file_get_contents('include/language/en_us.lang.php');
236 file_put_contents('include/language/fr_test.lang.php', $this->file);
238 if(!file_exists('custom/include/language/fr_test.lang.php')){
239 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
241 $this->file_fr_tmp = file_get_contents('custom/include/language/fr_test.lang.php');
242 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
244 if(!file_exists('custom/include/language/en_us.lang.php')){
245 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
247 $this->file_en_tmp = file_get_contents('custom/include/language/en_us.lang.php');
248 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
252 public function loadFilesAddedValueEn(){
255 \$app_list_strings['account_type_dom']=array (
256 'Analyst' => 'Analyste',
257 'Competitor' => 'Concurrent',
258 'Customer' => 'Client',
259 'Integrator' => 'Intégrateur',
260 'Investor' => 'Investisseur',
261 'Partner' => 'Partenaire',
263 'Prospect' => 'Prospect',
270 \$app_list_strings['account_type_dom']=array (
272 'Analyst' => 'Analyst',
273 'Competitor' => 'Competitor',
274 'Customer' => 'Customer',
275 'Integrator' => 'Integrator',
276 'Investor' => 'Investor',
277 'Partner' => 'Partner',
279 'Prospect' => 'Prospect',
284 if(!file_exists('include/language/fr_test.lang.php')){
285 $this->file = file_get_contents('include/language/en_us.lang.php');
286 file_put_contents('include/language/fr_test.lang.php', $this->file);
288 if(!file_exists('custom/include/language/fr_test.lang.php')){
289 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
291 $this->file_fr_tmp = file_get_contents('custom/include/language/fr_test.lang.php');
292 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
294 if(!file_exists('custom/include/language/en_us.lang.php')){
295 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
297 $this->file_en_tmp = file_get_contents('custom/include/language/en_us.lang.php');
298 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
302 public function cleanupFiles(){
303 if(!empty($this->file)){
305 unlink('include/language/fr_test.lang.php');
307 if(!empty($this->file_fr_tmp)){
308 file_put_contents('custom/include/language/fr_test.lang.php', $this->file_fr_tmp);
309 $this->file_fr_tmp = '';
311 unlink('custom/include/language/fr_test.lang.php');
313 if(!empty($this->file_en_tmp)){
314 file_put_contents('custom/include/language/en_us.lang.php', $this->file_en_tmp);
315 $this->file_en_tmp = '';
317 unlink('custom/include/language/en_us.lang.php');
321 public function isSameSize($result1, $result2)
323 if(count($result1) != count($result2)){
324 $this->assertTrue(false, 'The 2 drop down list didn\'t have the same size.');
330 public function isEqual($result1, $result2)
332 foreach($result1 as $k=>$v){
333 $this->assertTrue(in_array($v,$result2));
335 foreach($result2 as $k=>$v){
336 $this->assertTrue(in_array($v,$result1));