2 require_once 'modules/Calls/metadata/additionalDetails.php';
7 class Bug22882Test extends Sugar_PHPUnit_Framework_TestCase
10 private $file_fr_tmp = '';
11 private $file_en_tmp = '';
13 public function setUp()
15 if ( !is_dir('custom/include/language') )
16 @mkdir('custom/include/language', 0777, true);
17 sugar_cache_clear('app_list_strings.en_us');
18 sugar_cache_clear('app_list_strings.fr_test');
21 public function testMultiLanguagesDeletedValue()
23 $this->loadFilesDeletedValue();
24 $resultfr = return_app_list_strings_language('fr_test');
25 $resulten = return_app_list_strings_language('en_us');
26 $resultfr = array_keys($resultfr['account_type_dom']);
27 $resulten = array_keys($resulten['account_type_dom']);
28 if($this->isSameSize($resultfr, $resulten)){
29 $this->isEqual($resultfr, $resulten);
31 $this->cleanupFiles();
34 public function testMultiLanguagesDeletedValueFrOnly()
36 $this->loadFilesDeletedValueFrOnly();
37 $resultfr = return_app_list_strings_language('fr_test');
38 $resulten = return_app_list_strings_language('en_us');
39 $resultfr = array_keys($resultfr['account_type_dom']);
40 $resulten = array_keys($resulten['account_type_dom']);
41 $this->assertNotEquals(count($resultfr), count($resulten), 'The 2 drop down list have the same size.');
42 $this->cleanupFiles();
45 public function testMultiLanguagesDeletedValueEnOnly()
47 $this->loadFilesDeletedValueEnOnly();
48 $resultfr = return_app_list_strings_language('fr_test');
49 $resulten = return_app_list_strings_language('en_us');
50 $resultfr = array_keys($resultfr['account_type_dom']);
51 $resulten = array_keys($resulten['account_type_dom']);
52 $this->assertNotEquals(count($resultfr),count($resulten));
53 $this->assertFalse(in_array('Customer',$resulten));
54 $this->assertTrue(in_array('Customer',$resultfr));
55 $this->cleanupFiles();
58 public function testMultiLanguagesAddedValue()
60 $this->loadFilesAddedValueEn();
61 $resultfr = return_app_list_strings_language('fr_test');
62 $resulten = return_app_list_strings_language('en_us');
63 $resultfr = array_keys($resultfr['account_type_dom']);
64 $resulten = array_keys($resulten['account_type_dom']);
65 $this->assertNotEquals(count($resultfr), count($resulten), 'The 2 drop down list have the same size.');
66 $this->cleanupFiles();
69 public function loadFilesDeletedValue(){
72 \$app_list_strings['account_type_dom']=array (
73 //'Analyst' => 'Analyste', Line deleted
74 'Competitor' => 'Concurrent',
75 'Customer' => 'Client',
76 'Integrator' => 'Intégrateur',
77 'Investor' => 'Investisseur',
78 'Partner' => 'Partenaire',
80 'Prospect' => 'Prospect',
87 \$app_list_strings['account_type_dom']=array (
88 //'Analyst' => 'Analyst', Line deleted
89 'Competitor' => 'Competitor',
90 'Customer' => 'Customer',
91 'Integrator' => 'Integrator',
92 'Investor' => 'Investor',
93 'Partner' => 'Partner',
95 'Prospect' => 'Prospect',
100 if(!file_exists('include/language/fr_test.lang.php')){
101 $this->file = file_get_contents('include/language/en_us.lang.php');
102 file_put_contents('include/language/fr_test.lang.php', $this->file);
104 if(!file_exists('custom/include/language/fr_test.lang.php')){
105 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
107 $this->file_fr_tmp = file_get_contents('custom/include/language/fr_test.lang.php');
108 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
110 if(!file_exists('custom/include/language/en_us.lang.php')){
111 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
113 $this->file_en_tmp = file_get_contents('custom/include/language/en_us.lang.php');
114 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
118 public function loadFilesDeletedValueFrOnly(){
121 \$app_list_strings['account_type_dom']=array (
122 //'Analyst' => 'Analyste', Line deleted
123 'Competitor' => 'Concurrent',
124 'Customer' => 'Client',
125 'Integrator' => 'Intégrateur',
126 'Investor' => 'Investisseur',
127 'Partner' => 'Partenaire',
129 'Prospect' => 'Prospect',
136 \$app_list_strings['account_type_dom']=array (
137 'Analyst' => 'Analyst',
138 'Competitor' => 'Competitor',
139 'Customer' => 'Customer',
140 'Integrator' => 'Integrator',
141 'Investor' => 'Investor',
142 'Partner' => 'Partner',
144 'Prospect' => 'Prospect',
149 if(!file_exists('include/language/fr_test.lang.php')){
150 $this->file = file_get_contents('include/language/en_us.lang.php');
151 file_put_contents('include/language/fr_test.lang.php', $this->file);
153 if(!file_exists('custom/include/language/fr_test.lang.php')){
154 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
156 $this->file_fr_tmp = file_get_contents('custom/include/language/fr_test.lang.php');
157 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
159 if(!file_exists('custom/include/language/en_us.lang.php')){
160 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
162 $this->file_en_tmp = file_get_contents('custom/include/language/en_us.lang.php');
163 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
167 public function loadFilesDeletedValueEnOnly(){
170 \$app_list_strings['account_type_dom']=array (
171 'Analyst' => 'Analyste',
172 'Competitor' => 'Concurrent',
173 'Customer' => 'Client',
174 'Integrator' => 'Intégrateur',
175 'Investor' => 'Investisseur',
176 'Partner' => 'Partenaire',
178 'Prospect' => 'Prospect',
185 \$app_list_strings['account_type_dom']=array (
186 'Analyst' => 'Analyst',
187 'Competitor' => 'Competitor',
188 //'Customer' => 'Customer',
189 'Integrator' => 'Integrator',
190 'Investor' => 'Investor',
191 'Partner' => 'Partner',
193 'Prospect' => 'Prospect',
198 if(!file_exists('include/language/fr_test.lang.php')){
199 $this->file = file_get_contents('include/language/en_us.lang.php');
200 file_put_contents('include/language/fr_test.lang.php', $this->file);
202 if(!file_exists('custom/include/language/fr_test.lang.php')){
203 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
205 $this->file_fr_tmp = file_get_contents('custom/include/language/fr_test.lang.php');
206 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
208 if(!file_exists('custom/include/language/en_us.lang.php')){
209 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
211 $this->file_en_tmp = file_get_contents('custom/include/language/en_us.lang.php');
212 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
216 public function loadFilesAddedValueEn(){
219 \$app_list_strings['account_type_dom']=array (
220 'Analyst' => 'Analyste',
221 'Competitor' => 'Concurrent',
222 'Customer' => 'Client',
223 'Integrator' => 'Intégrateur',
224 'Investor' => 'Investisseur',
225 'Partner' => 'Partenaire',
227 'Prospect' => 'Prospect',
234 \$app_list_strings['account_type_dom']=array (
236 'Analyst' => 'Analyst',
237 'Competitor' => 'Competitor',
238 'Customer' => 'Customer',
239 'Integrator' => 'Integrator',
240 'Investor' => 'Investor',
241 'Partner' => 'Partner',
243 'Prospect' => 'Prospect',
248 if(!file_exists('include/language/fr_test.lang.php')){
249 $this->file = file_get_contents('include/language/en_us.lang.php');
250 file_put_contents('include/language/fr_test.lang.php', $this->file);
252 if(!file_exists('custom/include/language/fr_test.lang.php')){
253 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
255 $this->file_fr_tmp = file_get_contents('custom/include/language/fr_test.lang.php');
256 file_put_contents('custom/include/language/fr_test.lang.php', $file_fr);
258 if(!file_exists('custom/include/language/en_us.lang.php')){
259 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
261 $this->file_en_tmp = file_get_contents('custom/include/language/en_us.lang.php');
262 file_put_contents('custom/include/language/en_us.lang.php', $file_en);
266 public function cleanupFiles(){
267 if(!empty($this->file)){
269 unlink('include/language/fr_test.lang.php');
271 if(!empty($this->file_fr_tmp)){
272 file_put_contents('custom/include/language/fr_test.lang.php', $this->file_fr_tmp);
273 $this->file_fr_tmp = '';
275 unlink('custom/include/language/fr_test.lang.php');
277 if(!empty($this->file_en_tmp)){
278 file_put_contents('custom/include/language/en_us.lang.php', $this->file_en_tmp);
279 $this->file_en_tmp = '';
281 unlink('custom/include/language/en_us.lang.php');
285 public function isSameSize($result1, $result2)
287 if(count($result1) != count($result2)){
288 $this->assertTrue(false, 'The 2 drop down list didn\'t have the same size.');
294 public function isEqual($result1, $result2)
296 foreach($result1 as $k=>$v){
297 $this->assertTrue(in_array($v,$result2));
299 foreach($result2 as $k=>$v){
300 $this->assertTrue(in_array($v,$result1));