@@ -23,23 +23,23 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/exports/class/export.class.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/files.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
34 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
35 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
36 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
37 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
38 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
39 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
40 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
41 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
42 | +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
43 | 43 | |
44 | 44 | |
45 | 45 | /** |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | parent::__construct(); |
68 | 68 | |
69 | 69 | //$this->sharedFixture |
70 | - global $conf,$user,$langs,$db; |
|
71 | - $this->savconf=$conf; |
|
72 | - $this->savuser=$user; |
|
73 | - $this->savlangs=$langs; |
|
74 | - $this->savdb=$db; |
|
70 | + global $conf, $user, $langs, $db; |
|
71 | + $this->savconf = $conf; |
|
72 | + $this->savuser = $user; |
|
73 | + $this->savlangs = $langs; |
|
74 | + $this->savdb = $db; |
|
75 | 75 | |
76 | 76 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
77 | 77 | //print " - db ".$db->db; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | // Static methods |
82 | 82 | public static function setUpBeforeClass() |
83 | 83 | { |
84 | - global $conf,$user,$langs,$db; |
|
84 | + global $conf, $user, $langs, $db; |
|
85 | 85 | //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
86 | 86 | |
87 | 87 | print __METHOD__."\n"; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | // tear down after class |
91 | 91 | public static function tearDownAfterClass() |
92 | 92 | { |
93 | - global $conf,$user,$langs,$db; |
|
93 | + global $conf, $user, $langs, $db; |
|
94 | 94 | //$db->rollback(); |
95 | 95 | |
96 | 96 | print __METHOD__."\n"; |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function setUp() |
105 | 105 | { |
106 | - global $conf,$user,$langs,$db; |
|
107 | - $conf=$this->savconf; |
|
108 | - $user=$this->savuser; |
|
109 | - $langs=$this->savlangs; |
|
110 | - $db=$this->savdb; |
|
106 | + global $conf, $user, $langs, $db; |
|
107 | + $conf = $this->savconf; |
|
108 | + $user = $this->savuser; |
|
109 | + $langs = $this->savlangs; |
|
110 | + $db = $this->savdb; |
|
111 | 111 | |
112 | 112 | print __METHOD__."\n"; |
113 | 113 | } |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function testExportOther() |
131 | 131 | { |
132 | - global $conf,$user,$langs,$db; |
|
132 | + global $conf, $user, $langs, $db; |
|
133 | 133 | |
134 | - $model='csv'; |
|
134 | + $model = 'csv'; |
|
135 | 135 | |
136 | 136 | // Creation of class to export using model ExportXXX |
137 | - $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/"; |
|
137 | + $dir = DOL_DOCUMENT_ROOT."/core/modules/export/"; |
|
138 | 138 | $file = "export_".$model.".modules.php"; |
139 | 139 | $classname = "Export".$model; |
140 | 140 | require_once $dir.$file; |
@@ -143,64 +143,64 @@ discard block |
||
143 | 143 | // First test without option USE_STRICT_CSV_RULES |
144 | 144 | unset($conf->global->USE_STRICT_CSV_RULES); |
145 | 145 | |
146 | - $valtotest='A simple string'; |
|
146 | + $valtotest = 'A simple string'; |
|
147 | 147 | print __METHOD__." valtotest=".$valtotest."\n"; |
148 | 148 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
149 | 149 | print __METHOD__." result=".$result."\n"; |
150 | 150 | $this->assertEquals($result, 'A simple string'); |
151 | 151 | |
152 | - $valtotest='A string with , and ; inside'; |
|
152 | + $valtotest = 'A string with , and ; inside'; |
|
153 | 153 | print __METHOD__." valtotest=".$valtotest."\n"; |
154 | 154 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
155 | 155 | print __METHOD__." result=".$result."\n"; |
156 | 156 | $this->assertEquals($result, '"A string with , and ; inside"'); |
157 | 157 | |
158 | - $valtotest='A string with " inside'; |
|
158 | + $valtotest = 'A string with " inside'; |
|
159 | 159 | print __METHOD__." valtotest=".$valtotest."\n"; |
160 | 160 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
161 | 161 | print __METHOD__." result=".$result."\n"; |
162 | 162 | $this->assertEquals($result, '"A string with "" inside"'); |
163 | 163 | |
164 | - $valtotest='A string with " inside and '."\r\n".' carriage returns'; |
|
164 | + $valtotest = 'A string with " inside and '."\r\n".' carriage returns'; |
|
165 | 165 | print __METHOD__." valtotest=".$valtotest."\n"; |
166 | 166 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
167 | 167 | print __METHOD__." result=".$result."\n"; |
168 | 168 | $this->assertEquals($result, '"A string with "" inside and \n carriage returns"'); |
169 | 169 | |
170 | - $valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
170 | + $valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
171 | 171 | print __METHOD__." valtotest=".$valtotest."\n"; |
172 | 172 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
173 | 173 | print __METHOD__." result=".$result."\n"; |
174 | 174 | $this->assertEquals($result, '"A string with <a href=""aaa""><strong>html<br>content</strong></a> inside"'); |
175 | 175 | |
176 | 176 | // Same tests with strict mode |
177 | - $conf->global->USE_STRICT_CSV_RULES=1; |
|
177 | + $conf->global->USE_STRICT_CSV_RULES = 1; |
|
178 | 178 | |
179 | - $valtotest='A simple string'; |
|
179 | + $valtotest = 'A simple string'; |
|
180 | 180 | print __METHOD__." valtotest=".$valtotest."\n"; |
181 | 181 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
182 | 182 | print __METHOD__." result=".$result."\n"; |
183 | 183 | $this->assertEquals($result, 'A simple string'); |
184 | 184 | |
185 | - $valtotest='A string with , and ; inside'; |
|
185 | + $valtotest = 'A string with , and ; inside'; |
|
186 | 186 | print __METHOD__." valtotest=".$valtotest."\n"; |
187 | 187 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
188 | 188 | print __METHOD__." result=".$result."\n"; |
189 | 189 | $this->assertEquals($result, '"A string with , and ; inside"'); |
190 | 190 | |
191 | - $valtotest='A string with " inside'; |
|
191 | + $valtotest = 'A string with " inside'; |
|
192 | 192 | print __METHOD__." valtotest=".$valtotest."\n"; |
193 | 193 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
194 | 194 | print __METHOD__." result=".$result."\n"; |
195 | 195 | $this->assertEquals($result, '"A string with "" inside"'); |
196 | 196 | |
197 | - $valtotest='A string with " inside and '."\r\n".' carriage returns'; |
|
197 | + $valtotest = 'A string with " inside and '."\r\n".' carriage returns'; |
|
198 | 198 | print __METHOD__." valtotest=".$valtotest."\n"; |
199 | 199 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
200 | 200 | print __METHOD__." result=".$result."\n"; |
201 | 201 | $this->assertEquals($result, "\"A string with \"\" inside and \r\n carriage returns\""); |
202 | 202 | |
203 | - $valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
203 | + $valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
204 | 204 | print __METHOD__." valtotest=".$valtotest."\n"; |
205 | 205 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
206 | 206 | print __METHOD__." result=".$result."\n"; |
@@ -215,43 +215,43 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function testExportPersonalizedExport() |
217 | 217 | { |
218 | - global $conf,$user,$langs,$db; |
|
218 | + global $conf, $user, $langs, $db; |
|
219 | 219 | |
220 | 220 | $sql = "SELECT f.ref as f_ref, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f"; |
221 | 221 | |
222 | - $objexport=new Export($db); |
|
222 | + $objexport = new Export($db); |
|
223 | 223 | //$objexport->load_arrays($user,$datatoexport); |
224 | 224 | |
225 | 225 | // Define properties |
226 | - $datatoexport='test'; |
|
226 | + $datatoexport = 'test'; |
|
227 | 227 | $array_selected = array("f.ref"=>1, "f.total"=>2, "f.tva"=>3); |
228 | 228 | $array_export_fields = array("f.ref"=>"FacNumber", "f.total"=>"FacTotal", "f.tva"=>"FacVat"); |
229 | 229 | $array_alias = array("f_ref"=>"ref", "f_total"=>"total", "f_tva"=>"tva"); |
230 | - $objexport->array_export_fields[0]=$array_export_fields; |
|
231 | - $objexport->array_export_alias[0]=$array_alias; |
|
230 | + $objexport->array_export_fields[0] = $array_export_fields; |
|
231 | + $objexport->array_export_alias[0] = $array_alias; |
|
232 | 232 | |
233 | 233 | dol_mkdir($conf->export->dir_temp); |
234 | 234 | |
235 | - $model='csv'; |
|
235 | + $model = 'csv'; |
|
236 | 236 | |
237 | 237 | // Build export file |
238 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
239 | - $expectedresult=1; |
|
240 | - $this->assertEquals($expectedresult,$result); |
|
238 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
239 | + $expectedresult = 1; |
|
240 | + $this->assertEquals($expectedresult, $result); |
|
241 | 241 | |
242 | - $model='tsv'; |
|
242 | + $model = 'tsv'; |
|
243 | 243 | |
244 | 244 | // Build export file |
245 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
246 | - $expectedresult=1; |
|
247 | - $this->assertEquals($expectedresult,$result); |
|
245 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
246 | + $expectedresult = 1; |
|
247 | + $this->assertEquals($expectedresult, $result); |
|
248 | 248 | |
249 | - $model='excel'; |
|
249 | + $model = 'excel'; |
|
250 | 250 | |
251 | 251 | // Build export file |
252 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
253 | - $expectedresult=1; |
|
254 | - $this->assertEquals($expectedresult,$result); |
|
252 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
253 | + $expectedresult = 1; |
|
254 | + $this->assertEquals($expectedresult, $result); |
|
255 | 255 | |
256 | 256 | return true; |
257 | 257 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function testExportPersonalizedWithFilter() |
266 | 266 | { |
267 | - global $conf,$user,$langs,$db; |
|
267 | + global $conf, $user, $langs, $db; |
|
268 | 268 | /* |
269 | 269 | $sql = "SELECT f.ref as f_ref, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f"; |
270 | 270 | |
@@ -315,40 +315,40 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function testExportModulesDatasets() |
317 | 317 | { |
318 | - global $conf,$user,$langs,$db; |
|
318 | + global $conf, $user, $langs, $db; |
|
319 | 319 | |
320 | - $model='csv'; |
|
320 | + $model = 'csv'; |
|
321 | 321 | |
322 | - $filterdatatoexport=''; |
|
322 | + $filterdatatoexport = ''; |
|
323 | 323 | //$filterdatatoexport=''; |
324 | 324 | //$array_selected = array("s.rowid"=>1, "s.nom"=>2); // Mut be fields found into declaration of dataset |
325 | 325 | |
326 | 326 | // Load properties of arrays to make export |
327 | - $objexport=new Export($db); |
|
328 | - $result=$objexport->load_arrays($user,$filterdatatoexport); // This load ->array_export_xxx properties for datatoexport |
|
327 | + $objexport = new Export($db); |
|
328 | + $result = $objexport->load_arrays($user, $filterdatatoexport); // This load ->array_export_xxx properties for datatoexport |
|
329 | 329 | |
330 | 330 | // Loop on each dataset |
331 | - foreach($objexport->array_export_code as $key => $datatoexport) |
|
331 | + foreach ($objexport->array_export_code as $key => $datatoexport) |
|
332 | 332 | { |
333 | - $exportfile=$conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv'; |
|
333 | + $exportfile = $conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv'; |
|
334 | 334 | print "Process export for dataset ".$datatoexport." into ".$exportfile."\n"; |
335 | 335 | dol_delete_file($exportfile); |
336 | 336 | |
337 | 337 | // Generate $array_selected |
338 | - $i=0; |
|
339 | - $array_selected=array(); |
|
340 | - foreach($objexport->array_export_fields[$key] as $key => $val) |
|
338 | + $i = 0; |
|
339 | + $array_selected = array(); |
|
340 | + foreach ($objexport->array_export_fields[$key] as $key => $val) |
|
341 | 341 | { |
342 | - $array_selected[$key]=$i++; |
|
342 | + $array_selected[$key] = $i++; |
|
343 | 343 | } |
344 | 344 | //var_dump($array_selected); |
345 | 345 | |
346 | 346 | // Build export file |
347 | 347 | $sql = ""; |
348 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
349 | - $expectedresult=1; |
|
348 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
349 | + $expectedresult = 1; |
|
350 | 350 | $this->assertEquals($expectedresult, $result, "Call build_file() to export ".$exportfile.' failed'); |
351 | - $result=dol_is_file($exportfile); |
|
351 | + $result = dol_is_file($exportfile); |
|
352 | 352 | $this->assertTrue($result, 'File '.$exportfile.' not found'); |
353 | 353 | } |
354 | 354 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $user->fetch(1); |
36 | 36 | $user->getrights(); |
37 | 37 | } |
38 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
38 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | parent::__construct(); |
64 | 64 | |
65 | 65 | //$this->sharedFixture |
66 | - global $conf,$user,$langs,$db; |
|
67 | - $this->savconf=$conf; |
|
68 | - $this->savuser=$user; |
|
69 | - $this->savlangs=$langs; |
|
70 | - $this->savdb=$db; |
|
66 | + global $conf, $user, $langs, $db; |
|
67 | + $this->savconf = $conf; |
|
68 | + $this->savuser = $user; |
|
69 | + $this->savlangs = $langs; |
|
70 | + $this->savdb = $db; |
|
71 | 71 | |
72 | 72 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
73 | 73 | //print " - db ".$db->db; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | // Static methods |
78 | 78 | public static function setUpBeforeClass() |
79 | 79 | { |
80 | - global $conf,$user,$langs,$db; |
|
80 | + global $conf, $user, $langs, $db; |
|
81 | 81 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
82 | 82 | |
83 | 83 | print __METHOD__."\n"; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // tear down after class |
87 | 87 | public static function tearDownAfterClass() |
88 | 88 | { |
89 | - global $conf,$user,$langs,$db; |
|
89 | + global $conf, $user, $langs, $db; |
|
90 | 90 | $db->rollback(); |
91 | 91 | |
92 | 92 | print __METHOD__."\n"; |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | */ |
100 | 100 | protected function setUp() |
101 | 101 | { |
102 | - global $conf,$user,$langs,$db; |
|
103 | - $conf=$this->savconf; |
|
104 | - $user=$this->savuser; |
|
105 | - $langs=$this->savlangs; |
|
106 | - $db=$this->savdb; |
|
102 | + global $conf, $user, $langs, $db; |
|
103 | + $conf = $this->savconf; |
|
104 | + $user = $this->savuser; |
|
105 | + $langs = $this->savlangs; |
|
106 | + $db = $this->savdb; |
|
107 | 107 | |
108 | 108 | print __METHOD__."\n"; |
109 | 109 | } |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function testFetchUser() |
127 | 127 | { |
128 | - global $conf,$user,$langs,$db; |
|
129 | - $conf=$this->savconf; |
|
130 | - $user=$this->savuser; |
|
131 | - $langs=$this->savlangs; |
|
132 | - $db=$this->savdb; |
|
128 | + global $conf, $user, $langs, $db; |
|
129 | + $conf = $this->savconf; |
|
130 | + $user = $this->savuser; |
|
131 | + $langs = $this->savlangs; |
|
132 | + $db = $this->savdb; |
|
133 | 133 | |
134 | - $localobject=new Commande($this->savdb); |
|
134 | + $localobject = new Commande($this->savdb); |
|
135 | 135 | $localobject->fetch(1); |
136 | 136 | |
137 | - $result=$localobject->fetch_user(1); |
|
137 | + $result = $localobject->fetch_user(1); |
|
138 | 138 | |
139 | 139 | print __METHOD__." result=".$result."\n"; |
140 | 140 | $this->assertLessThan($localobject->user->id, 0); |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function testFetchProjet() |
150 | 150 | { |
151 | - global $conf,$user,$langs,$db; |
|
152 | - $conf=$this->savconf; |
|
153 | - $user=$this->savuser; |
|
154 | - $langs=$this->savlangs; |
|
155 | - $db=$this->savdb; |
|
151 | + global $conf, $user, $langs, $db; |
|
152 | + $conf = $this->savconf; |
|
153 | + $user = $this->savuser; |
|
154 | + $langs = $this->savlangs; |
|
155 | + $db = $this->savdb; |
|
156 | 156 | |
157 | - $localobject=new Commande($this->savdb); |
|
157 | + $localobject = new Commande($this->savdb); |
|
158 | 158 | $localobject->fetch(1); |
159 | - $result=$localobject->fetch_projet(); |
|
159 | + $result = $localobject->fetch_projet(); |
|
160 | 160 | |
161 | 161 | print __METHOD__." result=".$result."\n"; |
162 | - $this->assertLessThanOrEqual($result,0); |
|
162 | + $this->assertLessThanOrEqual($result, 0); |
|
163 | 163 | return $result; |
164 | 164 | } |
165 | 165 | |
@@ -170,19 +170,19 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function testFetchThirdParty() |
172 | 172 | { |
173 | - global $conf,$user,$langs,$db; |
|
174 | - $conf=$this->savconf; |
|
175 | - $user=$this->savuser; |
|
176 | - $langs=$this->savlangs; |
|
177 | - $db=$this->savdb; |
|
173 | + global $conf, $user, $langs, $db; |
|
174 | + $conf = $this->savconf; |
|
175 | + $user = $this->savuser; |
|
176 | + $langs = $this->savlangs; |
|
177 | + $db = $this->savdb; |
|
178 | 178 | |
179 | - $localobject=new Commande($this->savdb); |
|
179 | + $localobject = new Commande($this->savdb); |
|
180 | 180 | $localobject->fetch(1); |
181 | 181 | |
182 | - $result=$localobject->fetch_thirdparty(); |
|
182 | + $result = $localobject->fetch_thirdparty(); |
|
183 | 183 | |
184 | 184 | print __METHOD__." result=".$result."\n"; |
185 | - $this->assertLessThanOrEqual($result,0); |
|
185 | + $this->assertLessThanOrEqual($result, 0); |
|
186 | 186 | return $result; |
187 | 187 | } |
188 | 188 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | $user->getrights(); |
40 | 40 | } |
41 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
41 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | parent::__construct(); |
67 | 67 | |
68 | 68 | //$this->sharedFixture |
69 | - global $conf,$user,$langs,$db; |
|
70 | - $this->savconf=$conf; |
|
71 | - $this->savuser=$user; |
|
72 | - $this->savlangs=$langs; |
|
73 | - $this->savdb=$db; |
|
69 | + global $conf, $user, $langs, $db; |
|
70 | + $this->savconf = $conf; |
|
71 | + $this->savuser = $user; |
|
72 | + $this->savlangs = $langs; |
|
73 | + $this->savdb = $db; |
|
74 | 74 | |
75 | 75 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
76 | 76 | //print " - db ".$db->db; |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | // Static methods |
81 | 81 | public static function setUpBeforeClass() |
82 | 82 | { |
83 | - global $conf,$user,$langs,$db; |
|
84 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
83 | + global $conf, $user, $langs, $db; |
|
84 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
85 | 85 | |
86 | 86 | if (empty($conf->global->MAIN_MODULE_SUPPLIERPROPOSAL)) { print "\n".__METHOD__." module Supplier proposal must be enabled.\n"; die(); } |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // tear down after class |
92 | 92 | public static function tearDownAfterClass() |
93 | 93 | { |
94 | - global $conf,$user,$langs,$db; |
|
94 | + global $conf, $user, $langs, $db; |
|
95 | 95 | $db->rollback(); |
96 | 96 | |
97 | 97 | print __METHOD__."\n"; |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function setUp() |
106 | 106 | { |
107 | - global $conf,$user,$langs,$db; |
|
108 | - $conf=$this->savconf; |
|
109 | - $user=$this->savuser; |
|
110 | - $langs=$this->savlangs; |
|
111 | - $db=$this->savdb; |
|
107 | + global $conf, $user, $langs, $db; |
|
108 | + $conf = $this->savconf; |
|
109 | + $user = $this->savuser; |
|
110 | + $langs = $this->savlangs; |
|
111 | + $db = $this->savdb; |
|
112 | 112 | |
113 | 113 | print __METHOD__."\n"; |
114 | 114 | //print $db->getVersion()."\n"; |
@@ -135,15 +135,15 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function testSupplierProposalCreate() |
137 | 137 | { |
138 | - global $conf,$user,$langs,$db; |
|
139 | - $conf=$this->savconf; |
|
140 | - $user=$this->savuser; |
|
141 | - $langs=$this->savlangs; |
|
142 | - $db=$this->savdb; |
|
138 | + global $conf, $user, $langs, $db; |
|
139 | + $conf = $this->savconf; |
|
140 | + $user = $this->savuser; |
|
141 | + $langs = $this->savlangs; |
|
142 | + $db = $this->savdb; |
|
143 | 143 | |
144 | - $localobject=new SupplierProposal($this->savdb); |
|
144 | + $localobject = new SupplierProposal($this->savdb); |
|
145 | 145 | $localobject->initAsSpecimen(); |
146 | - $result=$localobject->create($user); |
|
146 | + $result = $localobject->create($user); |
|
147 | 147 | |
148 | 148 | $this->assertLessThan($result, 0); |
149 | 149 | print __METHOD__." result=".$result."\n"; |
@@ -161,14 +161,14 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function testSupplierProposalFetch($id) |
163 | 163 | { |
164 | - global $conf,$user,$langs,$db; |
|
165 | - $conf=$this->savconf; |
|
166 | - $user=$this->savuser; |
|
167 | - $langs=$this->savlangs; |
|
168 | - $db=$this->savdb; |
|
164 | + global $conf, $user, $langs, $db; |
|
165 | + $conf = $this->savconf; |
|
166 | + $user = $this->savuser; |
|
167 | + $langs = $this->savlangs; |
|
168 | + $db = $this->savdb; |
|
169 | 169 | |
170 | - $localobject=new SupplierProposal($this->savdb); |
|
171 | - $result=$localobject->fetch($id); |
|
170 | + $localobject = new SupplierProposal($this->savdb); |
|
171 | + $result = $localobject->fetch($id); |
|
172 | 172 | |
173 | 173 | $this->assertLessThan($result, 0); |
174 | 174 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function testSupplierProposalAddLine($localobject) |
188 | 188 | { |
189 | - global $conf,$user,$langs,$db; |
|
190 | - $conf=$this->savconf; |
|
191 | - $user=$this->savuser; |
|
192 | - $langs=$this->savlangs; |
|
193 | - $db=$this->savdb; |
|
189 | + global $conf, $user, $langs, $db; |
|
190 | + $conf = $this->savconf; |
|
191 | + $user = $this->savuser; |
|
192 | + $langs = $this->savlangs; |
|
193 | + $db = $this->savdb; |
|
194 | 194 | |
195 | 195 | $localobject->fetch_thirdparty(); |
196 | - $result=$localobject->addline('Added line', 10, 2, 19.6); |
|
196 | + $result = $localobject->addline('Added line', 10, 2, 19.6); |
|
197 | 197 | |
198 | 198 | $this->assertLessThan($result, 0); |
199 | 199 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function testSupplierProposalValid($localobject) |
213 | 213 | { |
214 | - global $conf,$user,$langs,$db; |
|
215 | - $conf=$this->savconf; |
|
216 | - $user=$this->savuser; |
|
217 | - $langs=$this->savlangs; |
|
218 | - $db=$this->savdb; |
|
214 | + global $conf, $user, $langs, $db; |
|
215 | + $conf = $this->savconf; |
|
216 | + $user = $this->savuser; |
|
217 | + $langs = $this->savlangs; |
|
218 | + $db = $this->savdb; |
|
219 | 219 | |
220 | - $result=$localobject->valid($user); |
|
220 | + $result = $localobject->valid($user); |
|
221 | 221 | |
222 | 222 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
223 | 223 | $this->assertLessThan($result, 0); |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function testSupplierProposalOther($localobject) |
237 | 237 | { |
238 | - global $conf,$user,$langs,$db; |
|
239 | - $conf=$this->savconf; |
|
240 | - $user=$this->savuser; |
|
241 | - $langs=$this->savlangs; |
|
242 | - $db=$this->savdb; |
|
238 | + global $conf, $user, $langs, $db; |
|
239 | + $conf = $this->savconf; |
|
240 | + $user = $this->savuser; |
|
241 | + $langs = $this->savlangs; |
|
242 | + $db = $this->savdb; |
|
243 | 243 | |
244 | 244 | /*$result=$localobject->setstatus(0); |
245 | 245 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -264,15 +264,15 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function testSupplierProposalDelete($id) |
266 | 266 | { |
267 | - global $conf,$user,$langs,$db; |
|
268 | - $conf=$this->savconf; |
|
269 | - $user=$this->savuser; |
|
270 | - $langs=$this->savlangs; |
|
271 | - $db=$this->savdb; |
|
272 | - |
|
273 | - $localobject=new SupplierProposal($this->savdb); |
|
274 | - $result=$localobject->fetch($id); |
|
275 | - $result=$localobject->delete($user); |
|
267 | + global $conf, $user, $langs, $db; |
|
268 | + $conf = $this->savconf; |
|
269 | + $user = $this->savuser; |
|
270 | + $langs = $this->savlangs; |
|
271 | + $db = $this->savdb; |
|
272 | + |
|
273 | + $localobject = new SupplierProposal($this->savdb); |
|
274 | + $result = $localobject->fetch($id); |
|
275 | + $result = $localobject->delete($user); |
|
276 | 276 | |
277 | 277 | print __METHOD__." id=".$id." result=".$result."\n"; |
278 | 278 | $this->assertLessThan($result, 0); |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | print "PHP Version: ".phpversion()."\n"; |
27 | -print "Memory: ". ini_get('memory_limit')."\n"; |
|
27 | +print "Memory: ".ini_get('memory_limit')."\n"; |
|
28 | 28 | |
29 | -global $conf,$user,$langs,$db; |
|
29 | +global $conf, $user, $langs, $db; |
|
30 | 30 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
31 | 31 | //require_once 'PHPUnit/Autoload.php'; |
32 | 32 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
33 | -print 'DOL_MAIN_URL_ROOT='.DOL_MAIN_URL_ROOT."\n"; // constant will be used by other tests |
|
33 | +print 'DOL_MAIN_URL_ROOT='.DOL_MAIN_URL_ROOT."\n"; // constant will be used by other tests |
|
34 | 34 | |
35 | 35 | |
36 | 36 | if ($langs->defaultlang != 'en_US') |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | print "Error: Module member must be enabled to have significant results.\n"; |
44 | 44 | exit(1); |
45 | 45 | } |
46 | -if (! empty($conf->ldap->enabled)) |
|
46 | +if (!empty($conf->ldap->enabled)) |
|
47 | 47 | { |
48 | 48 | print "Error: LDAP module should not be enabled.\n"; |
49 | 49 | exit(1); |
50 | 50 | } |
51 | -if (! empty($conf->google->enabled)) |
|
51 | +if (!empty($conf->google->enabled)) |
|
52 | 52 | { |
53 | 53 | print "Warning: Google module should not be enabled.\n"; |
54 | 54 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $user->fetch(1); |
59 | 59 | $user->getrights(); |
60 | 60 | } |
61 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
61 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
62 | 62 | |
63 | 63 | |
64 | 64 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | require_once dirname(__FILE__).'/FormAdminTest.php'; |
241 | 241 | $suite->addTestSuite('FormAdminTest'); |
242 | 242 | |
243 | - require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer |
|
243 | + require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer |
|
244 | 244 | $suite->addTestSuite('ModulesTest'); |
245 | 245 | |
246 | 246 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $user->fetch(1); |
35 | 35 | $user->getrights(); |
36 | 36 | } |
37 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
37 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
38 | 38 | |
39 | 39 | $langs->load("main"); |
40 | 40 | |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | parent::__construct(); |
65 | 65 | |
66 | 66 | //$this->sharedFixture |
67 | - global $conf,$user,$langs,$db; |
|
68 | - $this->savconf=$conf; |
|
69 | - $this->savuser=$user; |
|
70 | - $this->savlangs=$langs; |
|
71 | - $this->savdb=$db; |
|
67 | + global $conf, $user, $langs, $db; |
|
68 | + $this->savconf = $conf; |
|
69 | + $this->savuser = $user; |
|
70 | + $this->savlangs = $langs; |
|
71 | + $this->savdb = $db; |
|
72 | 72 | |
73 | 73 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
74 | 74 | //print " - db ".$db->db; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // Static methods |
79 | 79 | public static function setUpBeforeClass() |
80 | 80 | { |
81 | - global $conf,$user,$langs,$db; |
|
81 | + global $conf, $user, $langs, $db; |
|
82 | 82 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
83 | 83 | |
84 | 84 | print __METHOD__."\n"; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | // tear down after class |
88 | 88 | public static function tearDownAfterClass() |
89 | 89 | { |
90 | - global $conf,$user,$langs,$db; |
|
90 | + global $conf, $user, $langs, $db; |
|
91 | 91 | $db->rollback(); |
92 | 92 | |
93 | 93 | print __METHOD__."\n"; |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected function setUp() |
102 | 102 | { |
103 | - global $conf,$user,$langs,$db; |
|
104 | - $conf=$this->savconf; |
|
105 | - $user=$this->savuser; |
|
106 | - $langs=$this->savlangs; |
|
107 | - $db=$this->savdb; |
|
103 | + global $conf, $user, $langs, $db; |
|
104 | + $conf = $this->savconf; |
|
105 | + $user = $this->savuser; |
|
106 | + $langs = $this->savlangs; |
|
107 | + $db = $this->savdb; |
|
108 | 108 | |
109 | 109 | print __METHOD__."\n"; |
110 | 110 | } |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function testBankAccountCreate() |
127 | 127 | { |
128 | - global $conf,$user,$langs,$db; |
|
129 | - $conf=$this->savconf; |
|
130 | - $user=$this->savuser; |
|
131 | - $langs=$this->savlangs; |
|
132 | - $db=$this->savdb; |
|
128 | + global $conf, $user, $langs, $db; |
|
129 | + $conf = $this->savconf; |
|
130 | + $user = $this->savuser; |
|
131 | + $langs = $this->savlangs; |
|
132 | + $db = $this->savdb; |
|
133 | 133 | |
134 | - $localobject=new Account($this->savdb); |
|
134 | + $localobject = new Account($this->savdb); |
|
135 | 135 | $localobject->initAsSpecimen(); |
136 | - $localobject->date_solde=dol_now(); |
|
137 | - $result=$localobject->create($user); |
|
136 | + $localobject->date_solde = dol_now(); |
|
137 | + $result = $localobject->create($user); |
|
138 | 138 | |
139 | 139 | print __METHOD__." result=".$result."\n"; |
140 | 140 | $this->assertLessThan($result, 0); |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function testBankAccountFetch($id) |
155 | 155 | { |
156 | - global $conf,$user,$langs,$db; |
|
157 | - $conf=$this->savconf; |
|
158 | - $user=$this->savuser; |
|
159 | - $langs=$this->savlangs; |
|
160 | - $db=$this->savdb; |
|
156 | + global $conf, $user, $langs, $db; |
|
157 | + $conf = $this->savconf; |
|
158 | + $user = $this->savuser; |
|
159 | + $langs = $this->savlangs; |
|
160 | + $db = $this->savdb; |
|
161 | 161 | |
162 | - $localobject=new Account($this->savdb); |
|
163 | - $result=$localobject->fetch($id); |
|
162 | + $localobject = new Account($this->savdb); |
|
163 | + $result = $localobject->fetch($id); |
|
164 | 164 | |
165 | 165 | print __METHOD__." id=".$id." result=".$result."\n"; |
166 | 166 | $this->assertLessThan($result, 0); |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function testBankAccountOther($localobject) |
181 | 181 | { |
182 | - global $conf,$user,$langs,$db; |
|
183 | - $conf=$this->savconf; |
|
184 | - $user=$this->savuser; |
|
185 | - $langs=$this->savlangs; |
|
186 | - $db=$this->savdb; |
|
182 | + global $conf, $user, $langs, $db; |
|
183 | + $conf = $this->savconf; |
|
184 | + $user = $this->savuser; |
|
185 | + $langs = $this->savlangs; |
|
186 | + $db = $this->savdb; |
|
187 | 187 | |
188 | 188 | /*$result=$localobject->setstatus(0); |
189 | 189 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function testBankAccountDelete($id) |
210 | 210 | { |
211 | - global $conf,$user,$langs,$db; |
|
212 | - $conf=$this->savconf; |
|
213 | - $user=$this->savuser; |
|
214 | - $langs=$this->savlangs; |
|
215 | - $db=$this->savdb; |
|
216 | - |
|
217 | - $localobject=new Account($this->savdb); |
|
218 | - $result=$localobject->fetch($id); |
|
219 | - $result=$localobject->delete($user); |
|
211 | + global $conf, $user, $langs, $db; |
|
212 | + $conf = $this->savconf; |
|
213 | + $user = $this->savuser; |
|
214 | + $langs = $this->savlangs; |
|
215 | + $db = $this->savdb; |
|
216 | + |
|
217 | + $localobject = new Account($this->savdb); |
|
218 | + $result = $localobject->fetch($id); |
|
219 | + $result = $localobject->delete($user); |
|
220 | 220 | |
221 | 221 | print __METHOD__." id=".$id." result=".$result."\n"; |
222 | 222 | $this->assertLessThan($result, 0); |
@@ -24,22 +24,22 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
34 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
35 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
36 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
37 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
38 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
39 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
40 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
41 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
42 | +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Class for PHPUnit tests |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | parent::__construct(); |
67 | 67 | |
68 | 68 | //$this->sharedFixture |
69 | - global $conf,$user,$langs,$db; |
|
70 | - $this->savconf=$conf; |
|
71 | - $this->savuser=$user; |
|
72 | - $this->savlangs=$langs; |
|
73 | - $this->savdb=$db; |
|
69 | + global $conf, $user, $langs, $db; |
|
70 | + $this->savconf = $conf; |
|
71 | + $this->savuser = $user; |
|
72 | + $this->savlangs = $langs; |
|
73 | + $this->savdb = $db; |
|
74 | 74 | |
75 | 75 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
76 | 76 | //print " - db ".$db->db; |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | // Static methods |
81 | 81 | public static function setUpBeforeClass() |
82 | 82 | { |
83 | - global $conf,$user,$langs,$db; |
|
83 | + global $conf, $user, $langs, $db; |
|
84 | 84 | //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
85 | 85 | |
86 | - if (! function_exists('mb_substr')) { print "\n".__METHOD__." function mb_substr must be enabled.\n"; die(); } |
|
86 | + if (!function_exists('mb_substr')) { print "\n".__METHOD__." function mb_substr must be enabled.\n"; die(); } |
|
87 | 87 | |
88 | 88 | print __METHOD__."\n"; |
89 | 89 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // tear down after class |
92 | 92 | public static function tearDownAfterClass() |
93 | 93 | { |
94 | - global $conf,$user,$langs,$db; |
|
94 | + global $conf, $user, $langs, $db; |
|
95 | 95 | //$db->rollback(); |
96 | 96 | |
97 | 97 | print __METHOD__."\n"; |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function setUp() |
106 | 106 | { |
107 | - global $conf,$user,$langs,$db; |
|
108 | - $conf=$this->savconf; |
|
109 | - $user=$this->savuser; |
|
110 | - $langs=$this->savlangs; |
|
111 | - $db=$this->savdb; |
|
107 | + global $conf, $user, $langs, $db; |
|
108 | + $conf = $this->savconf; |
|
109 | + $user = $this->savuser; |
|
110 | + $langs = $this->savlangs; |
|
111 | + $db = $this->savdb; |
|
112 | 112 | |
113 | 113 | print __METHOD__."\n"; |
114 | 114 | } |
@@ -133,18 +133,18 @@ discard block |
||
133 | 133 | { |
134 | 134 | // Nb of line is same than entry text |
135 | 135 | |
136 | - $input="yahoo.com"; |
|
137 | - $result=isValidMXRecord($input); |
|
136 | + $input = "yahoo.com"; |
|
137 | + $result = isValidMXRecord($input); |
|
138 | 138 | print __METHOD__." result=".$result."\n"; |
139 | 139 | $this->assertEquals(1, $result); |
140 | 140 | |
141 | - $input="yhaoo.com"; |
|
142 | - $result=isValidMXRecord($input); |
|
141 | + $input = "yhaoo.com"; |
|
142 | + $result = isValidMXRecord($input); |
|
143 | 143 | print __METHOD__." result=".$result."\n"; |
144 | 144 | $this->assertEquals(0, $result); |
145 | 145 | |
146 | - $input="dolibarr.fr"; |
|
147 | - $result=isValidMXRecord($input); |
|
146 | + $input = "dolibarr.fr"; |
|
147 | + $result = isValidMXRecord($input); |
|
148 | 148 | print __METHOD__." result=".$result."\n"; |
149 | 149 | $this->assertEquals(0, $result); |
150 | 150 | } |
@@ -158,57 +158,57 @@ discard block |
||
158 | 158 | { |
159 | 159 | // Nb of line is same than entry text |
160 | 160 | |
161 | - $input="aaaa"; |
|
162 | - $result=dolGetFirstLineOfText($input); |
|
161 | + $input = "aaaa"; |
|
162 | + $result = dolGetFirstLineOfText($input); |
|
163 | 163 | print __METHOD__." result=".$result."\n"; |
164 | 164 | $this->assertEquals("aaaa", $result); |
165 | 165 | |
166 | - $input="aaaa\nbbbbbbbbbbbb\n"; |
|
167 | - $result=dolGetFirstLineOfText($input, 2); |
|
166 | + $input = "aaaa\nbbbbbbbbbbbb\n"; |
|
167 | + $result = dolGetFirstLineOfText($input, 2); |
|
168 | 168 | print __METHOD__." result=".$result."\n"; |
169 | 169 | $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); |
170 | 170 | |
171 | - $input="aaaa<br>bbbbbbbbbbbb<br>"; |
|
172 | - $result=dolGetFirstLineOfText($input, 2); |
|
171 | + $input = "aaaa<br>bbbbbbbbbbbb<br>"; |
|
172 | + $result = dolGetFirstLineOfText($input, 2); |
|
173 | 173 | print __METHOD__." result=".$result."\n"; |
174 | 174 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result); |
175 | 175 | |
176 | 176 | // Nb of line is lower |
177 | 177 | |
178 | - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
179 | - $result=dolGetFirstLineOfText($input); |
|
178 | + $input = "aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
179 | + $result = dolGetFirstLineOfText($input); |
|
180 | 180 | print __METHOD__." result=".$result."\n"; |
181 | 181 | $this->assertEquals("aaaa...", $result); |
182 | 182 | |
183 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
184 | - $result=dolGetFirstLineOfText($input); |
|
183 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
184 | + $result = dolGetFirstLineOfText($input); |
|
185 | 185 | print __METHOD__." result=".$result."\n"; |
186 | 186 | $this->assertEquals("aaaa...", $result); |
187 | 187 | |
188 | - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
189 | - $result=dolGetFirstLineOfText($input, 2); |
|
188 | + $input = "aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
189 | + $result = dolGetFirstLineOfText($input, 2); |
|
190 | 190 | print __METHOD__." result=".$result."\n"; |
191 | 191 | $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); |
192 | 192 | |
193 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
194 | - $result=dolGetFirstLineOfText($input, 2); |
|
193 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
194 | + $result = dolGetFirstLineOfText($input, 2); |
|
195 | 195 | print __METHOD__." result=".$result."\n"; |
196 | 196 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result); |
197 | 197 | |
198 | 198 | // Nb of line is higher |
199 | 199 | |
200 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc"; |
|
201 | - $result=dolGetFirstLineOfText($input, 100); |
|
200 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc"; |
|
201 | + $result = dolGetFirstLineOfText($input, 100); |
|
202 | 202 | print __METHOD__." result=".$result."\n"; |
203 | 203 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); |
204 | 204 | |
205 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
206 | - $result=dolGetFirstLineOfText($input, 100); |
|
205 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
206 | + $result = dolGetFirstLineOfText($input, 100); |
|
207 | 207 | print __METHOD__." result=".$result."\n"; |
208 | 208 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); |
209 | 209 | |
210 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n"; |
|
211 | - $result=dolGetFirstLineOfText($input, 100); |
|
210 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n"; |
|
211 | + $result = dolGetFirstLineOfText($input, 100); |
|
212 | 212 | print __METHOD__." result=".$result."\n"; |
213 | 213 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); |
214 | 214 | } |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | var_dump($tmp); |
230 | 230 | */ |
231 | 231 | |
232 | - $result=dol_buildpath('/google/oauth2callback.php', 2); |
|
232 | + $result = dol_buildpath('/google/oauth2callback.php', 2); |
|
233 | 233 | print __METHOD__." result=".$result."\n"; |
234 | 234 | $this->assertStringStartsWith('http', $result); |
235 | 235 | |
236 | - $result=dol_buildpath('/google/oauth2callback.php', 3); |
|
236 | + $result = dol_buildpath('/google/oauth2callback.php', 3); |
|
237 | 237 | print __METHOD__." result=".$result."\n"; |
238 | 238 | $this->assertStringStartsWith('http', $result); |
239 | 239 | } |
@@ -247,81 +247,81 @@ discard block |
||
247 | 247 | public function testGetBrowserInfo() |
248 | 248 | { |
249 | 249 | // MSIE 5.0 |
250 | - $user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; |
|
251 | - $tmp=getBrowserInfo($user_agent); |
|
252 | - $this->assertEquals('ie',$tmp['browsername']); |
|
253 | - $this->assertEquals('5.0',$tmp['browserversion']); |
|
250 | + $user_agent = 'Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; |
|
251 | + $tmp = getBrowserInfo($user_agent); |
|
252 | + $this->assertEquals('ie', $tmp['browsername']); |
|
253 | + $this->assertEquals('5.0', $tmp['browserversion']); |
|
254 | 254 | $this->assertEmpty($tmp['phone']); |
255 | 255 | $this->assertFalse($tmp['tablet']); |
256 | 256 | $this->assertEquals('classic', $tmp['layout']); |
257 | 257 | |
258 | 258 | // Firefox 0.9.1 |
259 | - $user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; |
|
260 | - $tmp=getBrowserInfo($user_agent); |
|
261 | - $this->assertEquals('firefox',$tmp['browsername']); |
|
262 | - $this->assertEquals('0.9.1',$tmp['browserversion']); |
|
259 | + $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; |
|
260 | + $tmp = getBrowserInfo($user_agent); |
|
261 | + $this->assertEquals('firefox', $tmp['browsername']); |
|
262 | + $this->assertEquals('0.9.1', $tmp['browserversion']); |
|
263 | 263 | $this->assertEmpty($tmp['phone']); |
264 | 264 | $this->assertFalse($tmp['tablet']); |
265 | 265 | $this->assertEquals('classic', $tmp['layout']); |
266 | 266 | |
267 | - $user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]'; |
|
268 | - $tmp=getBrowserInfo($user_agent); |
|
269 | - $this->assertEquals('opera',$tmp['browsername']); |
|
270 | - $this->assertEquals('6.03',$tmp['browserversion']); |
|
267 | + $user_agent = 'Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]'; |
|
268 | + $tmp = getBrowserInfo($user_agent); |
|
269 | + $this->assertEquals('opera', $tmp['browsername']); |
|
270 | + $this->assertEquals('6.03', $tmp['browserversion']); |
|
271 | 271 | $this->assertEmpty($tmp['phone']); |
272 | 272 | $this->assertFalse($tmp['tablet']); |
273 | 273 | $this->assertEquals('classic', $tmp['layout']); |
274 | 274 | |
275 | - $user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21'; |
|
276 | - $tmp=getBrowserInfo($user_agent); |
|
277 | - $this->assertEquals('chrome',$tmp['browsername']); |
|
278 | - $this->assertEquals('19.0.1042.0',$tmp['browserversion']); |
|
275 | + $user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21'; |
|
276 | + $tmp = getBrowserInfo($user_agent); |
|
277 | + $this->assertEquals('chrome', $tmp['browsername']); |
|
278 | + $this->assertEquals('19.0.1042.0', $tmp['browserversion']); |
|
279 | 279 | $this->assertEmpty($tmp['phone']); |
280 | 280 | $this->assertFalse($tmp['tablet']); |
281 | 281 | $this->assertEquals('classic', $tmp['layout']); |
282 | 282 | |
283 | - $user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)'; |
|
284 | - $tmp=getBrowserInfo($user_agent); |
|
285 | - $this->assertEquals('chrome',$tmp['browsername']); |
|
286 | - $this->assertEquals('17.0.963.56',$tmp['browserversion']); |
|
283 | + $user_agent = 'chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)'; |
|
284 | + $tmp = getBrowserInfo($user_agent); |
|
285 | + $this->assertEquals('chrome', $tmp['browsername']); |
|
286 | + $this->assertEquals('17.0.963.56', $tmp['browserversion']); |
|
287 | 287 | $this->assertEmpty($tmp['phone']); |
288 | 288 | $this->assertFalse($tmp['tablet']); |
289 | 289 | $this->assertEquals('classic', $tmp['layout']); |
290 | 290 | |
291 | - $user_agent ='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1'; |
|
292 | - $tmp=getBrowserInfo($user_agent); |
|
293 | - $this->assertEquals('safari',$tmp['browsername']); |
|
294 | - $this->assertEquals('533.21.1',$tmp['browserversion']); |
|
291 | + $user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1'; |
|
292 | + $tmp = getBrowserInfo($user_agent); |
|
293 | + $this->assertEquals('safari', $tmp['browsername']); |
|
294 | + $this->assertEquals('533.21.1', $tmp['browserversion']); |
|
295 | 295 | $this->assertEmpty($tmp['phone']); |
296 | 296 | $this->assertFalse($tmp['tablet']); |
297 | 297 | $this->assertEquals('classic', $tmp['layout']); |
298 | 298 | |
299 | 299 | //Internet Explorer 11 |
300 | 300 | $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; |
301 | - $tmp=getBrowserInfo($user_agent); |
|
302 | - $this->assertEquals('ie',$tmp['browsername']); |
|
303 | - $this->assertEquals('11.0',$tmp['browserversion']); |
|
301 | + $tmp = getBrowserInfo($user_agent); |
|
302 | + $this->assertEquals('ie', $tmp['browsername']); |
|
303 | + $this->assertEquals('11.0', $tmp['browserversion']); |
|
304 | 304 | $this->assertEmpty($tmp['phone']); |
305 | 305 | $this->assertFalse($tmp['tablet']); |
306 | 306 | $this->assertEquals('classic', $tmp['layout']); |
307 | 307 | |
308 | 308 | //Internet Explorer 11 bis |
309 | 309 | $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko'; |
310 | - $tmp=getBrowserInfo($user_agent); |
|
311 | - $this->assertEquals('ie',$tmp['browsername']); |
|
312 | - $this->assertEquals('11.0',$tmp['browserversion']); |
|
310 | + $tmp = getBrowserInfo($user_agent); |
|
311 | + $this->assertEquals('ie', $tmp['browsername']); |
|
312 | + $this->assertEquals('11.0', $tmp['browserversion']); |
|
313 | 313 | $this->assertEmpty($tmp['phone']); |
314 | 314 | $this->assertFalse($tmp['tablet']); |
315 | 315 | $this->assertEquals('classic', $tmp['layout']); |
316 | 316 | |
317 | 317 | //iPad |
318 | 318 | $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'; |
319 | - $tmp=getBrowserInfo($user_agent); |
|
320 | - $this->assertEquals('safari',$tmp['browsername']); |
|
321 | - $this->assertEquals('8536.25',$tmp['browserversion']); |
|
322 | - $this->assertEquals('ios',$tmp['browseros']); |
|
323 | - $this->assertEquals('tablet',$tmp['layout']); |
|
324 | - $this->assertEquals('iphone',$tmp['phone']); |
|
319 | + $tmp = getBrowserInfo($user_agent); |
|
320 | + $this->assertEquals('safari', $tmp['browsername']); |
|
321 | + $this->assertEquals('8536.25', $tmp['browserversion']); |
|
322 | + $this->assertEquals('ios', $tmp['browseros']); |
|
323 | + $this->assertEquals('tablet', $tmp['layout']); |
|
324 | + $this->assertEquals('iphone', $tmp['phone']); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
@@ -384,64 +384,64 @@ discard block |
||
384 | 384 | public function testDolTextIsHtml() |
385 | 385 | { |
386 | 386 | // True |
387 | - $input='<html>xxx</html>'; |
|
388 | - $after=dol_textishtml($input); |
|
387 | + $input = '<html>xxx</html>'; |
|
388 | + $after = dol_textishtml($input); |
|
389 | 389 | $this->assertTrue($after, 'Test with html tag'); |
390 | - $input='<body>xxx</body>'; |
|
391 | - $after=dol_textishtml($input); |
|
390 | + $input = '<body>xxx</body>'; |
|
391 | + $after = dol_textishtml($input); |
|
392 | 392 | $this->assertTrue($after, 'Test with body tag'); |
393 | - $input='xxx <b>yyy</b> zzz'; |
|
394 | - $after=dol_textishtml($input); |
|
393 | + $input = 'xxx <b>yyy</b> zzz'; |
|
394 | + $after = dol_textishtml($input); |
|
395 | 395 | $this->assertTrue($after, 'Test with b tag'); |
396 | - $input='xxx <u>yyy</u> zzz'; |
|
397 | - $after=dol_textishtml($input); |
|
396 | + $input = 'xxx <u>yyy</u> zzz'; |
|
397 | + $after = dol_textishtml($input); |
|
398 | 398 | $this->assertTrue($after, 'Test with u tag'); |
399 | - $input='text with <div>some div</div>'; |
|
400 | - $after=dol_textishtml($input); |
|
399 | + $input = 'text with <div>some div</div>'; |
|
400 | + $after = dol_textishtml($input); |
|
401 | 401 | $this->assertTrue($after, 'Test with div tag'); |
402 | - $input='text with HTML entities'; |
|
403 | - $after=dol_textishtml($input); |
|
402 | + $input = 'text with HTML entities'; |
|
403 | + $after = dol_textishtml($input); |
|
404 | 404 | $this->assertTrue($after, 'Test with entities tag'); |
405 | - $input='xxx<br>'; |
|
406 | - $after=dol_textishtml($input); |
|
405 | + $input = 'xxx<br>'; |
|
406 | + $after = dol_textishtml($input); |
|
407 | 407 | $this->assertTrue($after, 'Test with entities br'); |
408 | - $input='xxx<br >'; |
|
409 | - $after=dol_textishtml($input); |
|
408 | + $input = 'xxx<br >'; |
|
409 | + $after = dol_textishtml($input); |
|
410 | 410 | $this->assertTrue($after, 'Test with entities br'); |
411 | - $input='xxx<br style="eee">'; |
|
412 | - $after=dol_textishtml($input); |
|
411 | + $input = 'xxx<br style="eee">'; |
|
412 | + $after = dol_textishtml($input); |
|
413 | 413 | $this->assertTrue($after, 'Test with entities br and attributes'); |
414 | - $input='xxx<br style="eee" >'; |
|
415 | - $after=dol_textishtml($input); |
|
414 | + $input = 'xxx<br style="eee" >'; |
|
415 | + $after = dol_textishtml($input); |
|
416 | 416 | $this->assertTrue($after, 'Test with entities br and attributes bis'); |
417 | - $input='<h2>abc</h2>'; |
|
418 | - $after=dol_textishtml($input); |
|
417 | + $input = '<h2>abc</h2>'; |
|
418 | + $after = dol_textishtml($input); |
|
419 | 419 | $this->assertTrue($after, 'Test with entities h2'); |
420 | - $input='<img id="abc" src="https://xxx.com/aaa/image.png" />'; |
|
421 | - $after=dol_textishtml($input); |
|
420 | + $input = '<img id="abc" src="https://xxx.com/aaa/image.png" />'; |
|
421 | + $after = dol_textishtml($input); |
|
422 | 422 | $this->assertTrue($after, 'Test with img tag'); |
423 | - $input='<a class="azerty" href="https://xxx.com/aaa/image.png" />'; |
|
424 | - $after=dol_textishtml($input); |
|
423 | + $input = '<a class="azerty" href="https://xxx.com/aaa/image.png" />'; |
|
424 | + $after = dol_textishtml($input); |
|
425 | 425 | $this->assertTrue($after, 'Test with a tag'); |
426 | - $input='This is a text with html spaces'; |
|
427 | - $after=dol_textishtml($input); |
|
426 | + $input = 'This is a text with html spaces'; |
|
427 | + $after = dol_textishtml($input); |
|
428 | 428 | $this->assertTrue($after, 'Test with a '); |
429 | - $input='This is a text with accent é'; |
|
430 | - $after=dol_textishtml($input); |
|
429 | + $input = 'This is a text with accent é'; |
|
430 | + $after = dol_textishtml($input); |
|
431 | 431 | $this->assertTrue($after, 'Test with a é'); |
432 | 432 | |
433 | 433 | // False |
434 | - $input='xxx < br>'; |
|
435 | - $after=dol_textishtml($input); |
|
434 | + $input = 'xxx < br>'; |
|
435 | + $after = dol_textishtml($input); |
|
436 | 436 | $this->assertFalse($after); |
437 | - $input='xxx <[email protected]>'; // <em> is html, <em... is not |
|
438 | - $after=dol_textishtml($input); |
|
437 | + $input = 'xxx <[email protected]>'; // <em> is html, <em... is not |
|
438 | + $after = dol_textishtml($input); |
|
439 | 439 | $this->assertFalse($after); |
440 | - $input='xxx <brstyle="ee">'; |
|
441 | - $after=dol_textishtml($input); |
|
440 | + $input = 'xxx <brstyle="ee">'; |
|
441 | + $after = dol_textishtml($input); |
|
442 | 442 | $this->assertFalse($after); |
443 | - $input='This is a text with html comments <!-- comment -->'; // we suppose this is not enough to be html content |
|
444 | - $after=dol_textishtml($input); |
|
443 | + $input = 'This is a text with html comments <!-- comment -->'; // we suppose this is not enough to be html content |
|
444 | + $after = dol_textishtml($input); |
|
445 | 445 | $this->assertFalse($after); |
446 | 446 | } |
447 | 447 | |
@@ -453,33 +453,33 @@ discard block |
||
453 | 453 | */ |
454 | 454 | public function testDolHtmlCleanLastBr() |
455 | 455 | { |
456 | - $input="A string\n"; |
|
457 | - $after=dol_htmlcleanlastbr($input); |
|
458 | - $this->assertEquals("A string",$after); |
|
456 | + $input = "A string\n"; |
|
457 | + $after = dol_htmlcleanlastbr($input); |
|
458 | + $this->assertEquals("A string", $after); |
|
459 | 459 | |
460 | - $input="A string first\nA string second\n"; |
|
461 | - $after=dol_htmlcleanlastbr($input); |
|
462 | - $this->assertEquals("A string first\nA string second",$after); |
|
460 | + $input = "A string first\nA string second\n"; |
|
461 | + $after = dol_htmlcleanlastbr($input); |
|
462 | + $this->assertEquals("A string first\nA string second", $after); |
|
463 | 463 | |
464 | - $input="A string\n\n\n"; |
|
465 | - $after=dol_htmlcleanlastbr($input); |
|
466 | - $this->assertEquals("A string",$after); |
|
464 | + $input = "A string\n\n\n"; |
|
465 | + $after = dol_htmlcleanlastbr($input); |
|
466 | + $this->assertEquals("A string", $after); |
|
467 | 467 | |
468 | - $input="A string<br>"; |
|
469 | - $after=dol_htmlcleanlastbr($input); |
|
470 | - $this->assertEquals("A string",$after); |
|
468 | + $input = "A string<br>"; |
|
469 | + $after = dol_htmlcleanlastbr($input); |
|
470 | + $this->assertEquals("A string", $after); |
|
471 | 471 | |
472 | - $input="A string first<br>\nA string second<br>"; |
|
473 | - $after=dol_htmlcleanlastbr($input); |
|
474 | - $this->assertEquals("A string first<br>\nA string second",$after); |
|
472 | + $input = "A string first<br>\nA string second<br>"; |
|
473 | + $after = dol_htmlcleanlastbr($input); |
|
474 | + $this->assertEquals("A string first<br>\nA string second", $after); |
|
475 | 475 | |
476 | - $input="A string\n<br type=\"_moz\" />\n"; |
|
477 | - $after=dol_htmlcleanlastbr($input); |
|
478 | - $this->assertEquals("A string",$after); |
|
476 | + $input = "A string\n<br type=\"_moz\" />\n"; |
|
477 | + $after = dol_htmlcleanlastbr($input); |
|
478 | + $this->assertEquals("A string", $after); |
|
479 | 479 | |
480 | - $input="A string\n<br><br />\n\n"; |
|
481 | - $after=dol_htmlcleanlastbr($input); |
|
482 | - $this->assertEquals("A string",$after); |
|
480 | + $input = "A string\n<br><br />\n\n"; |
|
481 | + $after = dol_htmlcleanlastbr($input); |
|
482 | + $this->assertEquals("A string", $after); |
|
483 | 483 | |
484 | 484 | return true; |
485 | 485 | } |
@@ -491,17 +491,17 @@ discard block |
||
491 | 491 | */ |
492 | 492 | public function testDolConcat() |
493 | 493 | { |
494 | - $text1="A string 1"; $text2="A string 2"; // text 1 and 2 are text, concat need only \n |
|
495 | - $after=dol_concatdesc($text1, $text2); |
|
496 | - $this->assertEquals("A string 1\nA string 2",$after); |
|
494 | + $text1 = "A string 1"; $text2 = "A string 2"; // text 1 and 2 are text, concat need only \n |
|
495 | + $after = dol_concatdesc($text1, $text2); |
|
496 | + $this->assertEquals("A string 1\nA string 2", $after); |
|
497 | 497 | |
498 | - $text1="A<br>string 1"; $text2="A string 2"; // text 1 is html, concat need <br>\n |
|
499 | - $after=dol_concatdesc($text1, $text2); |
|
500 | - $this->assertEquals("A<br>string 1<br>\nA string 2",$after); |
|
498 | + $text1 = "A<br>string 1"; $text2 = "A string 2"; // text 1 is html, concat need <br>\n |
|
499 | + $after = dol_concatdesc($text1, $text2); |
|
500 | + $this->assertEquals("A<br>string 1<br>\nA string 2", $after); |
|
501 | 501 | |
502 | - $text1="A string 1"; $text2="A <b>string</b> 2"; // text 2 is html, concat need <br>\n |
|
503 | - $after=dol_concatdesc($text1, $text2); |
|
504 | - $this->assertEquals("A string 1<br>\nA <b>string</b> 2",$after); |
|
502 | + $text1 = "A string 1"; $text2 = "A <b>string</b> 2"; // text 2 is html, concat need <br>\n |
|
503 | + $after = dol_concatdesc($text1, $text2); |
|
504 | + $this->assertEquals("A string 1<br>\nA <b>string</b> 2", $after); |
|
505 | 505 | |
506 | 506 | return true; |
507 | 507 | } |
@@ -514,49 +514,49 @@ discard block |
||
514 | 514 | */ |
515 | 515 | public function testDolStringNohtmltag() |
516 | 516 | { |
517 | - $text="A\nstring\n\nand more\n"; |
|
518 | - $after=dol_string_nohtmltag($text,0); |
|
519 | - $this->assertEquals("A\nstring\n\nand more",$after,"test1a"); |
|
517 | + $text = "A\nstring\n\nand more\n"; |
|
518 | + $after = dol_string_nohtmltag($text, 0); |
|
519 | + $this->assertEquals("A\nstring\n\nand more", $after, "test1a"); |
|
520 | 520 | |
521 | - $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
522 | - $after=dol_string_nohtmltag($text, 0); |
|
523 | - $this->assertEquals("A string\n\n\n\n\nwith html tag",$after,"test2a 2 br and 3 \n give 5 \n"); |
|
521 | + $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
522 | + $after = dol_string_nohtmltag($text, 0); |
|
523 | + $this->assertEquals("A string\n\n\n\n\nwith html tag", $after, "test2a 2 br and 3 \n give 5 \n"); |
|
524 | 524 | |
525 | - $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
526 | - $after=dol_string_nohtmltag($text, 1); |
|
527 | - $this->assertEquals("A string with html tag",$after,"test2b 2 br and 3 \n give 1 space"); |
|
525 | + $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
526 | + $after = dol_string_nohtmltag($text, 1); |
|
527 | + $this->assertEquals("A string with html tag", $after, "test2b 2 br and 3 \n give 1 space"); |
|
528 | 528 | |
529 | - $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
530 | - $after=dol_string_nohtmltag($text, 2); |
|
531 | - $this->assertEquals("A string\n\nwith html tag",$after,"test2c 2 br and 3 \n give 2 \n"); |
|
529 | + $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
530 | + $after = dol_string_nohtmltag($text, 2); |
|
531 | + $this->assertEquals("A string\n\nwith html tag", $after, "test2c 2 br and 3 \n give 2 \n"); |
|
532 | 532 | |
533 | - $text="A string<br>Another string"; |
|
534 | - $after=dol_string_nohtmltag($text,0); |
|
535 | - $this->assertEquals("A string\nAnother string",$after,"test4"); |
|
533 | + $text = "A string<br>Another string"; |
|
534 | + $after = dol_string_nohtmltag($text, 0); |
|
535 | + $this->assertEquals("A string\nAnother string", $after, "test4"); |
|
536 | 536 | |
537 | - $text="A string<br>Another string"; |
|
538 | - $after=dol_string_nohtmltag($text,1); |
|
539 | - $this->assertEquals("A string Another string",$after,"test5"); |
|
537 | + $text = "A string<br>Another string"; |
|
538 | + $after = dol_string_nohtmltag($text, 1); |
|
539 | + $this->assertEquals("A string Another string", $after, "test5"); |
|
540 | 540 | |
541 | - $text='<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>'; |
|
542 | - $after=dol_string_nohtmltag($text,1); |
|
543 | - $this->assertEquals("ABC",$after,"test6"); |
|
541 | + $text = '<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>'; |
|
542 | + $after = dol_string_nohtmltag($text, 1); |
|
543 | + $this->assertEquals("ABC", $after, "test6"); |
|
544 | 544 | |
545 | - $text='<a href="/myurl" title="<u>Afficher projet</u>">DEF</a>'; |
|
546 | - $after=dol_string_nohtmltag($text,1); |
|
547 | - $this->assertEquals("DEF",$after,"test7"); |
|
545 | + $text = '<a href="/myurl" title="<u>Afficher projet</u>">DEF</a>'; |
|
546 | + $after = dol_string_nohtmltag($text, 1); |
|
547 | + $this->assertEquals("DEF", $after, "test7"); |
|
548 | 548 | |
549 | - $text='<a href="/myurl" title="<u>A title</u>">HIJ</a>'; |
|
550 | - $after=dol_string_nohtmltag($text,0); |
|
551 | - $this->assertEquals("HIJ",$after,"test8"); |
|
549 | + $text = '<a href="/myurl" title="<u>A title</u>">HIJ</a>'; |
|
550 | + $after = dol_string_nohtmltag($text, 0); |
|
551 | + $this->assertEquals("HIJ", $after, "test8"); |
|
552 | 552 | |
553 | - $text="A <b>string<b>\n\nwith html tag and '<' chars<br>\n"; |
|
554 | - $after=dol_string_nohtmltag($text, 0); |
|
555 | - $this->assertEquals("A string\n\nwith html tag and '<' chars",$after,"test9"); |
|
553 | + $text = "A <b>string<b>\n\nwith html tag and '<' chars<br>\n"; |
|
554 | + $after = dol_string_nohtmltag($text, 0); |
|
555 | + $this->assertEquals("A string\n\nwith html tag and '<' chars", $after, "test9"); |
|
556 | 556 | |
557 | - $text="A <b>string<b>\n\nwith tag with < chars<br>\n"; |
|
558 | - $after=dol_string_nohtmltag($text, 1); |
|
559 | - $this->assertEquals("A string with tag with < chars",$after,"test10"); |
|
557 | + $text = "A <b>string<b>\n\nwith tag with < chars<br>\n"; |
|
558 | + $after = dol_string_nohtmltag($text, 1); |
|
559 | + $this->assertEquals("A string with tag with < chars", $after, "test10"); |
|
560 | 560 | |
561 | 561 | return true; |
562 | 562 | } |
@@ -572,39 +572,39 @@ discard block |
||
572 | 572 | { |
573 | 573 | // Text not already HTML |
574 | 574 | |
575 | - $input="A string\nwith a é, &, < and >."; |
|
576 | - $after=dol_htmlentitiesbr($input,0); // Add <br> before \n |
|
577 | - $this->assertEquals("A string<br>\nwith a é, &, < and >.",$after); |
|
575 | + $input = "A string\nwith a é, &, < and >."; |
|
576 | + $after = dol_htmlentitiesbr($input, 0); // Add <br> before \n |
|
577 | + $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
|
578 | 578 | |
579 | - $input="A string\nwith a é, &, < and >."; |
|
580 | - $after=dol_htmlentitiesbr($input,1); // Replace \n with <br> |
|
581 | - $this->assertEquals("A string<br>with a é, &, < and >.",$after); |
|
579 | + $input = "A string\nwith a é, &, < and >."; |
|
580 | + $after = dol_htmlentitiesbr($input, 1); // Replace \n with <br> |
|
581 | + $this->assertEquals("A string<br>with a é, &, < and >.", $after); |
|
582 | 582 | |
583 | - $input="A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
584 | - $after=dol_htmlentitiesbr($input,0); // Add <br> before \n |
|
585 | - $this->assertEquals("A string<br>\nwith a é, &, < and >.",$after); |
|
583 | + $input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
584 | + $after = dol_htmlentitiesbr($input, 0); // Add <br> before \n |
|
585 | + $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
|
586 | 586 | |
587 | - $input="A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
588 | - $after=dol_htmlentitiesbr($input,1); // Replace \n with <br> |
|
589 | - $this->assertEquals("A string<br>with a é, &, < and >.",$after); |
|
587 | + $input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
588 | + $after = dol_htmlentitiesbr($input, 1); // Replace \n with <br> |
|
589 | + $this->assertEquals("A string<br>with a é, &, < and >.", $after); |
|
590 | 590 | |
591 | 591 | // Text already HTML, so &,<,> should not be converted |
592 | 592 | |
593 | - $input="A string<br>\nwith a é, &, < and >."; |
|
594 | - $after=dol_htmlentitiesbr($input); |
|
595 | - $this->assertEquals("A string<br>\nwith a é, &, < and >.",$after); |
|
593 | + $input = "A string<br>\nwith a é, &, < and >."; |
|
594 | + $after = dol_htmlentitiesbr($input); |
|
595 | + $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
|
596 | 596 | |
597 | - $input="<li>\nA string with a é, &, < and >.</li>\nAnother string"; |
|
598 | - $after=dol_htmlentitiesbr($input); |
|
599 | - $this->assertEquals("<li>\nA string with a é, &, < and >.</li>\nAnother string",$after); |
|
597 | + $input = "<li>\nA string with a é, &, < and >.</li>\nAnother string"; |
|
598 | + $after = dol_htmlentitiesbr($input); |
|
599 | + $this->assertEquals("<li>\nA string with a é, &, < and >.</li>\nAnother string", $after); |
|
600 | 600 | |
601 | - $input="A string<br>\nwith a é, &, < and >.<br>"; // With some <br> at end that should be cleaned |
|
602 | - $after=dol_htmlentitiesbr($input); |
|
603 | - $this->assertEquals("A string<br>\nwith a é, &, < and >.",$after); |
|
601 | + $input = "A string<br>\nwith a é, &, < and >.<br>"; // With some <br> at end that should be cleaned |
|
602 | + $after = dol_htmlentitiesbr($input); |
|
603 | + $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
|
604 | 604 | |
605 | - $input="<li>\nA string with a é, &, < and >.</li>\nAnother string<br>"; // With some <br> at end that should be cleaned |
|
606 | - $after=dol_htmlentitiesbr($input); |
|
607 | - $this->assertEquals("<li>\nA string with a é, &, < and >.</li>\nAnother string",$after); |
|
605 | + $input = "<li>\nA string with a é, &, < and >.</li>\nAnother string<br>"; // With some <br> at end that should be cleaned |
|
606 | + $after = dol_htmlentitiesbr($input); |
|
607 | + $this->assertEquals("<li>\nA string with a é, &, < and >.</li>\nAnother string", $after); |
|
608 | 608 | |
609 | 609 | // TODO Add test with param $removelasteolbr = 0 |
610 | 610 | |
@@ -620,19 +620,19 @@ discard block |
||
620 | 620 | public function testDolNbOfLinesBis() |
621 | 621 | { |
622 | 622 | // This is not a html string so nb of lines depends on \n |
623 | - $input="A string\nwith a é, &, < and > and bold tag.\nThird line"; |
|
624 | - $after=dol_nboflines_bis($input,0); |
|
625 | - $this->assertEquals($after,3); |
|
623 | + $input = "A string\nwith a é, &, < and > and bold tag.\nThird line"; |
|
624 | + $after = dol_nboflines_bis($input, 0); |
|
625 | + $this->assertEquals($after, 3); |
|
626 | 626 | |
627 | 627 | // This is a html string so nb of lines depends on <br> |
628 | - $input="A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line"; |
|
629 | - $after=dol_nboflines_bis($input,0); |
|
630 | - $this->assertEquals($after,1); |
|
628 | + $input = "A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line"; |
|
629 | + $after = dol_nboflines_bis($input, 0); |
|
630 | + $this->assertEquals($after, 1); |
|
631 | 631 | |
632 | 632 | // This is a html string so nb of lines depends on <br> |
633 | - $input="A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line"; |
|
634 | - $after=dol_nboflines_bis($input,0); |
|
635 | - $this->assertEquals($after,3); |
|
633 | + $input = "A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line"; |
|
634 | + $after = dol_nboflines_bis($input, 0); |
|
635 | + $this->assertEquals($after, 3); |
|
636 | 636 | |
637 | 637 | return true; |
638 | 638 | } |
@@ -647,9 +647,9 @@ discard block |
||
647 | 647 | { |
648 | 648 | // Text not already HTML |
649 | 649 | |
650 | - $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; |
|
651 | - $after=dol_string_unaccent($input); |
|
652 | - $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.",$after); |
|
650 | + $input = "A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; |
|
651 | + $after = dol_string_unaccent($input); |
|
652 | + $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.", $after); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | |
@@ -661,17 +661,17 @@ discard block |
||
661 | 661 | public function testDolUtf8Check() |
662 | 662 | { |
663 | 663 | // True |
664 | - $result=utf8_check('azerty'); |
|
664 | + $result = utf8_check('azerty'); |
|
665 | 665 | $this->assertTrue($result); |
666 | 666 | |
667 | - $file=dirname(__FILE__).'/textutf8.txt'; |
|
668 | - $filecontent=file_get_contents($file); |
|
669 | - $result=utf8_check($filecontent); |
|
667 | + $file = dirname(__FILE__).'/textutf8.txt'; |
|
668 | + $filecontent = file_get_contents($file); |
|
669 | + $result = utf8_check($filecontent); |
|
670 | 670 | $this->assertTrue($result); |
671 | 671 | |
672 | - $file=dirname(__FILE__).'/textiso.txt'; |
|
673 | - $filecontent=file_get_contents($file); |
|
674 | - $result=utf8_check($filecontent); |
|
672 | + $file = dirname(__FILE__).'/textiso.txt'; |
|
673 | + $filecontent = file_get_contents($file); |
|
674 | + $result = utf8_check($filecontent); |
|
675 | 675 | $this->assertFalse($result); |
676 | 676 | } |
677 | 677 | |
@@ -683,50 +683,50 @@ discard block |
||
683 | 683 | public function testDolTrunc() |
684 | 684 | { |
685 | 685 | // Default trunc (will add ... if truncation truncation or keep last char if only one char) |
686 | - $input="éeéeéeàa"; |
|
687 | - $after=dol_trunc($input,3); |
|
688 | - $this->assertEquals("éeé...",$after,'Test A1'); |
|
689 | - $after=dol_trunc($input,2); |
|
690 | - $this->assertEquals("ée...",$after,'Test A2'); |
|
691 | - $after=dol_trunc($input,1); |
|
692 | - $this->assertEquals("é...",$after,'Test A3'); |
|
693 | - $input="éeéeé"; |
|
694 | - $after=dol_trunc($input,3); |
|
695 | - $this->assertEquals("éeéeé",$after,'Test B1'); |
|
696 | - $after=dol_trunc($input,2); |
|
697 | - $this->assertEquals("éeéeé",$after,'Test B2'); |
|
698 | - $after=dol_trunc($input,1); |
|
699 | - $this->assertEquals("é...",$after,'Test B3'); |
|
700 | - $input="éeée"; |
|
701 | - $after=dol_trunc($input,3); |
|
702 | - $this->assertEquals("éeée",$after,'Test C1'); |
|
703 | - $after=dol_trunc($input,2); |
|
704 | - $this->assertEquals("éeée",$after,'Test C2'); |
|
705 | - $after=dol_trunc($input,1); |
|
706 | - $this->assertEquals("éeée",$after,'Test C3'); |
|
707 | - $input="éeé"; |
|
708 | - $after=dol_trunc($input,3); |
|
709 | - $this->assertEquals("éeé",$after,'Test C'); |
|
710 | - $after=dol_trunc($input,2); |
|
711 | - $this->assertEquals("éeé",$after,'Test D'); |
|
712 | - $after=dol_trunc($input,1); |
|
713 | - $this->assertEquals("éeé",$after,'Test E'); |
|
686 | + $input = "éeéeéeàa"; |
|
687 | + $after = dol_trunc($input, 3); |
|
688 | + $this->assertEquals("éeé...", $after, 'Test A1'); |
|
689 | + $after = dol_trunc($input, 2); |
|
690 | + $this->assertEquals("ée...", $after, 'Test A2'); |
|
691 | + $after = dol_trunc($input, 1); |
|
692 | + $this->assertEquals("é...", $after, 'Test A3'); |
|
693 | + $input = "éeéeé"; |
|
694 | + $after = dol_trunc($input, 3); |
|
695 | + $this->assertEquals("éeéeé", $after, 'Test B1'); |
|
696 | + $after = dol_trunc($input, 2); |
|
697 | + $this->assertEquals("éeéeé", $after, 'Test B2'); |
|
698 | + $after = dol_trunc($input, 1); |
|
699 | + $this->assertEquals("é...", $after, 'Test B3'); |
|
700 | + $input = "éeée"; |
|
701 | + $after = dol_trunc($input, 3); |
|
702 | + $this->assertEquals("éeée", $after, 'Test C1'); |
|
703 | + $after = dol_trunc($input, 2); |
|
704 | + $this->assertEquals("éeée", $after, 'Test C2'); |
|
705 | + $after = dol_trunc($input, 1); |
|
706 | + $this->assertEquals("éeée", $after, 'Test C3'); |
|
707 | + $input = "éeé"; |
|
708 | + $after = dol_trunc($input, 3); |
|
709 | + $this->assertEquals("éeé", $after, 'Test C'); |
|
710 | + $after = dol_trunc($input, 2); |
|
711 | + $this->assertEquals("éeé", $after, 'Test D'); |
|
712 | + $after = dol_trunc($input, 1); |
|
713 | + $this->assertEquals("éeé", $after, 'Test E'); |
|
714 | 714 | // Trunc with no ... |
715 | - $input="éeéeéeàa"; |
|
716 | - $after=dol_trunc($input,3,'right','UTF-8',1); |
|
717 | - $this->assertEquals("éeé",$after,'Test F'); |
|
718 | - $after=dol_trunc($input,2,'right','UTF-8',1); |
|
719 | - $this->assertEquals("ée",$after,'Test G'); |
|
720 | - $input="éeé"; |
|
721 | - $after=dol_trunc($input,3,'right','UTF-8',1); |
|
722 | - $this->assertEquals("éeé",$after,'Test H'); |
|
723 | - $after=dol_trunc($input,2,'right','UTF-8',1); |
|
724 | - $this->assertEquals("ée",$after,'Test I'); |
|
725 | - $after=dol_trunc($input,1,'right','UTF-8',1); |
|
726 | - $this->assertEquals("é",$after,'Test J'); |
|
727 | - $input="éeéeéeàa"; |
|
728 | - $after=dol_trunc($input,4,'middle'); |
|
729 | - $this->assertEquals("ée...àa",$after,'Test K'); |
|
715 | + $input = "éeéeéeàa"; |
|
716 | + $after = dol_trunc($input, 3, 'right', 'UTF-8', 1); |
|
717 | + $this->assertEquals("éeé", $after, 'Test F'); |
|
718 | + $after = dol_trunc($input, 2, 'right', 'UTF-8', 1); |
|
719 | + $this->assertEquals("ée", $after, 'Test G'); |
|
720 | + $input = "éeé"; |
|
721 | + $after = dol_trunc($input, 3, 'right', 'UTF-8', 1); |
|
722 | + $this->assertEquals("éeé", $after, 'Test H'); |
|
723 | + $after = dol_trunc($input, 2, 'right', 'UTF-8', 1); |
|
724 | + $this->assertEquals("ée", $after, 'Test I'); |
|
725 | + $after = dol_trunc($input, 1, 'right', 'UTF-8', 1); |
|
726 | + $this->assertEquals("é", $after, 'Test J'); |
|
727 | + $input = "éeéeéeàa"; |
|
728 | + $after = dol_trunc($input, 4, 'middle'); |
|
729 | + $this->assertEquals("ée...àa", $after, 'Test K'); |
|
730 | 730 | |
731 | 731 | return true; |
732 | 732 | } |
@@ -740,49 +740,49 @@ discard block |
||
740 | 740 | { |
741 | 741 | global $conf; |
742 | 742 | |
743 | - $savtz=date_default_timezone_get(); |
|
743 | + $savtz = date_default_timezone_get(); |
|
744 | 744 | |
745 | 745 | // Some test for UTC TZ |
746 | 746 | date_default_timezone_set('UTC'); |
747 | 747 | |
748 | 748 | // Check bad hours |
749 | - $result=dol_mktime(25,0,0,1,1,1970,1,1); // Error (25 hours) |
|
749 | + $result = dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1); // Error (25 hours) |
|
750 | 750 | print __METHOD__." result=".$result."\n"; |
751 | - $this->assertEquals('',$result); |
|
752 | - $result=dol_mktime(2,61,0,1,1,1970,1,1); // Error (61 minutes) |
|
751 | + $this->assertEquals('', $result); |
|
752 | + $result = dol_mktime(2, 61, 0, 1, 1, 1970, 1, 1); // Error (61 minutes) |
|
753 | 753 | print __METHOD__." result=".$result."\n"; |
754 | - $this->assertEquals('',$result); |
|
755 | - $result=dol_mktime(2,1,61,1,1,1970,1,1); // Error (61 seconds) |
|
754 | + $this->assertEquals('', $result); |
|
755 | + $result = dol_mktime(2, 1, 61, 1, 1, 1970, 1, 1); // Error (61 seconds) |
|
756 | 756 | print __METHOD__." result=".$result."\n"; |
757 | - $this->assertEquals('',$result); |
|
758 | - $result=dol_mktime(2,1,1,1,32,1970,1,1); // Error (day 32) |
|
757 | + $this->assertEquals('', $result); |
|
758 | + $result = dol_mktime(2, 1, 1, 1, 32, 1970, 1, 1); // Error (day 32) |
|
759 | 759 | print __METHOD__." result=".$result."\n"; |
760 | - $this->assertEquals('',$result); |
|
761 | - $result=dol_mktime(2,1,1,13,1,1970,1,1); // Error (month 13) |
|
760 | + $this->assertEquals('', $result); |
|
761 | + $result = dol_mktime(2, 1, 1, 13, 1, 1970, 1, 1); // Error (month 13) |
|
762 | 762 | print __METHOD__." result=".$result."\n"; |
763 | - $this->assertEquals('',$result); |
|
763 | + $this->assertEquals('', $result); |
|
764 | 764 | |
765 | - $result=dol_mktime(2,1,1,1,1,1970,1); // 1970-01-01 02:01:01 in GMT area -> 7261 |
|
765 | + $result = dol_mktime(2, 1, 1, 1, 1, 1970, 1); // 1970-01-01 02:01:01 in GMT area -> 7261 |
|
766 | 766 | print __METHOD__." result=".$result."\n"; |
767 | - $this->assertEquals(7261,$result); |
|
767 | + $this->assertEquals(7261, $result); |
|
768 | 768 | |
769 | - $result=dol_mktime(2,0,0,1,1,1970,0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
769 | + $result = dol_mktime(2, 0, 0, 1, 1, 1970, 0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
770 | 770 | print __METHOD__." result=".$result."\n"; |
771 | - $tz=getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter) |
|
772 | - $this->assertEquals(7200-($tz*3600),$result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter |
|
771 | + $tz = getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter) |
|
772 | + $this->assertEquals(7200 - ($tz * 3600), $result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter |
|
773 | 773 | |
774 | 774 | // Some test for local TZ Europe/Paris |
775 | 775 | date_default_timezone_set('Europe/Paris'); |
776 | 776 | |
777 | 777 | // Check that tz for paris in winter is used |
778 | - $result=dol_mktime(2,0,0,1,1,1970,'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
778 | + $result = dol_mktime(2, 0, 0, 1, 1, 1970, 'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
779 | 779 | print __METHOD__." result=".$result."\n"; |
780 | - $this->assertEquals(3600,$result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris |
|
780 | + $this->assertEquals(3600, $result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris |
|
781 | 781 | |
782 | 782 | // Check that daylight saving time is used |
783 | - $result=dol_mktime(2,0,0,6,1,2014,0); // 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT |
|
783 | + $result = dol_mktime(2, 0, 0, 6, 1, 2014, 0); // 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT |
|
784 | 784 | print __METHOD__." result=".$result."\n"; |
785 | - $this->assertEquals(1401588000-3600-3600,$result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer |
|
785 | + $this->assertEquals(1401588000 - 3600 - 3600, $result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer |
|
786 | 786 | |
787 | 787 | date_default_timezone_set($savtz); |
788 | 788 | } |
@@ -795,15 +795,15 @@ discard block |
||
795 | 795 | */ |
796 | 796 | public function testDolEscapeJs() |
797 | 797 | { |
798 | - $input="x&<b>#</b>,\"'"; // " will be converted into ' |
|
799 | - $result=dol_escape_js($input); |
|
800 | - $this->assertEquals("x&<b>#</b>,\'\'",$result,"Test mode=0"); |
|
798 | + $input = "x&<b>#</b>,\"'"; // " will be converted into ' |
|
799 | + $result = dol_escape_js($input); |
|
800 | + $this->assertEquals("x&<b>#</b>,\'\'", $result, "Test mode=0"); |
|
801 | 801 | |
802 | - $result=dol_escape_js($input,1); |
|
803 | - $this->assertEquals("x&<b>#</b>,\"\'",$result,"Test mode=1"); |
|
802 | + $result = dol_escape_js($input, 1); |
|
803 | + $this->assertEquals("x&<b>#</b>,\"\'", $result, "Test mode=1"); |
|
804 | 804 | |
805 | - $result=dol_escape_js($input,2); |
|
806 | - $this->assertEquals("x&<b>#</b>,\\\"'",$result,"Test mode=2"); |
|
805 | + $result = dol_escape_js($input, 2); |
|
806 | + $this->assertEquals("x&<b>#</b>,\\\"'", $result, "Test mode=2"); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | |
@@ -814,13 +814,13 @@ discard block |
||
814 | 814 | */ |
815 | 815 | public function testDolEscapeHtmlTag() |
816 | 816 | { |
817 | - $input='x&<b>#</b>,"'; // & and " are converted into html entities, <b> are removed |
|
818 | - $result=dol_escape_htmltag($input); |
|
819 | - $this->assertEquals('x&#,"',$result); |
|
817 | + $input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are removed |
|
818 | + $result = dol_escape_htmltag($input); |
|
819 | + $this->assertEquals('x&#,"', $result); |
|
820 | 820 | |
821 | - $input='x&<b>#</b>,"'; // & and " are converted into html entities, <b> are not removed |
|
822 | - $result=dol_escape_htmltag($input,1); |
|
823 | - $this->assertEquals('x&<b>#</b>,"',$result); |
|
821 | + $input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are not removed |
|
822 | + $result = dol_escape_htmltag($input, 1); |
|
823 | + $this->assertEquals('x&<b>#</b>,"', $result); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -831,30 +831,30 @@ discard block |
||
831 | 831 | */ |
832 | 832 | public function testDolFormatAddress() |
833 | 833 | { |
834 | - global $conf,$user,$langs,$db; |
|
835 | - $conf=$this->savconf; |
|
836 | - $user=$this->savuser; |
|
837 | - $langs=$this->savlangs; |
|
838 | - $db=$this->savdb; |
|
834 | + global $conf, $user, $langs, $db; |
|
835 | + $conf = $this->savconf; |
|
836 | + $user = $this->savuser; |
|
837 | + $langs = $this->savlangs; |
|
838 | + $db = $this->savdb; |
|
839 | 839 | |
840 | - $object=new Societe($db); |
|
840 | + $object = new Societe($db); |
|
841 | 841 | $object->initAsSpecimen(); |
842 | 842 | |
843 | - $object->country_code='FR'; |
|
844 | - $address=dol_format_address($object); |
|
845 | - $this->assertEquals("21 jump street\n99999 MyTown",$address); |
|
843 | + $object->country_code = 'FR'; |
|
844 | + $address = dol_format_address($object); |
|
845 | + $this->assertEquals("21 jump street\n99999 MyTown", $address); |
|
846 | 846 | |
847 | - $object->country_code='GB'; |
|
848 | - $address=dol_format_address($object); |
|
849 | - $this->assertEquals("21 jump street\nMyTown, MyState\n99999",$address); |
|
847 | + $object->country_code = 'GB'; |
|
848 | + $address = dol_format_address($object); |
|
849 | + $this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address); |
|
850 | 850 | |
851 | - $object->country_code='US'; |
|
852 | - $address=dol_format_address($object); |
|
853 | - $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address); |
|
851 | + $object->country_code = 'US'; |
|
852 | + $address = dol_format_address($object); |
|
853 | + $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); |
|
854 | 854 | |
855 | - $object->country_code='AU'; |
|
856 | - $address=dol_format_address($object); |
|
857 | - $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address); |
|
855 | + $object->country_code = 'AU'; |
|
856 | + $address = dol_format_address($object); |
|
857 | + $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | |
@@ -865,29 +865,29 @@ discard block |
||
865 | 865 | */ |
866 | 866 | public function testDolPrintPhone() |
867 | 867 | { |
868 | - global $conf,$user,$langs,$db; |
|
869 | - $conf=$this->savconf; |
|
870 | - $user=$this->savuser; |
|
871 | - $langs=$this->savlangs; |
|
872 | - $db=$this->savdb; |
|
868 | + global $conf, $user, $langs, $db; |
|
869 | + $conf = $this->savconf; |
|
870 | + $user = $this->savuser; |
|
871 | + $langs = $this->savlangs; |
|
872 | + $db = $this->savdb; |
|
873 | 873 | |
874 | - $object=new Societe($db); |
|
874 | + $object = new Societe($db); |
|
875 | 875 | $object->initAsSpecimen(); |
876 | 876 | |
877 | - $object->country_code='FR'; |
|
878 | - $phone=dol_print_phone('1234567890', $object->country_code); |
|
877 | + $object->country_code = 'FR'; |
|
878 | + $phone = dol_print_phone('1234567890', $object->country_code); |
|
879 | 879 | $this->assertEquals('<span style="margin-right: 10px;">12 34 56 78 90</span>', $phone, 'Phone for FR 1'); |
880 | 880 | |
881 | - $object->country_code='FR'; |
|
882 | - $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ''); |
|
881 | + $object->country_code = 'FR'; |
|
882 | + $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ''); |
|
883 | 883 | $this->assertEquals('<span style="margin-right: 10px;">1234567890</span>', $phone, 'Phone for FR 2'); |
884 | 884 | |
885 | - $object->country_code='FR'; |
|
886 | - $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
885 | + $object->country_code = 'FR'; |
|
886 | + $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
887 | 887 | $this->assertEquals('<span style="margin-right: 10px;">12 34 56 78 90</span>', $phone, 'Phone for FR 3'); |
888 | 888 | |
889 | - $object->country_code='CA'; |
|
890 | - $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
889 | + $object->country_code = 'CA'; |
|
890 | + $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
891 | 891 | $this->assertEquals('<span style="margin-right: 10px;">(123) 456-7890</span>', $phone, 'Phone for CA 1'); |
892 | 892 | } |
893 | 893 | |
@@ -899,26 +899,26 @@ discard block |
||
899 | 899 | */ |
900 | 900 | public function testImgPicto() |
901 | 901 | { |
902 | - $s=img_picto('title','user'); |
|
902 | + $s = img_picto('title', 'user'); |
|
903 | 903 | print __METHOD__." s=".$s."\n"; |
904 | - $this->assertContains('theme',$s,'testImgPicto1'); |
|
904 | + $this->assertContains('theme', $s, 'testImgPicto1'); |
|
905 | 905 | |
906 | - $s=img_picto('title','img.png','style="float: right"',0); |
|
906 | + $s = img_picto('title', 'img.png', 'style="float: right"', 0); |
|
907 | 907 | print __METHOD__." s=".$s."\n"; |
908 | - $this->assertContains('theme',$s,'testImgPicto2'); |
|
909 | - $this->assertContains('style="float: right"',$s,'testImgPicto2'); |
|
908 | + $this->assertContains('theme', $s, 'testImgPicto2'); |
|
909 | + $this->assertContains('style="float: right"', $s, 'testImgPicto2'); |
|
910 | 910 | |
911 | - $s=img_picto('title', '/fullpath/img.png', '', 1); |
|
911 | + $s = img_picto('title', '/fullpath/img.png', '', 1); |
|
912 | 912 | print __METHOD__." s=".$s."\n"; |
913 | - $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">',$s,'testImgPicto3'); |
|
913 | + $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto3'); |
|
914 | 914 | |
915 | - $s=img_picto('title', '/fullpath/img.png', '', true); |
|
915 | + $s = img_picto('title', '/fullpath/img.png', '', true); |
|
916 | 916 | print __METHOD__." s=".$s."\n"; |
917 | - $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">',$s,'testImgPicto4'); |
|
917 | + $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto4'); |
|
918 | 918 | |
919 | - $s=img_picto('title', 'delete', '', 0, 1); |
|
919 | + $s = img_picto('title', 'delete', '', 0, 1); |
|
920 | 920 | print __METHOD__." s=".$s."\n"; |
921 | - $this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png',$s,'testImgPicto5'); |
|
921 | + $this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png', $s, 'testImgPicto5'); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | /** |
@@ -928,10 +928,10 @@ discard block |
||
928 | 928 | */ |
929 | 929 | public function testDolNow() |
930 | 930 | { |
931 | - $now=dol_now('gmt'); |
|
932 | - $nowtzserver=dol_now('tzserver'); |
|
933 | - print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now')*3600)."\n"; |
|
934 | - $this->assertEquals(getServerTimeZoneInt('now')*3600,($nowtzserver-$now)); |
|
931 | + $now = dol_now('gmt'); |
|
932 | + $nowtzserver = dol_now('tzserver'); |
|
933 | + print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now') * 3600)."\n"; |
|
934 | + $this->assertEquals(getServerTimeZoneInt('now') * 3600, ($nowtzserver - $now)); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | /** |
@@ -941,19 +941,19 @@ discard block |
||
941 | 941 | */ |
942 | 942 | public function testVerifCond() |
943 | 943 | { |
944 | - $verifcond=verifCond('1==1'); |
|
945 | - $this->assertTrue($verifcond,'Test a true comparison'); |
|
944 | + $verifcond = verifCond('1==1'); |
|
945 | + $this->assertTrue($verifcond, 'Test a true comparison'); |
|
946 | 946 | |
947 | - $verifcond=verifCond('1==2'); |
|
948 | - $this->assertFalse($verifcond,'Test a false comparison'); |
|
947 | + $verifcond = verifCond('1==2'); |
|
948 | + $this->assertFalse($verifcond, 'Test a false comparison'); |
|
949 | 949 | |
950 | - $verifcond=verifCond('$conf->facture->enabled'); |
|
951 | - $this->assertTrue($verifcond,'Test that conf property of a module report true when enabled'); |
|
950 | + $verifcond = verifCond('$conf->facture->enabled'); |
|
951 | + $this->assertTrue($verifcond, 'Test that conf property of a module report true when enabled'); |
|
952 | 952 | |
953 | - $verifcond=verifCond('$conf->moduledummy->enabled'); |
|
954 | - $this->assertFalse($verifcond,'Test that conf property of a module report false when disabled'); |
|
953 | + $verifcond = verifCond('$conf->moduledummy->enabled'); |
|
954 | + $this->assertFalse($verifcond, 'Test that conf property of a module report false when disabled'); |
|
955 | 955 | |
956 | - $verifcond=verifCond(''); |
|
956 | + $verifcond = verifCond(''); |
|
957 | 957 | $this->assertTrue($verifcond); |
958 | 958 | } |
959 | 959 | |
@@ -964,76 +964,76 @@ discard block |
||
964 | 964 | */ |
965 | 965 | public function testGetDefaultTva() |
966 | 966 | { |
967 | - global $conf,$user,$langs,$db; |
|
968 | - $this->savconf=$conf; |
|
969 | - $this->savuser=$user; |
|
970 | - $this->savlangs=$langs; |
|
971 | - $this->savdb=$db; |
|
967 | + global $conf, $user, $langs, $db; |
|
968 | + $this->savconf = $conf; |
|
969 | + $this->savuser = $user; |
|
970 | + $this->savlangs = $langs; |
|
971 | + $this->savdb = $db; |
|
972 | 972 | |
973 | 973 | // Sellers |
974 | - $companyfrnovat=new Societe($db); |
|
975 | - $companyfrnovat->country_code='FR'; |
|
976 | - $companyfrnovat->tva_assuj=0; |
|
974 | + $companyfrnovat = new Societe($db); |
|
975 | + $companyfrnovat->country_code = 'FR'; |
|
976 | + $companyfrnovat->tva_assuj = 0; |
|
977 | 977 | |
978 | - $companyfr=new Societe($db); |
|
979 | - $companyfr->country_code='FR'; |
|
980 | - $companyfr->tva_assuj=1; |
|
981 | - $companyfr->tva_intra='FR9999'; |
|
978 | + $companyfr = new Societe($db); |
|
979 | + $companyfr->country_code = 'FR'; |
|
980 | + $companyfr->tva_assuj = 1; |
|
981 | + $companyfr->tva_intra = 'FR9999'; |
|
982 | 982 | |
983 | 983 | // Buyers |
984 | - $companymc=new Societe($db); |
|
985 | - $companymc->country_code='MC'; |
|
986 | - $companymc->tva_assuj=1; |
|
987 | - $companyfr->tva_intra='MC9999'; |
|
984 | + $companymc = new Societe($db); |
|
985 | + $companymc->country_code = 'MC'; |
|
986 | + $companymc->tva_assuj = 1; |
|
987 | + $companyfr->tva_intra = 'MC9999'; |
|
988 | 988 | |
989 | - $companyit=new Societe($db); |
|
990 | - $companyit->country_code='IT'; |
|
991 | - $companyit->tva_assuj=1; |
|
992 | - $companyit->tva_intra='IT99999'; |
|
989 | + $companyit = new Societe($db); |
|
990 | + $companyit->country_code = 'IT'; |
|
991 | + $companyit->tva_assuj = 1; |
|
992 | + $companyit->tva_intra = 'IT99999'; |
|
993 | 993 | |
994 | - $companyde=new Societe($db); |
|
995 | - $companyde->country_code='DE'; |
|
996 | - $companyde->tva_assuj=1; |
|
997 | - $companyde->tva_intra='DE99999'; |
|
994 | + $companyde = new Societe($db); |
|
995 | + $companyde->country_code = 'DE'; |
|
996 | + $companyde->tva_assuj = 1; |
|
997 | + $companyde->tva_intra = 'DE99999'; |
|
998 | 998 | |
999 | - $notcompanyde=new Societe($db); |
|
1000 | - $notcompanyde->country_code='DE'; |
|
1001 | - $notcompanyde->tva_assuj=0; |
|
1002 | - $notcompanyde->tva_intra=''; |
|
1003 | - $notcompanyde->typent_code='TE_PRIVATE'; |
|
999 | + $notcompanyde = new Societe($db); |
|
1000 | + $notcompanyde->country_code = 'DE'; |
|
1001 | + $notcompanyde->tva_assuj = 0; |
|
1002 | + $notcompanyde->tva_intra = ''; |
|
1003 | + $notcompanyde->typent_code = 'TE_PRIVATE'; |
|
1004 | 1004 | |
1005 | - $companyus=new Societe($db); |
|
1006 | - $companyus->country_code='US'; |
|
1007 | - $companyus->tva_assuj=1; |
|
1008 | - $companyus->tva_intra=''; |
|
1005 | + $companyus = new Societe($db); |
|
1006 | + $companyus->country_code = 'US'; |
|
1007 | + $companyus->tva_assuj = 1; |
|
1008 | + $companyus->tva_intra = ''; |
|
1009 | 1009 | |
1010 | 1010 | |
1011 | 1011 | // Test RULE 0 (FR-DE) |
1012 | 1012 | // Not tested |
1013 | 1013 | |
1014 | 1014 | // Test RULE 1 |
1015 | - $vat=get_default_tva($companyfrnovat,$companymc,0); |
|
1016 | - $this->assertEquals(0,$vat,'RULE 1'); |
|
1015 | + $vat = get_default_tva($companyfrnovat, $companymc, 0); |
|
1016 | + $this->assertEquals(0, $vat, 'RULE 1'); |
|
1017 | 1017 | |
1018 | 1018 | // Test RULE 2 (FR-FR) |
1019 | - $vat=get_default_tva($companyfr,$companyfr,0); |
|
1020 | - $this->assertEquals(20,$vat,'RULE 2'); |
|
1019 | + $vat = get_default_tva($companyfr, $companyfr, 0); |
|
1020 | + $this->assertEquals(20, $vat, 'RULE 2'); |
|
1021 | 1021 | |
1022 | 1022 | // Test RULE 2 (FR-MC) |
1023 | - $vat=get_default_tva($companyfr,$companymc,0); |
|
1024 | - $this->assertEquals(20,$vat,'RULE 2'); |
|
1023 | + $vat = get_default_tva($companyfr, $companymc, 0); |
|
1024 | + $this->assertEquals(20, $vat, 'RULE 2'); |
|
1025 | 1025 | |
1026 | 1026 | // Test RULE 3 (FR-DE company) |
1027 | - $vat=get_default_tva($companyfr,$companyit,0); |
|
1028 | - $this->assertEquals(0,$vat,'RULE 3'); |
|
1027 | + $vat = get_default_tva($companyfr, $companyit, 0); |
|
1028 | + $this->assertEquals(0, $vat, 'RULE 3'); |
|
1029 | 1029 | |
1030 | 1030 | // Test RULE 4 (FR-DE not a company) |
1031 | - $vat=get_default_tva($companyfr,$notcompanyde,0); |
|
1032 | - $this->assertEquals(20,$vat,'RULE 4'); |
|
1031 | + $vat = get_default_tva($companyfr, $notcompanyde, 0); |
|
1032 | + $this->assertEquals(20, $vat, 'RULE 4'); |
|
1033 | 1033 | |
1034 | 1034 | // Test RULE 5 (FR-US) |
1035 | - $vat=get_default_tva($companyfr,$companyus,0); |
|
1036 | - $this->assertEquals(0,$vat,'RULE 5'); |
|
1035 | + $vat = get_default_tva($companyfr, $companyus, 0); |
|
1036 | + $this->assertEquals(0, $vat, 'RULE 5'); |
|
1037 | 1037 | |
1038 | 1038 | |
1039 | 1039 | // We do same tests but with option SERVICE_ARE_ECOMMERCE_200238EC on. |
@@ -1041,24 +1041,24 @@ discard block |
||
1041 | 1041 | |
1042 | 1042 | |
1043 | 1043 | // Test RULE 1 (FR-US) |
1044 | - $vat=get_default_tva($companyfr,$companyus,0); |
|
1045 | - $this->assertEquals(0,$vat,'RULE 1 ECOMMERCE_200238EC'); |
|
1044 | + $vat = get_default_tva($companyfr, $companyus, 0); |
|
1045 | + $this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC'); |
|
1046 | 1046 | |
1047 | 1047 | // Test RULE 2 (FR-FR) |
1048 | - $vat=get_default_tva($companyfr,$companyfr,0); |
|
1049 | - $this->assertEquals(20,$vat,'RULE 2 ECOMMERCE_200238EC'); |
|
1048 | + $vat = get_default_tva($companyfr, $companyfr, 0); |
|
1049 | + $this->assertEquals(20, $vat, 'RULE 2 ECOMMERCE_200238EC'); |
|
1050 | 1050 | |
1051 | 1051 | // Test RULE 3 (FR-DE company) |
1052 | - $vat=get_default_tva($companyfr,$companyde,0); |
|
1053 | - $this->assertEquals(0,$vat,'RULE 3 ECOMMERCE_200238EC'); |
|
1052 | + $vat = get_default_tva($companyfr, $companyde, 0); |
|
1053 | + $this->assertEquals(0, $vat, 'RULE 3 ECOMMERCE_200238EC'); |
|
1054 | 1054 | |
1055 | 1055 | // Test RULE 4 (FR-DE not a company) |
1056 | - $vat=get_default_tva($companyfr,$notcompanyde,0); |
|
1057 | - $this->assertEquals(19,$vat,'RULE 4 ECOMMERCE_200238EC'); |
|
1056 | + $vat = get_default_tva($companyfr, $notcompanyde, 0); |
|
1057 | + $this->assertEquals(19, $vat, 'RULE 4 ECOMMERCE_200238EC'); |
|
1058 | 1058 | |
1059 | 1059 | // Test RULE 5 (FR-US) |
1060 | - $vat=get_default_tva($companyfr,$companyus,0); |
|
1061 | - $this->assertEquals(0,$vat,'RULE 5 ECOMMERCE_200238EC'); |
|
1060 | + $vat = get_default_tva($companyfr, $companyus, 0); |
|
1061 | + $this->assertEquals(0, $vat, 'RULE 5 ECOMMERCE_200238EC'); |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | /** |
@@ -1068,84 +1068,84 @@ discard block |
||
1068 | 1068 | */ |
1069 | 1069 | public function testGetDefaultLocalTax() |
1070 | 1070 | { |
1071 | - global $conf,$user,$langs,$db; |
|
1072 | - $this->savconf=$conf; |
|
1073 | - $this->savuser=$user; |
|
1074 | - $this->savlangs=$langs; |
|
1075 | - $this->savdb=$db; |
|
1076 | - |
|
1077 | - $companyfrnovat=new Societe($db); |
|
1078 | - $companyfrnovat->country_code='FR'; |
|
1079 | - $companyfrnovat->tva_assuj=0; |
|
1080 | - $companyfrnovat->localtax1_assuj=0; |
|
1081 | - $companyfrnovat->localtax2_assuj=0; |
|
1082 | - |
|
1083 | - $companyes=new Societe($db); |
|
1084 | - $companyes->country_code='ES'; |
|
1085 | - $companyes->tva_assuj=1; |
|
1086 | - $companyes->localtax1_assuj=1; |
|
1087 | - $companyes->localtax2_assuj=1; |
|
1088 | - |
|
1089 | - $companymc=new Societe($db); |
|
1090 | - $companymc->country_code='MC'; |
|
1091 | - $companymc->tva_assuj=1; |
|
1092 | - $companymc->localtax1_assuj=0; |
|
1093 | - $companymc->localtax2_assuj=0; |
|
1094 | - |
|
1095 | - $companyit=new Societe($db); |
|
1096 | - $companyit->country_code='IT'; |
|
1097 | - $companyit->tva_assuj=1; |
|
1098 | - $companyit->tva_intra='IT99999'; |
|
1099 | - $companyit->localtax1_assuj=0; |
|
1100 | - $companyit->localtax2_assuj=0; |
|
1101 | - |
|
1102 | - $notcompanyit=new Societe($db); |
|
1103 | - $notcompanyit->country_code='IT'; |
|
1104 | - $notcompanyit->tva_assuj=1; |
|
1105 | - $notcompanyit->tva_intra=''; |
|
1106 | - $notcompanyit->typent_code='TE_PRIVATE'; |
|
1107 | - $notcompanyit->localtax1_assuj=0; |
|
1108 | - $notcompanyit->localtax2_assuj=0; |
|
1109 | - |
|
1110 | - $companyus=new Societe($db); |
|
1111 | - $companyus->country_code='US'; |
|
1112 | - $companyus->tva_assuj=1; |
|
1113 | - $companyus->tva_intra=''; |
|
1114 | - $companyus->localtax1_assuj=0; |
|
1115 | - $companyus->localtax2_assuj=0; |
|
1071 | + global $conf, $user, $langs, $db; |
|
1072 | + $this->savconf = $conf; |
|
1073 | + $this->savuser = $user; |
|
1074 | + $this->savlangs = $langs; |
|
1075 | + $this->savdb = $db; |
|
1076 | + |
|
1077 | + $companyfrnovat = new Societe($db); |
|
1078 | + $companyfrnovat->country_code = 'FR'; |
|
1079 | + $companyfrnovat->tva_assuj = 0; |
|
1080 | + $companyfrnovat->localtax1_assuj = 0; |
|
1081 | + $companyfrnovat->localtax2_assuj = 0; |
|
1082 | + |
|
1083 | + $companyes = new Societe($db); |
|
1084 | + $companyes->country_code = 'ES'; |
|
1085 | + $companyes->tva_assuj = 1; |
|
1086 | + $companyes->localtax1_assuj = 1; |
|
1087 | + $companyes->localtax2_assuj = 1; |
|
1088 | + |
|
1089 | + $companymc = new Societe($db); |
|
1090 | + $companymc->country_code = 'MC'; |
|
1091 | + $companymc->tva_assuj = 1; |
|
1092 | + $companymc->localtax1_assuj = 0; |
|
1093 | + $companymc->localtax2_assuj = 0; |
|
1094 | + |
|
1095 | + $companyit = new Societe($db); |
|
1096 | + $companyit->country_code = 'IT'; |
|
1097 | + $companyit->tva_assuj = 1; |
|
1098 | + $companyit->tva_intra = 'IT99999'; |
|
1099 | + $companyit->localtax1_assuj = 0; |
|
1100 | + $companyit->localtax2_assuj = 0; |
|
1101 | + |
|
1102 | + $notcompanyit = new Societe($db); |
|
1103 | + $notcompanyit->country_code = 'IT'; |
|
1104 | + $notcompanyit->tva_assuj = 1; |
|
1105 | + $notcompanyit->tva_intra = ''; |
|
1106 | + $notcompanyit->typent_code = 'TE_PRIVATE'; |
|
1107 | + $notcompanyit->localtax1_assuj = 0; |
|
1108 | + $notcompanyit->localtax2_assuj = 0; |
|
1109 | + |
|
1110 | + $companyus = new Societe($db); |
|
1111 | + $companyus->country_code = 'US'; |
|
1112 | + $companyus->tva_assuj = 1; |
|
1113 | + $companyus->tva_intra = ''; |
|
1114 | + $companyus->localtax1_assuj = 0; |
|
1115 | + $companyus->localtax2_assuj = 0; |
|
1116 | 1116 | |
1117 | 1117 | // Test RULE FR-MC |
1118 | - $vat1=get_default_localtax($companyfrnovat,$companymc,1,0); |
|
1119 | - $vat2=get_default_localtax($companyfrnovat,$companymc,2,0); |
|
1120 | - $this->assertEquals(0,$vat1); |
|
1121 | - $this->assertEquals(0,$vat2); |
|
1118 | + $vat1 = get_default_localtax($companyfrnovat, $companymc, 1, 0); |
|
1119 | + $vat2 = get_default_localtax($companyfrnovat, $companymc, 2, 0); |
|
1120 | + $this->assertEquals(0, $vat1); |
|
1121 | + $this->assertEquals(0, $vat2); |
|
1122 | 1122 | |
1123 | 1123 | // Test RULE ES-ES |
1124 | - $vat1=get_default_localtax($companyes,$companyes,1,0); |
|
1125 | - $vat2=get_default_localtax($companyes,$companyes,2,0); |
|
1124 | + $vat1 = get_default_localtax($companyes, $companyes, 1, 0); |
|
1125 | + $vat2 = get_default_localtax($companyes, $companyes, 2, 0); |
|
1126 | 1126 | $this->assertEquals($vat1, 5.2); |
1127 | - $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) |
|
1127 | + $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) |
|
1128 | 1128 | |
1129 | 1129 | // Test RULE ES-IT |
1130 | - $vat1=get_default_localtax($companyes,$companyit,1,0); |
|
1131 | - $vat2=get_default_localtax($companyes,$companyit,2,0); |
|
1132 | - $this->assertEquals(0,$vat1); |
|
1133 | - $this->assertEquals(0,$vat2); |
|
1130 | + $vat1 = get_default_localtax($companyes, $companyit, 1, 0); |
|
1131 | + $vat2 = get_default_localtax($companyes, $companyit, 2, 0); |
|
1132 | + $this->assertEquals(0, $vat1); |
|
1133 | + $this->assertEquals(0, $vat2); |
|
1134 | 1134 | |
1135 | 1135 | // Test RULE ES-IT |
1136 | - $vat1=get_default_localtax($companyes,$notcompanyit,1,0); |
|
1137 | - $vat2=get_default_localtax($companyes,$notcompanyit,2,0); |
|
1138 | - $this->assertEquals(0,$vat1); |
|
1139 | - $this->assertEquals(0,$vat2); |
|
1136 | + $vat1 = get_default_localtax($companyes, $notcompanyit, 1, 0); |
|
1137 | + $vat2 = get_default_localtax($companyes, $notcompanyit, 2, 0); |
|
1138 | + $this->assertEquals(0, $vat1); |
|
1139 | + $this->assertEquals(0, $vat2); |
|
1140 | 1140 | |
1141 | 1141 | // Test RULE FR-IT |
1142 | 1142 | // Not tested |
1143 | 1143 | |
1144 | 1144 | // Test RULE ES-US |
1145 | - $vat1=get_default_localtax($companyes,$companyus,1,0); |
|
1146 | - $vat2=get_default_localtax($companyes,$companyus,2,0); |
|
1147 | - $this->assertEquals(0,$vat1); |
|
1148 | - $this->assertEquals(0,$vat2); |
|
1145 | + $vat1 = get_default_localtax($companyes, $companyus, 1, 0); |
|
1146 | + $vat2 = get_default_localtax($companyes, $companyus, 2, 0); |
|
1147 | + $this->assertEquals(0, $vat1); |
|
1148 | + $this->assertEquals(0, $vat2); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | |
@@ -1156,11 +1156,11 @@ discard block |
||
1156 | 1156 | */ |
1157 | 1157 | public function testDolExplodeIntoArray() |
1158 | 1158 | { |
1159 | - $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.'; |
|
1160 | - $tmp=dolExplodeIntoArray($stringtoexplode,'.','='); |
|
1159 | + $stringtoexplode = 'AA=B/B.CC=.EE=FF.HH=GG;.'; |
|
1160 | + $tmp = dolExplodeIntoArray($stringtoexplode, '.', '='); |
|
1161 | 1161 | |
1162 | 1162 | print __METHOD__." tmp=".json_encode($tmp)."\n"; |
1163 | - $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}',json_encode($tmp)); |
|
1163 | + $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}', json_encode($tmp)); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | /** |
@@ -1194,22 +1194,22 @@ discard block |
||
1194 | 1194 | public function testDolPrice2Num() |
1195 | 1195 | { |
1196 | 1196 | $this->assertEquals(1000, price2num('1 000.0')); |
1197 | - $this->assertEquals(1000, price2num('1 000','MT')); |
|
1198 | - $this->assertEquals(1000, price2num('1 000','MU')); |
|
1197 | + $this->assertEquals(1000, price2num('1 000', 'MT')); |
|
1198 | + $this->assertEquals(1000, price2num('1 000', 'MU')); |
|
1199 | 1199 | |
1200 | 1200 | $this->assertEquals(1000.123456, price2num('1 000.123456')); |
1201 | 1201 | |
1202 | 1202 | // Round down |
1203 | - $this->assertEquals(1000.12, price2num('1 000.123452','MT')); |
|
1204 | - $this->assertEquals(1000.12345, price2num('1 000.123452','MU'),"Test MU"); |
|
1203 | + $this->assertEquals(1000.12, price2num('1 000.123452', 'MT')); |
|
1204 | + $this->assertEquals(1000.12345, price2num('1 000.123452', 'MU'), "Test MU"); |
|
1205 | 1205 | |
1206 | 1206 | // Round up |
1207 | - $this->assertEquals(1000.13, price2num('1 000.125456','MT')); |
|
1208 | - $this->assertEquals(1000.12546, price2num('1 000.125456','MU'),"Test MU"); |
|
1207 | + $this->assertEquals(1000.13, price2num('1 000.125456', 'MT')); |
|
1208 | + $this->assertEquals(1000.12546, price2num('1 000.125456', 'MU'), "Test MU"); |
|
1209 | 1209 | |
1210 | 1210 | // Text can't be converted |
1211 | - $this->assertEquals('12.4$',price2num('12.4$')); |
|
1212 | - $this->assertEquals('12r.4$',price2num('12r.4$')); |
|
1211 | + $this->assertEquals('12.4$', price2num('12.4$')); |
|
1212 | + $this->assertEquals('12r.4$', price2num('12r.4$')); |
|
1213 | 1213 | |
1214 | 1214 | return true; |
1215 | 1215 | } |
@@ -1225,18 +1225,18 @@ discard block |
||
1225 | 1225 | |
1226 | 1226 | $conf->global->MAIN_START_WEEK = 0; |
1227 | 1227 | |
1228 | - $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1228 | + $tmp = dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1229 | 1229 | $this->assertEquals(4, $tmp['wday']); |
1230 | 1230 | |
1231 | - $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday |
|
1231 | + $tmp = dol_getdate(24 * 60 * 60 + 1); // 2/1/1970 and 1 second = friday |
|
1232 | 1232 | $this->assertEquals(5, $tmp['wday']); |
1233 | 1233 | |
1234 | 1234 | $conf->global->MAIN_START_WEEK = 1; |
1235 | 1235 | |
1236 | - $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1236 | + $tmp = dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1237 | 1237 | $this->assertEquals(4, $tmp['wday']); |
1238 | 1238 | |
1239 | - $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday |
|
1239 | + $tmp = dol_getdate(24 * 60 * 60 + 1); // 2/1/1970 and 1 second = friday |
|
1240 | 1240 | $this->assertEquals(5, $tmp['wday']); |
1241 | 1241 | |
1242 | 1242 | return true; |
@@ -1253,8 +1253,8 @@ discard block |
||
1253 | 1253 | global $conf, $langs; |
1254 | 1254 | $langs->load("main"); |
1255 | 1255 | |
1256 | - $substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced"); |
|
1257 | - $chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__'; |
|
1256 | + $substit = array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced"); |
|
1257 | + $chaine = 'This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__'; |
|
1258 | 1258 | $newstring = make_substitutions($chaine, $substit); |
1259 | 1259 | $this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__'); |
1260 | 1260 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $user->fetch(1); |
37 | 37 | $user->getrights(); |
38 | 38 | } |
39 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
39 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /** |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | parent::__construct(); |
65 | 65 | |
66 | 66 | //$this->sharedFixture |
67 | - global $conf,$user,$langs,$db; |
|
68 | - $this->savconf=$conf; |
|
69 | - $this->savuser=$user; |
|
70 | - $this->savlangs=$langs; |
|
71 | - $this->savdb=$db; |
|
67 | + global $conf, $user, $langs, $db; |
|
68 | + $this->savconf = $conf; |
|
69 | + $this->savuser = $user; |
|
70 | + $this->savlangs = $langs; |
|
71 | + $this->savdb = $db; |
|
72 | 72 | |
73 | 73 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
74 | 74 | //print " - db ".$db->db; |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | // Static methods |
79 | 79 | public static function setUpBeforeClass() |
80 | 80 | { |
81 | - global $conf,$user,$langs,$db; |
|
82 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
81 | + global $conf, $user, $langs, $db; |
|
82 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
83 | 83 | |
84 | 84 | print __METHOD__."\n"; |
85 | 85 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | // tear down after class |
88 | 88 | public static function tearDownAfterClass() |
89 | 89 | { |
90 | - global $conf,$user,$langs,$db; |
|
90 | + global $conf, $user, $langs, $db; |
|
91 | 91 | $db->rollback(); |
92 | 92 | |
93 | 93 | print __METHOD__."\n"; |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected function setUp() |
102 | 102 | { |
103 | - global $conf,$user,$langs,$db; |
|
104 | - $conf=$this->savconf; |
|
105 | - $user=$this->savuser; |
|
106 | - $langs=$this->savlangs; |
|
107 | - $db=$this->savdb; |
|
103 | + global $conf, $user, $langs, $db; |
|
104 | + $conf = $this->savconf; |
|
105 | + $user = $this->savuser; |
|
106 | + $langs = $this->savlangs; |
|
107 | + $db = $this->savdb; |
|
108 | 108 | |
109 | 109 | print __METHOD__."\n"; |
110 | 110 | } |
@@ -126,43 +126,43 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function testGetRootURLFromURL() |
128 | 128 | { |
129 | - global $conf,$user,$langs,$db; |
|
130 | - $conf=$this->savconf; |
|
131 | - $user=$this->savuser; |
|
132 | - $langs=$this->savlangs; |
|
133 | - $db=$this->savdb; |
|
129 | + global $conf, $user, $langs, $db; |
|
130 | + $conf = $this->savconf; |
|
131 | + $user = $this->savuser; |
|
132 | + $langs = $this->savlangs; |
|
133 | + $db = $this->savdb; |
|
134 | 134 | |
135 | - $result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); |
|
135 | + $result = getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); |
|
136 | 136 | print __METHOD__." result=".$result."\n"; |
137 | - $this->assertEquals('http://www.dolimed.com',$result,'Test 1'); |
|
137 | + $this->assertEquals('http://www.dolimed.com', $result, 'Test 1'); |
|
138 | 138 | |
139 | - $result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); |
|
139 | + $result = getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); |
|
140 | 140 | print __METHOD__." result=".$result."\n"; |
141 | - $this->assertEquals('https://www.dolimed.com',$result,'Test 2'); |
|
141 | + $this->assertEquals('https://www.dolimed.com', $result, 'Test 2'); |
|
142 | 142 | |
143 | - $result=getRootURLFromURL('http://www.dolimed.com/screenshots'); |
|
143 | + $result = getRootURLFromURL('http://www.dolimed.com/screenshots'); |
|
144 | 144 | print __METHOD__." result=".$result."\n"; |
145 | - $this->assertEquals('http://www.dolimed.com',$result); |
|
145 | + $this->assertEquals('http://www.dolimed.com', $result); |
|
146 | 146 | |
147 | - $result=getRootURLFromURL('https://www.dolimed.com/screenshots'); |
|
147 | + $result = getRootURLFromURL('https://www.dolimed.com/screenshots'); |
|
148 | 148 | print __METHOD__." result=".$result."\n"; |
149 | - $this->assertEquals('https://www.dolimed.com',$result); |
|
149 | + $this->assertEquals('https://www.dolimed.com', $result); |
|
150 | 150 | |
151 | - $result=getRootURLFromURL('http://www.dolimed.com/'); |
|
151 | + $result = getRootURLFromURL('http://www.dolimed.com/'); |
|
152 | 152 | print __METHOD__." result=".$result."\n"; |
153 | - $this->assertEquals('http://www.dolimed.com',$result); |
|
153 | + $this->assertEquals('http://www.dolimed.com', $result); |
|
154 | 154 | |
155 | - $result=getRootURLFromURL('https://www.dolimed.com/'); |
|
155 | + $result = getRootURLFromURL('https://www.dolimed.com/'); |
|
156 | 156 | print __METHOD__." result=".$result."\n"; |
157 | - $this->assertEquals('https://www.dolimed.com',$result); |
|
157 | + $this->assertEquals('https://www.dolimed.com', $result); |
|
158 | 158 | |
159 | - $result=getRootURLFromURL('http://www.dolimed.com'); |
|
159 | + $result = getRootURLFromURL('http://www.dolimed.com'); |
|
160 | 160 | print __METHOD__." result=".$result."\n"; |
161 | - $this->assertEquals('http://www.dolimed.com',$result); |
|
161 | + $this->assertEquals('http://www.dolimed.com', $result); |
|
162 | 162 | |
163 | - $result=getRootURLFromURL('https://www.dolimed.com'); |
|
163 | + $result = getRootURLFromURL('https://www.dolimed.com'); |
|
164 | 164 | print __METHOD__." result=".$result."\n"; |
165 | - $this->assertEquals('https://www.dolimed.com',$result); |
|
165 | + $this->assertEquals('https://www.dolimed.com', $result); |
|
166 | 166 | |
167 | 167 | return 1; |
168 | 168 | } |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function testRemoveHtmlComment() |
177 | 177 | { |
178 | - global $conf,$user,$langs,$db; |
|
179 | - $conf=$this->savconf; |
|
180 | - $user=$this->savuser; |
|
181 | - $langs=$this->savlangs; |
|
182 | - $db=$this->savdb; |
|
178 | + global $conf, $user, $langs, $db; |
|
179 | + $conf = $this->savconf; |
|
180 | + $user = $this->savuser; |
|
181 | + $langs = $this->savlangs; |
|
182 | + $db = $this->savdb; |
|
183 | 183 | |
184 | - $result=removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def'); |
|
184 | + $result = removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def'); |
|
185 | 185 | print __METHOD__." result=".$result."\n"; |
186 | - $this->assertEquals('abcdef',$result,'Test 1'); |
|
186 | + $this->assertEquals('abcdef', $result, 'Test 1'); |
|
187 | 187 | |
188 | - $result=removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def'); |
|
188 | + $result = removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def'); |
|
189 | 189 | print __METHOD__." result=".$result."\n"; |
190 | - $this->assertEquals('abcbbdef',$result,'Test 1'); |
|
190 | + $this->assertEquals('abcbbdef', $result, 'Test 1'); |
|
191 | 191 | |
192 | 192 | return 1; |
193 | 193 | } |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; |
31 | -require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
|
31 | +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
|
32 | 32 | |
33 | 33 | |
34 | 34 | if (empty($user->id)) { |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | $user->fetch(1); |
37 | 37 | $user->getrights(); |
38 | 38 | } |
39 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
39 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
40 | 40 | |
41 | -$conf->global->MAIN_UMASK='0666'; |
|
41 | +$conf->global->MAIN_UMASK = '0666'; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | parent::__construct(); |
67 | 67 | |
68 | 68 | //$this->sharedFixture |
69 | - global $conf,$user,$langs,$db; |
|
70 | - $this->savconf=$conf; |
|
71 | - $this->savuser=$user; |
|
72 | - $this->savlangs=$langs; |
|
73 | - $this->savdb=$db; |
|
69 | + global $conf, $user, $langs, $db; |
|
70 | + $this->savconf = $conf; |
|
71 | + $this->savuser = $user; |
|
72 | + $this->savlangs = $langs; |
|
73 | + $this->savdb = $db; |
|
74 | 74 | |
75 | 75 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
76 | 76 | //print " - db ".$db->db; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | // Static methods |
81 | 81 | public static function setUpBeforeClass() |
82 | 82 | { |
83 | - global $conf,$user,$langs,$db; |
|
83 | + global $conf, $user, $langs, $db; |
|
84 | 84 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
85 | 85 | |
86 | 86 | print __METHOD__."\n"; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | // tear down after class |
90 | 90 | public static function tearDownAfterClass() |
91 | 91 | { |
92 | - global $conf,$user,$langs,$db; |
|
92 | + global $conf, $user, $langs, $db; |
|
93 | 93 | $db->rollback(); |
94 | 94 | |
95 | 95 | print __METHOD__."\n"; |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function setUp() |
104 | 104 | { |
105 | - global $conf,$user,$langs,$db; |
|
106 | - $conf=$this->savconf; |
|
107 | - $user=$this->savuser; |
|
108 | - $langs=$this->savlangs; |
|
109 | - $db=$this->savdb; |
|
105 | + global $conf, $user, $langs, $db; |
|
106 | + $conf = $this->savconf; |
|
107 | + $user = $this->savuser; |
|
108 | + $langs = $this->savlangs; |
|
109 | + $db = $this->savdb; |
|
110 | 110 | |
111 | 111 | print __METHOD__."\n"; |
112 | 112 | } |
@@ -129,26 +129,26 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function testWSUserGetUser() |
131 | 131 | { |
132 | - global $conf,$user,$langs,$db; |
|
133 | - $conf=$this->savconf; |
|
134 | - $user=$this->savuser; |
|
135 | - $langs=$this->savlangs; |
|
136 | - $db=$this->savdb; |
|
132 | + global $conf, $user, $langs, $db; |
|
133 | + $conf = $this->savconf; |
|
134 | + $user = $this->savuser; |
|
135 | + $langs = $this->savlangs; |
|
136 | + $db = $this->savdb; |
|
137 | 137 | |
138 | 138 | $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_user.php'; |
139 | 139 | $WS_METHOD = 'getUser'; |
140 | - $ns='http://www.dolibarr.org/ns/'; |
|
140 | + $ns = 'http://www.dolibarr.org/ns/'; |
|
141 | 141 | |
142 | 142 | // Set the WebService URL |
143 | 143 | print __METHOD__."Create nusoap_client for URL=".$WS_DOL_URL."\n"; |
144 | 144 | $soapclient = new nusoap_client($WS_DOL_URL); |
145 | 145 | if ($soapclient) { |
146 | - $soapclient->soap_defencoding='UTF-8'; |
|
146 | + $soapclient->soap_defencoding = 'UTF-8'; |
|
147 | 147 | $soapclient->decodeUTF8(false); |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Call the WebService method and store its result in $result. |
151 | - $authentication=array( |
|
151 | + $authentication = array( |
|
152 | 152 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
153 | 153 | 'sourceapplication'=>'DEMO', |
154 | 154 | 'login'=>'admin', |
@@ -157,20 +157,20 @@ discard block |
||
157 | 157 | ); |
158 | 158 | |
159 | 159 | // Test URL |
160 | - $result=''; |
|
161 | - $parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'admin'); |
|
160 | + $result = ''; |
|
161 | + $parameters = array('authentication'=>$authentication, 'id'=>0, 'ref'=>'admin'); |
|
162 | 162 | print __METHOD__."Call method ".$WS_METHOD."\n"; |
163 | 163 | try { |
164 | - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); |
|
165 | - } catch(SoapFault $exception) { |
|
164 | + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); |
|
165 | + } catch (SoapFault $exception) { |
|
166 | 166 | echo $exception; |
167 | - $result=0; |
|
167 | + $result = 0; |
|
168 | 168 | } |
169 | - if (! empty($result['faultstring'])) { |
|
169 | + if (!empty($result['faultstring'])) { |
|
170 | 170 | print $result['faultstring']."\n"; |
171 | - $result=0; |
|
171 | + $result = 0; |
|
172 | 172 | } |
173 | - if (! $result) { |
|
173 | + if (!$result) { |
|
174 | 174 | //var_dump($soapclient); |
175 | 175 | print $soapclient->error_str; |
176 | 176 | print "\n<br>\n"; |
@@ -184,16 +184,16 @@ discard block |
||
184 | 184 | $this->assertEquals('OK', $result['result']['result_code'], 'Test on ref admin'); |
185 | 185 | |
186 | 186 | // Test URL |
187 | - $result=''; |
|
188 | - $parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'refthatdoesnotexists'); |
|
187 | + $result = ''; |
|
188 | + $parameters = array('authentication'=>$authentication, 'id'=>0, 'ref'=>'refthatdoesnotexists'); |
|
189 | 189 | print __METHOD__."Call method ".$WS_METHOD."\n"; |
190 | 190 | try { |
191 | - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); |
|
192 | - } catch(SoapFault $exception) { |
|
191 | + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); |
|
192 | + } catch (SoapFault $exception) { |
|
193 | 193 | echo $exception; |
194 | - $result=0; |
|
194 | + $result = 0; |
|
195 | 195 | } |
196 | - if (! $result || ! empty($result['faultstring'])) { |
|
196 | + if (!$result || !empty($result['faultstring'])) { |
|
197 | 197 | //var_dump($soapclient); |
198 | 198 | print $soapclient->error_str; |
199 | 199 | print "\n<br>\n"; |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | * \remarks To run this script as CLI: phpunit filename.php |
26 | 26 | */ |
27 | 27 | |
28 | -global $conf,$user,$langs,$db; |
|
28 | +global $conf, $user, $langs, $db; |
|
29 | 29 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
30 | 30 | //require_once 'PHPUnit/Autoload.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
32 | 32 | require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; |
33 | -require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
|
33 | +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
|
34 | 34 | |
35 | 35 | |
36 | 36 | if (empty($user->id)) { |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | $user->fetch(1); |
39 | 39 | $user->getrights(); |
40 | 40 | } |
41 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
41 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
42 | 42 | |
43 | -$conf->global->MAIN_UMASK='0666'; |
|
43 | +$conf->global->MAIN_UMASK = '0666'; |
|
44 | 44 | |
45 | 45 | if (empty($conf->service->enabled)) |
46 | 46 | { |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | parent::__construct(); |
74 | 74 | |
75 | 75 | //$this->sharedFixture |
76 | - global $conf,$user,$langs,$db; |
|
77 | - $this->savconf=$conf; |
|
78 | - $this->savuser=$user; |
|
79 | - $this->savlangs=$langs; |
|
80 | - $this->savdb=$db; |
|
76 | + global $conf, $user, $langs, $db; |
|
77 | + $this->savconf = $conf; |
|
78 | + $this->savuser = $user; |
|
79 | + $this->savlangs = $langs; |
|
80 | + $this->savdb = $db; |
|
81 | 81 | |
82 | 82 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
83 | 83 | //print " - db ".$db->db; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | // Static methods |
88 | 88 | public static function setUpBeforeClass() |
89 | 89 | { |
90 | - global $conf,$user,$langs,$db; |
|
90 | + global $conf, $user, $langs, $db; |
|
91 | 91 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
92 | 92 | |
93 | 93 | print __METHOD__."\n"; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // tear down after class |
96 | 96 | public static function tearDownAfterClass() |
97 | 97 | { |
98 | - global $conf,$user,$langs,$db; |
|
98 | + global $conf, $user, $langs, $db; |
|
99 | 99 | $db->rollback(); |
100 | 100 | |
101 | 101 | print __METHOD__."\n"; |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | */ |
109 | 109 | protected function setUp() |
110 | 110 | { |
111 | - global $conf,$user,$langs,$db; |
|
112 | - $conf=$this->savconf; |
|
113 | - $user=$this->savuser; |
|
114 | - $langs=$this->savlangs; |
|
115 | - $db=$this->savdb; |
|
111 | + global $conf, $user, $langs, $db; |
|
112 | + $conf = $this->savconf; |
|
113 | + $user = $this->savuser; |
|
114 | + $langs = $this->savlangs; |
|
115 | + $db = $this->savdb; |
|
116 | 116 | |
117 | 117 | print __METHOD__."\n"; |
118 | 118 | } |
@@ -135,28 +135,28 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function testWSProductsCreateProductOrService() |
137 | 137 | { |
138 | - global $conf,$user,$langs,$db; |
|
139 | - $conf=$this->savconf; |
|
140 | - $user=$this->savuser; |
|
141 | - $langs=$this->savlangs; |
|
142 | - $db=$this->savdb; |
|
138 | + global $conf, $user, $langs, $db; |
|
139 | + $conf = $this->savconf; |
|
140 | + $user = $this->savuser; |
|
141 | + $langs = $this->savlangs; |
|
142 | + $db = $this->savdb; |
|
143 | 143 | |
144 | - $datestring=dol_print_date(dol_now(),'dayhourlog'); |
|
144 | + $datestring = dol_print_date(dol_now(), 'dayhourlog'); |
|
145 | 145 | |
146 | 146 | $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; |
147 | 147 | $WS_METHOD = 'createProductOrService'; |
148 | - $ns='http://www.dolibarr.org/ns/'; |
|
148 | + $ns = 'http://www.dolibarr.org/ns/'; |
|
149 | 149 | |
150 | 150 | // Set the WebService URL |
151 | 151 | print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; |
152 | 152 | $soapclient = new nusoap_client($WS_DOL_URL); |
153 | 153 | if ($soapclient) { |
154 | - $soapclient->soap_defencoding='UTF-8'; |
|
154 | + $soapclient->soap_defencoding = 'UTF-8'; |
|
155 | 155 | $soapclient->decodeUTF8(false); |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Call the WebService method and store its result in $result. |
159 | - $authentication=array( |
|
159 | + $authentication = array( |
|
160 | 160 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
161 | 161 | 'sourceapplication'=>'DEMO', |
162 | 162 | 'login'=>'admin', |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | ); |
166 | 166 | |
167 | 167 | // Test URL |
168 | - $result=''; |
|
168 | + $result = ''; |
|
169 | 169 | $parameters = array( |
170 | - 'authentication'=>$authentication,'product'=>array( |
|
170 | + 'authentication'=>$authentication, 'product'=>array( |
|
171 | 171 | 'ref'=>'NewProductFromWS'.$datestring, |
172 | 172 | 'label'=>'New Product From WS '.$datestring, |
173 | 173 | 'type'=>1, |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | ); |
179 | 179 | print __METHOD__." call method ".$WS_METHOD."\n"; |
180 | 180 | try { |
181 | - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); |
|
182 | - } catch(SoapFault $exception) { |
|
181 | + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); |
|
182 | + } catch (SoapFault $exception) { |
|
183 | 183 | echo $exception; |
184 | - $result=0; |
|
184 | + $result = 0; |
|
185 | 185 | } |
186 | - if (! $result || ! empty($result['faultstring']) || $result['result']['result_code'] != 'OK') { |
|
186 | + if (!$result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') { |
|
187 | 187 | //var_dump($soapclient); |
188 | 188 | print $soapclient->error_str; |
189 | 189 | print "\n<br>\n"; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | } |
195 | 195 | |
196 | 196 | print __METHOD__." result=".$result."\n"; |
197 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
197 | + $this->assertEquals('OK', $result['result']['result_code']); |
|
198 | 198 | |
199 | 199 | return $result['id']; |
200 | 200 | } |
@@ -209,26 +209,26 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function testWSProductsGetProductOrService($id) |
211 | 211 | { |
212 | - global $conf,$user,$langs,$db; |
|
213 | - $conf=$this->savconf; |
|
214 | - $user=$this->savuser; |
|
215 | - $langs=$this->savlangs; |
|
216 | - $db=$this->savdb; |
|
212 | + global $conf, $user, $langs, $db; |
|
213 | + $conf = $this->savconf; |
|
214 | + $user = $this->savuser; |
|
215 | + $langs = $this->savlangs; |
|
216 | + $db = $this->savdb; |
|
217 | 217 | |
218 | 218 | $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; |
219 | 219 | $WS_METHOD = 'getProductOrService'; |
220 | - $ns='http://www.dolibarr.org/ns/'; |
|
220 | + $ns = 'http://www.dolibarr.org/ns/'; |
|
221 | 221 | |
222 | 222 | // Set the WebService URL |
223 | 223 | print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; |
224 | 224 | $soapclient = new nusoap_client($WS_DOL_URL); |
225 | 225 | if ($soapclient) { |
226 | - $soapclient->soap_defencoding='UTF-8'; |
|
226 | + $soapclient->soap_defencoding = 'UTF-8'; |
|
227 | 227 | $soapclient->decodeUTF8(false); |
228 | 228 | } |
229 | 229 | |
230 | 230 | // Call the WebService method and store its result in $result. |
231 | - $authentication=array( |
|
231 | + $authentication = array( |
|
232 | 232 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
233 | 233 | 'sourceapplication'=>'DEMO', |
234 | 234 | 'login'=>'admin', |
@@ -237,16 +237,16 @@ discard block |
||
237 | 237 | ); |
238 | 238 | |
239 | 239 | // Test URL |
240 | - $result=''; |
|
241 | - $parameters = array('authentication'=>$authentication,'id'=>$id,'ref'=>''); |
|
240 | + $result = ''; |
|
241 | + $parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>''); |
|
242 | 242 | print __METHOD__." call method ".$WS_METHOD."\n"; |
243 | 243 | try { |
244 | - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); |
|
245 | - } catch(SoapFault $exception) { |
|
244 | + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); |
|
245 | + } catch (SoapFault $exception) { |
|
246 | 246 | echo $exception; |
247 | - $result=0; |
|
247 | + $result = 0; |
|
248 | 248 | } |
249 | - if (! $result || ! empty($result['faultstring'])) { |
|
249 | + if (!$result || !empty($result['faultstring'])) { |
|
250 | 250 | //var_dump($soapclient); |
251 | 251 | print $soapclient->error_str; |
252 | 252 | print "\n<br>\n"; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | } |
258 | 258 | |
259 | 259 | print __METHOD__." result=".$result."\n"; |
260 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
260 | + $this->assertEquals('OK', $result['result']['result_code']); |
|
261 | 261 | |
262 | 262 | return $id; |
263 | 263 | } |
@@ -272,26 +272,26 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function testWSProductsDeleteProductOrService($id) |
274 | 274 | { |
275 | - global $conf,$user,$langs,$db; |
|
276 | - $conf=$this->savconf; |
|
277 | - $user=$this->savuser; |
|
278 | - $langs=$this->savlangs; |
|
279 | - $db=$this->savdb; |
|
275 | + global $conf, $user, $langs, $db; |
|
276 | + $conf = $this->savconf; |
|
277 | + $user = $this->savuser; |
|
278 | + $langs = $this->savlangs; |
|
279 | + $db = $this->savdb; |
|
280 | 280 | |
281 | 281 | $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; |
282 | 282 | $WS_METHOD = 'deleteProductOrService'; |
283 | - $ns='http://www.dolibarr.org/ns/'; |
|
283 | + $ns = 'http://www.dolibarr.org/ns/'; |
|
284 | 284 | |
285 | 285 | // Set the WebService URL |
286 | 286 | print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; |
287 | 287 | $soapclient = new nusoap_client($WS_DOL_URL); |
288 | 288 | if ($soapclient) { |
289 | - $soapclient->soap_defencoding='UTF-8'; |
|
289 | + $soapclient->soap_defencoding = 'UTF-8'; |
|
290 | 290 | $soapclient->decodeUTF8(false); |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Call the WebService method and store its result in $result. |
294 | - $authentication=array( |
|
294 | + $authentication = array( |
|
295 | 295 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
296 | 296 | 'sourceapplication'=>'DEMO', |
297 | 297 | 'login'=>'admin', |
@@ -300,16 +300,16 @@ discard block |
||
300 | 300 | ); |
301 | 301 | |
302 | 302 | // Test URL |
303 | - $result=''; |
|
304 | - $parameters = array('authentication'=>$authentication,'listofid'=>$id); |
|
303 | + $result = ''; |
|
304 | + $parameters = array('authentication'=>$authentication, 'listofid'=>$id); |
|
305 | 305 | print __METHOD__." call method ".$WS_METHOD."\n"; |
306 | 306 | try { |
307 | - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); |
|
308 | - } catch(SoapFault $exception) { |
|
307 | + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); |
|
308 | + } catch (SoapFault $exception) { |
|
309 | 309 | echo $exception; |
310 | - $result=0; |
|
310 | + $result = 0; |
|
311 | 311 | } |
312 | - if (! $result || ! empty($result['faultstring']) || $result['result']['result_code'] != 'OK') { |
|
312 | + if (!$result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') { |
|
313 | 313 | //var_dump($soapclient); |
314 | 314 | print $soapclient->error_str; |
315 | 315 | print "\n<br>\n"; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | print __METHOD__." result=".$result."\n"; |
323 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
323 | + $this->assertEquals('OK', $result['result']['result_code']); |
|
324 | 324 | |
325 | 325 | return 0; |
326 | 326 | } |