Completed
Branch develop (3d98b7)
by
unknown
17:59
created
test/phpunit/FunctionsLibTest.php 1 patch
Spacing   +415 added lines, -415 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *		\remarks	To run this script as CLI:  phpunit filename.php
26 26
  */
27 27
 
28
-global $conf,$user,$langs,$db,$mysoc;
28
+global $conf, $user, $langs, $db, $mysoc;
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';
@@ -33,35 +33,35 @@  discard block
 block discarded – undo
33 33
 require_once dirname(__FILE__).'/../../htdocs/product/class/product.class.php';
34 34
 require_once dirname(__FILE__).'/CommonClassTest.class.php';
35 35
 
36
-if (! defined('NOREQUIREUSER')) {
36
+if (!defined('NOREQUIREUSER')) {
37 37
 	define('NOREQUIREUSER', '1');
38 38
 }
39
-if (! defined('NOREQUIREDB')) {
39
+if (!defined('NOREQUIREDB')) {
40 40
 	define('NOREQUIREDB', '1');
41 41
 }
42
-if (! defined('NOREQUIRESOC')) {
42
+if (!defined('NOREQUIRESOC')) {
43 43
 	define('NOREQUIRESOC', '1');
44 44
 }
45
-if (! defined('NOREQUIRETRAN')) {
45
+if (!defined('NOREQUIRETRAN')) {
46 46
 	define('NOREQUIRETRAN', '1');
47 47
 }
48
-if (! defined('NOCSRFCHECK')) {
48
+if (!defined('NOCSRFCHECK')) {
49 49
 	define('NOCSRFCHECK', '1');
50 50
 }
51
-if (! defined('NOTOKENRENEWAL')) {
51
+if (!defined('NOTOKENRENEWAL')) {
52 52
 	define('NOTOKENRENEWAL', '1');
53 53
 }
54
-if (! defined('NOREQUIREMENU')) {
54
+if (!defined('NOREQUIREMENU')) {
55 55
 	define('NOREQUIREMENU', '1'); // If there is no menu to show
56 56
 }
57
-if (! defined('NOREQUIREHTML')) {
57
+if (!defined('NOREQUIREHTML')) {
58 58
 	define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
59 59
 }
60
-if (! defined('NOREQUIREAJAX')) {
60
+if (!defined('NOREQUIREAJAX')) {
61 61
 	define('NOREQUIREAJAX', '1');
62 62
 }
63
-if (! defined("NOLOGIN")) {
64
-	define("NOLOGIN", '1');       // If this page is public (can be called outside logged session)
63
+if (!defined("NOLOGIN")) {
64
+	define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
65 65
 }
66 66
 
67 67
 print "\n".$langs->trans("CurrentTimeZone").' : '.getServerTimeZoneString();
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public static function setUpBeforeClass(): void
87 87
 	{
88
-		global $conf,$user,$langs,$db;
88
+		global $conf, $user, $langs, $db;
89 89
 		//$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
90 90
 
91
-		if (! function_exists('mb_substr')) {
91
+		if (!function_exists('mb_substr')) {
92 92
 			print "\n".__METHOD__." function mb_substr must be enabled.\n";
93 93
 			die(1);
94 94
 		}
@@ -217,17 +217,17 @@  discard block
 block discarded – undo
217 217
 		global $conf, $langs, $db;
218 218
 
219 219
 		// An attempt for SQL injection
220
-		$filter='if(now()=sysdate()%2Csleep(6)%2C0)';
220
+		$filter = 'if(now()=sysdate()%2Csleep(6)%2C0)';
221 221
 		$sql = forgeSQLFromUniversalSearchCriteria($filter);
222 222
 		$this->assertEquals('Filter error - Bad syntax of the search string', $sql);
223 223
 
224 224
 		// A real search string
225
-		$filter='(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))';
225
+		$filter = '(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))';
226 226
 		$sql = forgeSQLFromUniversalSearchCriteria($filter);
227 227
 		$this->assertEquals(' AND ((((statut = 1) or (entity IN (__AAA__))) and (abc < 2) and (abc <> 1.23)))', $sql);
228 228
 
229 229
 		// A real search string
230
-		$filter="(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.date_creation:<:'2016-01-01 12:30:00') or (t.nature:is:NULL)";
230
+		$filter = "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.date_creation:<:'2016-01-01 12:30:00') or (t.nature:is:NULL)";
231 231
 		$sql = forgeSQLFromUniversalSearchCriteria($filter);
232 232
 		$this->assertEquals(" AND ((t.ref LIKE 'SO-%') or (t.date_creation < '20160101') or (t.date_creation < 0) or (t.nature IS NULL))", $sql);
233 233
 
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 		$sql = forgeSQLFromUniversalSearchCriteria($filter);
248 248
 
249 249
 		if ($db->type == 'mysqli') {
250
-			$this->assertEquals(" AND ((t.fieldstring = 'aaa\'ttt'))", $sql);	// with mysql
250
+			$this->assertEquals(" AND ((t.fieldstring = 'aaa\'ttt'))", $sql); // with mysql
251 251
 		} else {
252
-			$this->assertEquals(" AND ((t.fieldstring = 'aaa''ttt'))", $sql);	// with pgsql
252
+			$this->assertEquals(" AND ((t.fieldstring = 'aaa''ttt'))", $sql); // with pgsql
253 253
 		}
254 254
 
255 255
 		$filter = "(t.fk_soc:IN:1,2)";
@@ -326,23 +326,23 @@  discard block
 block discarded – undo
326 326
 	{
327 327
 		// Nb of line is same than entry text
328 328
 
329
-		$input="bidon@bademail";
330
-		$result=isValidEmail($input);
329
+		$input = "bidon@bademail";
330
+		$result = isValidEmail($input);
331 331
 		print __METHOD__." result=".$result."\n";
332 332
 		$this->assertFalse($result, 'Check isValidEmail '.$input);
333 333
 
334
-		$input="[email protected]";
335
-		$result=isValidEmail($input);
334
+		$input = "[email protected]";
335
+		$result = isValidEmail($input);
336 336
 		print __METHOD__." result=".$result."\n";
337 337
 		$this->assertTrue($result, 'Check isValidEmail '.$input);
338 338
 
339
-		$input="The name of sender <[email protected]>";
340
-		$result=isValidEmail($input);
339
+		$input = "The name of sender <[email protected]>";
340
+		$result = isValidEmail($input);
341 341
 		print __METHOD__." result=".$result."\n";
342 342
 		$this->assertFalse($result, 'Check isValidEmail '.$input);
343 343
 
344
-		$input="[email protected]";
345
-		$result=isValidEmail($input);
344
+		$input = "[email protected]";
345
+		$result = isValidEmail($input);
346 346
 		print __METHOD__." result=".$result."\n";
347 347
 		$this->assertTrue($result, 'Check isValidEmail '.$input);
348 348
 	}
@@ -356,18 +356,18 @@  discard block
 block discarded – undo
356 356
 	{
357 357
 		// Nb of line is same than entry text
358 358
 
359
-		$input="yahoo.com";
360
-		$result=isValidMXRecord($input);
359
+		$input = "yahoo.com";
360
+		$result = isValidMXRecord($input);
361 361
 		print __METHOD__." result=".$result."\n";
362 362
 		$this->assertEquals(1, $result);
363 363
 
364
-		$input="yhaoo.com";
365
-		$result=isValidMXRecord($input);
364
+		$input = "yhaoo.com";
365
+		$result = isValidMXRecord($input);
366 366
 		print __METHOD__." result=".$result."\n";
367 367
 		$this->assertEquals(0, $result);
368 368
 
369
-		$input="dolibarr.fr";
370
-		$result=isValidMXRecord($input);
369
+		$input = "dolibarr.fr";
370
+		$result = isValidMXRecord($input);
371 371
 		print __METHOD__." result=".$result."\n";
372 372
 		$this->assertEquals(0, $result);
373 373
 	}
@@ -381,57 +381,57 @@  discard block
 block discarded – undo
381 381
 	{
382 382
 		// Nb of line is same than entry text
383 383
 
384
-		$input="aaaa";
385
-		$result=dolGetFirstLineOfText($input);
384
+		$input = "aaaa";
385
+		$result = dolGetFirstLineOfText($input);
386 386
 		print __METHOD__." result=".$result."\n";
387 387
 		$this->assertEquals("aaaa", $result);
388 388
 
389
-		$input="aaaa\nbbbbbbbbbbbb\n";
390
-		$result=dolGetFirstLineOfText($input, 2);
389
+		$input = "aaaa\nbbbbbbbbbbbb\n";
390
+		$result = dolGetFirstLineOfText($input, 2);
391 391
 		print __METHOD__." result=".$result."\n";
392 392
 		$this->assertEquals("aaaa\nbbbbbbbbbbbb", $result);
393 393
 
394
-		$input="aaaa<br>bbbbbbbbbbbb<br>";
395
-		$result=dolGetFirstLineOfText($input, 2);
394
+		$input = "aaaa<br>bbbbbbbbbbbb<br>";
395
+		$result = dolGetFirstLineOfText($input, 2);
396 396
 		print __METHOD__." result=".$result."\n";
397 397
 		$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result);
398 398
 
399 399
 		// Nb of line is lower
400 400
 
401
-		$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
402
-		$result=dolGetFirstLineOfText($input);
401
+		$input = "aaaa\nbbbbbbbbbbbb\ncccccc\n";
402
+		$result = dolGetFirstLineOfText($input);
403 403
 		print __METHOD__." result=".$result."\n";
404 404
 		$this->assertEquals("aaaa...", $result);
405 405
 
406
-		$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
407
-		$result=dolGetFirstLineOfText($input);
406
+		$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
407
+		$result = dolGetFirstLineOfText($input);
408 408
 		print __METHOD__." result=".$result."\n";
409 409
 		$this->assertEquals("aaaa...", $result);
410 410
 
411
-		$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
412
-		$result=dolGetFirstLineOfText($input, 2);
411
+		$input = "aaaa\nbbbbbbbbbbbb\ncccccc\n";
412
+		$result = dolGetFirstLineOfText($input, 2);
413 413
 		print __METHOD__." result=".$result."\n";
414 414
 		$this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result);
415 415
 
416
-		$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
417
-		$result=dolGetFirstLineOfText($input, 2);
416
+		$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
417
+		$result = dolGetFirstLineOfText($input, 2);
418 418
 		print __METHOD__." result=".$result."\n";
419 419
 		$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result);
420 420
 
421 421
 		// Nb of line is higher
422 422
 
423
-		$input="aaaa<br>bbbbbbbbbbbb<br>cccccc";
424
-		$result=dolGetFirstLineOfText($input, 100);
423
+		$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc";
424
+		$result = dolGetFirstLineOfText($input, 100);
425 425
 		print __METHOD__." result=".$result."\n";
426 426
 		$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a');
427 427
 
428
-		$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
429
-		$result=dolGetFirstLineOfText($input, 100);
428
+		$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
429
+		$result = dolGetFirstLineOfText($input, 100);
430 430
 		print __METHOD__." result=".$result."\n";
431 431
 		$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b');
432 432
 
433
-		$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n";
434
-		$result=dolGetFirstLineOfText($input, 100);
433
+		$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n";
434
+		$result = dolGetFirstLineOfText($input, 100);
435 435
 		print __METHOD__." result=".$result."\n";
436 436
 		$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c');
437 437
 	}
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
 		var_dump($tmp);
453 453
 		*/
454 454
 
455
-		$result=dol_buildpath('/google/oauth2callback.php', 2);
455
+		$result = dol_buildpath('/google/oauth2callback.php', 2);
456 456
 		print __METHOD__." dol_buildpath result=".$result."\n";
457 457
 		$this->assertStringStartsWith('http', $result);
458 458
 
459
-		$result=dol_buildpath('/google/oauth2callback.php', 3);
459
+		$result = dol_buildpath('/google/oauth2callback.php', 3);
460 460
 		print __METHOD__." dol_buildpath result=".$result."\n";
461 461
 		$this->assertStringStartsWith('http', $result);
462 462
 	}
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 	public function testGetBrowserInfo()
471 471
 	{
472 472
 		// MSIE 5.0
473
-		$user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)';
474
-		$tmp=getBrowserInfo($user_agent);
473
+		$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)';
474
+		$tmp = getBrowserInfo($user_agent);
475 475
 		$this->assertEquals('ie', $tmp['browsername']);
476 476
 		$this->assertEquals('5.0', $tmp['browserversion']);
477 477
 		$this->assertEmpty($tmp['phone']);
@@ -479,40 +479,40 @@  discard block
 block discarded – undo
479 479
 		$this->assertEquals('classic', $tmp['layout']);
480 480
 
481 481
 		// Firefox 0.9.1
482
-		$user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1';
483
-		$tmp=getBrowserInfo($user_agent);
482
+		$user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1';
483
+		$tmp = getBrowserInfo($user_agent);
484 484
 		$this->assertEquals('firefox', $tmp['browsername']);
485 485
 		$this->assertEquals('0.9.1', $tmp['browserversion']);
486 486
 		$this->assertEmpty($tmp['phone']);
487 487
 		$this->assertFalse($tmp['tablet']);
488 488
 		$this->assertEquals('classic', $tmp['layout']);
489 489
 
490
-		$user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03  [en]';
491
-		$tmp=getBrowserInfo($user_agent);
490
+		$user_agent = 'Mozilla/3.0 (Windows 98; U) Opera 6.03  [en]';
491
+		$tmp = getBrowserInfo($user_agent);
492 492
 		$this->assertEquals('opera', $tmp['browsername']);
493 493
 		$this->assertEquals('6.03', $tmp['browserversion']);
494 494
 		$this->assertEmpty($tmp['phone']);
495 495
 		$this->assertFalse($tmp['tablet']);
496 496
 		$this->assertEquals('classic', $tmp['layout']);
497 497
 
498
-		$user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21';
499
-		$tmp=getBrowserInfo($user_agent);
498
+		$user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21';
499
+		$tmp = getBrowserInfo($user_agent);
500 500
 		$this->assertEquals('chrome', $tmp['browsername']);
501 501
 		$this->assertEquals('19.0.1042.0', $tmp['browserversion']);
502 502
 		$this->assertEmpty($tmp['phone']);
503 503
 		$this->assertFalse($tmp['tablet']);
504 504
 		$this->assertEquals('classic', $tmp['layout']);
505 505
 
506
-		$user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)';
507
-		$tmp=getBrowserInfo($user_agent);
506
+		$user_agent = 'chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)';
507
+		$tmp = getBrowserInfo($user_agent);
508 508
 		$this->assertEquals('chrome', $tmp['browsername']);
509 509
 		$this->assertEquals('17.0.963.56', $tmp['browserversion']);
510 510
 		$this->assertEmpty($tmp['phone']);
511 511
 		$this->assertFalse($tmp['tablet']);
512 512
 		$this->assertEquals('classic', $tmp['layout']);
513 513
 
514
-		$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';
515
-		$tmp=getBrowserInfo($user_agent);
514
+		$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';
515
+		$tmp = getBrowserInfo($user_agent);
516 516
 		$this->assertEquals('safari', $tmp['browsername']);
517 517
 		$this->assertEquals('533.21.1', $tmp['browserversion']);
518 518
 		$this->assertEmpty($tmp['phone']);
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 
522 522
 		//Internet Explorer 11
523 523
 		$user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
524
-		$tmp=getBrowserInfo($user_agent);
524
+		$tmp = getBrowserInfo($user_agent);
525 525
 		$this->assertEquals('ie', $tmp['browsername']);
526 526
 		$this->assertEquals('11.0', $tmp['browserversion']);
527 527
 		$this->assertEmpty($tmp['phone']);
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 
531 531
 		//Internet Explorer 11 bis
532 532
 		$user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko';
533
-		$tmp=getBrowserInfo($user_agent);
533
+		$tmp = getBrowserInfo($user_agent);
534 534
 		$this->assertEquals('ie', $tmp['browsername']);
535 535
 		$this->assertEquals('11.0', $tmp['browserversion']);
536 536
 		$this->assertEmpty($tmp['phone']);
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 
540 540
 		//iPad
541 541
 		$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';
542
-		$tmp=getBrowserInfo($user_agent);
542
+		$tmp = getBrowserInfo($user_agent);
543 543
 		$this->assertEquals('safari', $tmp['browsername']);
544 544
 		$this->assertEquals('8536.25', $tmp['browserversion']);
545 545
 		$this->assertEquals('ios', $tmp['browseros']);
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 
549 549
 		//Lynx
550 550
 		$user_agent = 'Lynx/2.8.8dev.3 libwww‑FM/2.14 SSL‑MM/1.4.1';
551
-		$tmp=getBrowserInfo($user_agent);
551
+		$tmp = getBrowserInfo($user_agent);
552 552
 		$this->assertEquals('lynxlinks', $tmp['browsername']);
553 553
 		$this->assertEquals('2.8.8', $tmp['browserversion']);
554 554
 		$this->assertEquals('unknown', $tmp['browseros']);
@@ -615,71 +615,71 @@  discard block
 block discarded – undo
615 615
 	public function testDolTextIsHtml()
616 616
 	{
617 617
 		// True
618
-		$input='<html>xxx</html>';
619
-		$after=dol_textishtml($input);
618
+		$input = '<html>xxx</html>';
619
+		$after = dol_textishtml($input);
620 620
 		$this->assertTrue($after, 'Test with html tag');
621
-		$input='<body>xxx</body>';
622
-		$after=dol_textishtml($input);
621
+		$input = '<body>xxx</body>';
622
+		$after = dol_textishtml($input);
623 623
 		$this->assertTrue($after, 'Test with body tag');
624
-		$input='xxx <b>yyy</b> zzz';
625
-		$after=dol_textishtml($input);
624
+		$input = 'xxx <b>yyy</b> zzz';
625
+		$after = dol_textishtml($input);
626 626
 		$this->assertTrue($after, 'Test with b tag');
627
-		$input='xxx <u>yyy</u> zzz';
628
-		$after=dol_textishtml($input);
627
+		$input = 'xxx <u>yyy</u> zzz';
628
+		$after = dol_textishtml($input);
629 629
 		$this->assertTrue($after, 'Test with u tag');
630
-		$input='text with <div>some div</div>';
631
-		$after=dol_textishtml($input);
630
+		$input = 'text with <div>some div</div>';
631
+		$after = dol_textishtml($input);
632 632
 		$this->assertTrue($after, 'Test with div tag');
633
-		$input='text with HTML &nbsp; entities';
634
-		$after=dol_textishtml($input);
633
+		$input = 'text with HTML &nbsp; entities';
634
+		$after = dol_textishtml($input);
635 635
 		$this->assertTrue($after, 'Test with entities tag');
636
-		$input='xxx<br>';
637
-		$after=dol_textishtml($input);
636
+		$input = 'xxx<br>';
637
+		$after = dol_textishtml($input);
638 638
 		$this->assertTrue($after, 'Test with entities br');
639
-		$input='xxx<br >';
640
-		$after=dol_textishtml($input);
639
+		$input = 'xxx<br >';
640
+		$after = dol_textishtml($input);
641 641
 		$this->assertTrue($after, 'Test with entities br');
642
-		$input='xxx<br style="eee">';
643
-		$after=dol_textishtml($input);
642
+		$input = 'xxx<br style="eee">';
643
+		$after = dol_textishtml($input);
644 644
 		$this->assertTrue($after, 'Test with entities br and attributes');
645
-		$input='xxx<br style="eee" >';
646
-		$after=dol_textishtml($input);
645
+		$input = 'xxx<br style="eee" >';
646
+		$after = dol_textishtml($input);
647 647
 		$this->assertTrue($after, 'Test with entities br and attributes bis');
648
-		$input='<h2>abc</h2>';
649
-		$after=dol_textishtml($input);
648
+		$input = '<h2>abc</h2>';
649
+		$after = dol_textishtml($input);
650 650
 		$this->assertTrue($after, 'Test with entities h2');
651
-		$input='<img id="abc" src="https://xxx.com/aaa/image.png" />';
652
-		$after=dol_textishtml($input);
651
+		$input = '<img id="abc" src="https://xxx.com/aaa/image.png" />';
652
+		$after = dol_textishtml($input);
653 653
 		$this->assertTrue($after, 'Test with img tag');
654
-		$input='<a class="azerty" href="https://xxx.com/aaa/image.png" />';
655
-		$after=dol_textishtml($input);
654
+		$input = '<a class="azerty" href="https://xxx.com/aaa/image.png" />';
655
+		$after = dol_textishtml($input);
656 656
 		$this->assertTrue($after, 'Test with a tag');
657
-		$input='This is a text with&nbsp;html spaces';
658
-		$after=dol_textishtml($input);
657
+		$input = 'This is a text with&nbsp;html spaces';
658
+		$after = dol_textishtml($input);
659 659
 		$this->assertTrue($after, 'Test with a &nbsp;');
660
-		$input='This is a text with accent &eacute;';
661
-		$after=dol_textishtml($input);
660
+		$input = 'This is a text with accent &eacute;';
661
+		$after = dol_textishtml($input);
662 662
 		$this->assertTrue($after, 'Test with a &eacute;');
663
-		$input='<i class="abc">xxx</i>';
664
-		$after=dol_textishtml($input);
663
+		$input = '<i class="abc">xxx</i>';
664
+		$after = dol_textishtml($input);
665 665
 		$this->assertTrue($after, 'Test with i tag and class;');
666 666
 
667 667
 		// False
668
-		$input='xxx < br>';
669
-		$after=dol_textishtml($input);
668
+		$input = 'xxx < br>';
669
+		$after = dol_textishtml($input);
670 670
 		$this->assertFalse($after);
671
-		$input='xxx <[email protected]>';	// <em> is html, <em... is not
672
-		$after=dol_textishtml($input);
671
+		$input = 'xxx <[email protected]>'; // <em> is html, <em... is not
672
+		$after = dol_textishtml($input);
673 673
 		$this->assertFalse($after);
674
-		$input='xxx <brstyle="ee">';
675
-		$after=dol_textishtml($input);
674
+		$input = 'xxx <brstyle="ee">';
675
+		$after = dol_textishtml($input);
676 676
 		$this->assertFalse($after);
677
-		$input='This is a text with html comments <!-- comment -->';	// we suppose this is not enough to be html content
678
-		$after=dol_textishtml($input);
677
+		$input = 'This is a text with html comments <!-- comment -->'; // we suppose this is not enough to be html content
678
+		$after = dol_textishtml($input);
679 679
 		$this->assertFalse($after);
680 680
 
681
-		$input="A text\nwith a link https://aaa?param=abc&amp;param2=def";
682
-		$after=dol_textishtml($input);
681
+		$input = "A text\nwith a link https://aaa?param=abc&amp;param2=def";
682
+		$after = dol_textishtml($input);
683 683
 		$this->assertFalse($after);
684 684
 	}
685 685
 
@@ -691,32 +691,32 @@  discard block
 block discarded – undo
691 691
 	 */
692 692
 	public function testDolHtmlCleanLastBr()
693 693
 	{
694
-		$input="A string\n";
695
-		$after=dol_htmlcleanlastbr($input);
694
+		$input = "A string\n";
695
+		$after = dol_htmlcleanlastbr($input);
696 696
 		$this->assertEquals("A string", $after);
697 697
 
698
-		$input="A string first\nA string second\n";
699
-		$after=dol_htmlcleanlastbr($input);
698
+		$input = "A string first\nA string second\n";
699
+		$after = dol_htmlcleanlastbr($input);
700 700
 		$this->assertEquals("A string first\nA string second", $after);
701 701
 
702
-		$input="A string\n\n\n";
703
-		$after=dol_htmlcleanlastbr($input);
702
+		$input = "A string\n\n\n";
703
+		$after = dol_htmlcleanlastbr($input);
704 704
 		$this->assertEquals("A string", $after);
705 705
 
706
-		$input="A string<br>";
707
-		$after=dol_htmlcleanlastbr($input);
706
+		$input = "A string<br>";
707
+		$after = dol_htmlcleanlastbr($input);
708 708
 		$this->assertEquals("A string", $after);
709 709
 
710
-		$input="A string first<br>\nA string second<br>";
711
-		$after=dol_htmlcleanlastbr($input);
710
+		$input = "A string first<br>\nA string second<br>";
711
+		$after = dol_htmlcleanlastbr($input);
712 712
 		$this->assertEquals("A string first<br>\nA string second", $after);
713 713
 
714
-		$input="A string\n<br type=\"_moz\" />\n";
715
-		$after=dol_htmlcleanlastbr($input);
714
+		$input = "A string\n<br type=\"_moz\" />\n";
715
+		$after = dol_htmlcleanlastbr($input);
716 716
 		$this->assertEquals("A string", $after);
717 717
 
718
-		$input="A string\n<br><br />\n\n";
719
-		$after=dol_htmlcleanlastbr($input);
718
+		$input = "A string\n<br><br />\n\n";
719
+		$after = dol_htmlcleanlastbr($input);
720 720
 		$this->assertEquals("A string", $after);
721 721
 
722 722
 		return true;
@@ -729,19 +729,19 @@  discard block
 block discarded – undo
729 729
 	 */
730 730
 	public function testDolConcat()
731 731
 	{
732
-		$text1="A string 1";
733
-		$text2="A string 2";	// text 1 and 2 are text, concat need only \n
734
-		$after=dol_concatdesc($text1, $text2);
732
+		$text1 = "A string 1";
733
+		$text2 = "A string 2"; // text 1 and 2 are text, concat need only \n
734
+		$after = dol_concatdesc($text1, $text2);
735 735
 		$this->assertEquals("A string 1\nA string 2", $after);
736 736
 
737
-		$text1="A<br>string 1";
738
-		$text2="A string 2";	// text 1 is html, concat need <br>\n
739
-		$after=dol_concatdesc($text1, $text2);
737
+		$text1 = "A<br>string 1";
738
+		$text2 = "A string 2"; // text 1 is html, concat need <br>\n
739
+		$after = dol_concatdesc($text1, $text2);
740 740
 		$this->assertEquals("A<br>string 1<br>\nA string 2", $after);
741 741
 
742
-		$text1="A string 1";
743
-		$text2="A <b>string</b> 2";	// text 2 is html, concat need <br>\n
744
-		$after=dol_concatdesc($text1, $text2);
742
+		$text1 = "A string 1";
743
+		$text2 = "A <b>string</b> 2"; // text 2 is html, concat need <br>\n
744
+		$after = dol_concatdesc($text1, $text2);
745 745
 		$this->assertEquals("A string 1<br>\nA <b>string</b> 2", $after);
746 746
 
747 747
 		return true;
@@ -779,52 +779,52 @@  discard block
 block discarded – undo
779 779
 	 */
780 780
 	public function testDolStringNohtmltag()
781 781
 	{
782
-		$text="A\nstring\n\nand more\n";
783
-		$after=dol_string_nohtmltag($text, 0);
782
+		$text = "A\nstring\n\nand more\n";
783
+		$after = dol_string_nohtmltag($text, 0);
784 784
 		$this->assertEquals("A\nstring\n\nand more", $after, "test1a");
785 785
 
786
-		$text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
787
-		$after=dol_string_nohtmltag($text, 0);
786
+		$text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
787
+		$after = dol_string_nohtmltag($text, 0);
788 788
 		$this->assertEquals("A string\n\n\n\n\nwith html tag", $after, 'test2a 2 br and 3 \n give 5 \n');
789 789
 
790
-		$text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
791
-		$after=dol_string_nohtmltag($text, 1);
790
+		$text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
791
+		$after = dol_string_nohtmltag($text, 1);
792 792
 		$this->assertEquals("A string with html tag", $after, 'test2b 2 br and 3 \n give 1 space');
793 793
 
794
-		$text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
795
-		$after=dol_string_nohtmltag($text, 2);
794
+		$text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
795
+		$after = dol_string_nohtmltag($text, 2);
796 796
 		$this->assertEquals("A string\n\nwith html tag", $after, 'test2c 2 br and 3 \n give 2 \n');
797 797
 
798
-		$text="A <b>string<b><br>\r\n<br>\r\n\r\nwith html tag<br>\n";
799
-		$after=dol_string_nohtmltag($text, 2);
798
+		$text = "A <b>string<b><br>\r\n<br>\r\n\r\nwith html tag<br>\n";
799
+		$after = dol_string_nohtmltag($text, 2);
800 800
 		$this->assertEquals("A string\n\nwith html tag", $after, 'test2c 2 br and 3 \r\n give 2 \n');
801 801
 
802
-		$text="A string<br>Another string";
803
-		$after=dol_string_nohtmltag($text, 0);
802
+		$text = "A string<br>Another string";
803
+		$after = dol_string_nohtmltag($text, 0);
804 804
 		$this->assertEquals("A string\nAnother string", $after, "test4");
805 805
 
806
-		$text="A string<br>Another string";
807
-		$after=dol_string_nohtmltag($text, 1);
806
+		$text = "A string<br>Another string";
807
+		$after = dol_string_nohtmltag($text, 1);
808 808
 		$this->assertEquals("A string Another string", $after, "test5");
809 809
 
810
-		$text='<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>';
811
-		$after=dol_string_nohtmltag($text, 1);
810
+		$text = '<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>';
811
+		$after = dol_string_nohtmltag($text, 1);
812 812
 		$this->assertEquals("ABC", $after, "test6");
813 813
 
814
-		$text='<a href="/myurl" title="&lt;u&gt;Afficher projet&lt;/u&gt;">DEF</a>';
815
-		$after=dol_string_nohtmltag($text, 1);
814
+		$text = '<a href="/myurl" title="&lt;u&gt;Afficher projet&lt;/u&gt;">DEF</a>';
815
+		$after = dol_string_nohtmltag($text, 1);
816 816
 		$this->assertEquals("DEF", $after, "test7");
817 817
 
818
-		$text='<a href="/myurl" title="<u>A title</u>">HIJ</a>';
819
-		$after=dol_string_nohtmltag($text, 0);
818
+		$text = '<a href="/myurl" title="<u>A title</u>">HIJ</a>';
819
+		$after = dol_string_nohtmltag($text, 0);
820 820
 		$this->assertEquals("HIJ", $after, "test8");
821 821
 
822
-		$text="A <b>string<b>\n\nwith html tag and '<' chars<br>\n";
823
-		$after=dol_string_nohtmltag($text, 0);
822
+		$text = "A <b>string<b>\n\nwith html tag and '<' chars<br>\n";
823
+		$after = dol_string_nohtmltag($text, 0);
824 824
 		$this->assertEquals("A string\n\nwith html tag and '<' chars", $after, "test9");
825 825
 
826
-		$text="A <b>string<b>\n\nwith tag with < chars<br>\n";
827
-		$after=dol_string_nohtmltag($text, 1);
826
+		$text = "A <b>string<b>\n\nwith tag with < chars<br>\n";
827
+		$after = dol_string_nohtmltag($text, 1);
828 828
 		$this->assertEquals("A string with tag with < chars", $after, "test10");
829 829
 
830 830
 		return true;
@@ -841,38 +841,38 @@  discard block
 block discarded – undo
841 841
 	{
842 842
 		// Text not already HTML
843 843
 
844
-		$input="A string\nwith a é, &, < and >.";
845
-		$after=dol_htmlentitiesbr($input, 0);    // Add <br> before \n
844
+		$input = "A string\nwith a é, &, < and >.";
845
+		$after = dol_htmlentitiesbr($input, 0); // Add <br> before \n
846 846
 		$this->assertEquals("A string<br>\nwith a &eacute;, &amp;, &lt; and &gt;.", $after);
847 847
 
848
-		$input="A string\nwith a é, &, < and >.";
849
-		$after=dol_htmlentitiesbr($input, 1);    // Replace \n with <br>
848
+		$input = "A string\nwith a é, &, < and >.";
849
+		$after = dol_htmlentitiesbr($input, 1); // Replace \n with <br>
850 850
 		$this->assertEquals("A string<br>with a &eacute;, &amp;, &lt; and &gt;.", $after);
851 851
 
852
-		$input="A string\nwith a é, &, < and >.\n\n";	// With some \n at end that should be cleaned
853
-		$after=dol_htmlentitiesbr($input, 0);    // Add <br> before \n
852
+		$input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned
853
+		$after = dol_htmlentitiesbr($input, 0); // Add <br> before \n
854 854
 		$this->assertEquals("A string<br>\nwith a &eacute;, &amp;, &lt; and &gt;.", $after);
855 855
 
856
-		$input="A string\nwith a é, &, < and >.\n\n";	// With some \n at end that should be cleaned
857
-		$after=dol_htmlentitiesbr($input, 1);    // Replace \n with <br>
856
+		$input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned
857
+		$after = dol_htmlentitiesbr($input, 1); // Replace \n with <br>
858 858
 		$this->assertEquals("A string<br>with a &eacute;, &amp;, &lt; and &gt;.", $after);
859 859
 
860 860
 		// Text already HTML, so &,<,> should not be converted
861 861
 
862
-		$input="A string<br>\nwith a é, &, < and >.";
863
-		$after=dol_htmlentitiesbr($input);
862
+		$input = "A string<br>\nwith a é, &, < and >.";
863
+		$after = dol_htmlentitiesbr($input);
864 864
 		$this->assertEquals("A string<br>\nwith a &eacute;, &, < and >.", $after);
865 865
 
866
-		$input="<li>\nA string with a é, &, < and >.</li>\nAnother string";
867
-		$after=dol_htmlentitiesbr($input);
866
+		$input = "<li>\nA string with a é, &, < and >.</li>\nAnother string";
867
+		$after = dol_htmlentitiesbr($input);
868 868
 		$this->assertEquals("<li>\nA string with a &eacute;, &, < and >.</li>\nAnother string", $after);
869 869
 
870
-		$input="A string<br>\nwith a é, &, < and >.<br>";	// With some <br> at end that should be cleaned
871
-		$after=dol_htmlentitiesbr($input);
870
+		$input = "A string<br>\nwith a é, &, < and >.<br>"; // With some <br> at end that should be cleaned
871
+		$after = dol_htmlentitiesbr($input);
872 872
 		$this->assertEquals("A string<br>\nwith a &eacute;, &, < and >.", $after);
873 873
 
874
-		$input="<li>\nA string with a é, &, < and >.</li>\nAnother string<br>";	// With some <br> at end that should be cleaned
875
-		$after=dol_htmlentitiesbr($input);
874
+		$input = "<li>\nA string with a é, &, < and >.</li>\nAnother string<br>"; // With some <br> at end that should be cleaned
875
+		$after = dol_htmlentitiesbr($input);
876 876
 		$this->assertEquals("<li>\nA string with a &eacute;, &, < and >.</li>\nAnother string", $after);
877 877
 
878 878
 		// TODO Add test with param $removelasteolbr = 0
@@ -889,18 +889,18 @@  discard block
 block discarded – undo
889 889
 	public function testDolNbOfLinesBis()
890 890
 	{
891 891
 		// This is not a html string so nb of lines depends on \n
892
-		$input="A string\nwith a é, &, < and > and bold tag.\nThird line";
893
-		$after=dol_nboflines_bis($input, 0);
892
+		$input = "A string\nwith a é, &, < and > and bold tag.\nThird line";
893
+		$after = dol_nboflines_bis($input, 0);
894 894
 		$this->assertEquals($after, 3);
895 895
 
896 896
 		// This is a html string so nb of lines depends on <br>
897
-		$input="A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line";
898
-		$after=dol_nboflines_bis($input, 0);
897
+		$input = "A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line";
898
+		$after = dol_nboflines_bis($input, 0);
899 899
 		$this->assertEquals($after, 1);
900 900
 
901 901
 		// This is a html string so nb of lines depends on <br>
902
-		$input="A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line";
903
-		$after=dol_nboflines_bis($input, 0);
902
+		$input = "A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line";
903
+		$after = dol_nboflines_bis($input, 0);
904 904
 		$this->assertEquals($after, 3);
905 905
 
906 906
 		return true;
@@ -916,8 +916,8 @@  discard block
 block discarded – undo
916 916
 	{
917 917
 		// Text not already HTML
918 918
 
919
-		$input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >.";
920
-		$after=dol_string_unaccent($input);
919
+		$input = "A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >.";
920
+		$after = dol_string_unaccent($input);
921 921
 		$this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.", $after);
922 922
 	}
923 923
 
@@ -930,17 +930,17 @@  discard block
 block discarded – undo
930 930
 	public function testDolUtf8Check()
931 931
 	{
932 932
 		// True
933
-		$result=utf8_check('azerty');
933
+		$result = utf8_check('azerty');
934 934
 		$this->assertTrue($result);
935 935
 
936
-		$file=dirname(__FILE__).'/textutf8.txt';
937
-		$filecontent=file_get_contents($file);
938
-		$result=utf8_check($filecontent);
936
+		$file = dirname(__FILE__).'/textutf8.txt';
937
+		$filecontent = file_get_contents($file);
938
+		$result = utf8_check($filecontent);
939 939
 		$this->assertTrue($result);
940 940
 
941
-		$file=dirname(__FILE__).'/textiso.txt';
942
-		$filecontent=file_get_contents($file);
943
-		$result=utf8_check($filecontent);
941
+		$file = dirname(__FILE__).'/textiso.txt';
942
+		$filecontent = file_get_contents($file);
943
+		$result = utf8_check($filecontent);
944 944
 		$this->assertFalse($result);
945 945
 	}
946 946
 
@@ -952,15 +952,15 @@  discard block
 block discarded – undo
952 952
 	public function testDolAsciiCheck()
953 953
 	{
954 954
 		// True
955
-		$result=ascii_check('azerty');
955
+		$result = ascii_check('azerty');
956 956
 		$this->assertTrue($result);
957 957
 
958
-		$result=ascii_check('é');
958
+		$result = ascii_check('é');
959 959
 		$this->assertFalse($result);
960 960
 
961
-		$file=dirname(__FILE__).'/textutf8.txt';
962
-		$filecontent=file_get_contents($file);
963
-		$result=ascii_check($filecontent);
961
+		$file = dirname(__FILE__).'/textutf8.txt';
962
+		$filecontent = file_get_contents($file);
963
+		$result = ascii_check($filecontent);
964 964
 		$this->assertFalse($result);
965 965
 	}
966 966
 
@@ -972,49 +972,49 @@  discard block
 block discarded – undo
972 972
 	public function testDolTrunc()
973 973
 	{
974 974
 		// Default trunc (will add … if truncation truncation or keep last char if only one char)
975
-		$input="éeéeéeàa";
976
-		$after=dol_trunc($input, 3);
975
+		$input = "éeéeéeàa";
976
+		$after = dol_trunc($input, 3);
977 977
 		$this->assertEquals("éeé…", $after, 'Test A1');
978
-		$after=dol_trunc($input, 2);
978
+		$after = dol_trunc($input, 2);
979 979
 		$this->assertEquals("ée…", $after, 'Test A2');
980
-		$after=dol_trunc($input, 1);
980
+		$after = dol_trunc($input, 1);
981 981
 		$this->assertEquals("é…", $after, 'Test A3');
982
-		$input="éeée";
983
-		$after=dol_trunc($input, 3);
982
+		$input = "éeée";
983
+		$after = dol_trunc($input, 3);
984 984
 		$this->assertEquals("éeée", $after, 'Test B1');
985
-		$after=dol_trunc($input, 2);
985
+		$after = dol_trunc($input, 2);
986 986
 		$this->assertEquals("ée…", $after, 'Test B2');
987
-		$after=dol_trunc($input, 1);
987
+		$after = dol_trunc($input, 1);
988 988
 		$this->assertEquals("é…", $after, 'Test B3');
989
-		$input="éeée";
990
-		$after=dol_trunc($input, 3);
989
+		$input = "éeée";
990
+		$after = dol_trunc($input, 3);
991 991
 		$this->assertEquals("éeée", $after, 'Test C1');
992
-		$after=dol_trunc($input, 2);
992
+		$after = dol_trunc($input, 2);
993 993
 		$this->assertEquals("ée…", $after, 'Test C2');
994
-		$after=dol_trunc($input, 1);
994
+		$after = dol_trunc($input, 1);
995 995
 		$this->assertEquals("é…", $after, 'Test C3');
996
-		$input="éeé";
997
-		$after=dol_trunc($input, 3);
996
+		$input = "éeé";
997
+		$after = dol_trunc($input, 3);
998 998
 		$this->assertEquals("éeé", $after, 'Test C');
999
-		$after=dol_trunc($input, 2);
999
+		$after = dol_trunc($input, 2);
1000 1000
 		$this->assertEquals("éeé", $after, 'Test D');
1001
-		$after=dol_trunc($input, 1);
1001
+		$after = dol_trunc($input, 1);
1002 1002
 		$this->assertEquals("é…", $after, 'Test E');
1003 1003
 		// Trunc with no …
1004
-		$input="éeéeéeàa";
1005
-		$after=dol_trunc($input, 3, 'right', 'UTF-8', 1);
1004
+		$input = "éeéeéeàa";
1005
+		$after = dol_trunc($input, 3, 'right', 'UTF-8', 1);
1006 1006
 		$this->assertEquals("éeé", $after, 'Test F');
1007
-		$after=dol_trunc($input, 2, 'right', 'UTF-8', 1);
1007
+		$after = dol_trunc($input, 2, 'right', 'UTF-8', 1);
1008 1008
 		$this->assertEquals("ée", $after, 'Test G');
1009
-		$input="éeé";
1010
-		$after=dol_trunc($input, 3, 'right', 'UTF-8', 1);
1009
+		$input = "éeé";
1010
+		$after = dol_trunc($input, 3, 'right', 'UTF-8', 1);
1011 1011
 		$this->assertEquals("éeé", $after, 'Test H');
1012
-		$after=dol_trunc($input, 2, 'right', 'UTF-8', 1);
1012
+		$after = dol_trunc($input, 2, 'right', 'UTF-8', 1);
1013 1013
 		$this->assertEquals("ée", $after, 'Test I');
1014
-		$after=dol_trunc($input, 1, 'right', 'UTF-8', 1);
1014
+		$after = dol_trunc($input, 1, 'right', 'UTF-8', 1);
1015 1015
 		$this->assertEquals("é", $after, 'Test J');
1016
-		$input="éeéeéeàa";
1017
-		$after=dol_trunc($input, 4, 'middle');
1016
+		$input = "éeéeéeàa";
1017
+		$after = dol_trunc($input, 4, 'middle');
1018 1018
 		$this->assertEquals("ée…àa", $after, 'Test K');
1019 1019
 
1020 1020
 		return true;
@@ -1029,49 +1029,49 @@  discard block
 block discarded – undo
1029 1029
 	{
1030 1030
 		global $conf;
1031 1031
 
1032
-		$savtz=date_default_timezone_get();
1032
+		$savtz = date_default_timezone_get();
1033 1033
 
1034 1034
 		// Some test for UTC TZ
1035 1035
 		date_default_timezone_set('UTC');
1036 1036
 
1037 1037
 		// Check bad hours
1038
-		$result=dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1);    // Error (25 hours)
1038
+		$result = dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1); // Error (25 hours)
1039 1039
 		print __METHOD__." result=".$result."\n";
1040 1040
 		$this->assertEquals('', $result);
1041
-		$result=dol_mktime(2, 61, 0, 1, 1, 1970, 1, 1);    // Error (61 minutes)
1041
+		$result = dol_mktime(2, 61, 0, 1, 1, 1970, 1, 1); // Error (61 minutes)
1042 1042
 		print __METHOD__." result=".$result."\n";
1043 1043
 		$this->assertEquals('', $result);
1044
-		$result=dol_mktime(2, 1, 61, 1, 1, 1970, 1, 1);    // Error (61 seconds)
1044
+		$result = dol_mktime(2, 1, 61, 1, 1, 1970, 1, 1); // Error (61 seconds)
1045 1045
 		print __METHOD__." result=".$result."\n";
1046 1046
 		$this->assertEquals('', $result);
1047
-		$result=dol_mktime(2, 1, 1, 1, 32, 1970, 1, 1);    // Error (day 32)
1047
+		$result = dol_mktime(2, 1, 1, 1, 32, 1970, 1, 1); // Error (day 32)
1048 1048
 		print __METHOD__." result=".$result."\n";
1049 1049
 		$this->assertEquals('', $result);
1050
-		$result=dol_mktime(2, 1, 1, 13, 1, 1970, 1, 1);    // Error (month 13)
1050
+		$result = dol_mktime(2, 1, 1, 13, 1, 1970, 1, 1); // Error (month 13)
1051 1051
 		print __METHOD__." result=".$result."\n";
1052 1052
 		$this->assertEquals('', $result);
1053 1053
 
1054
-		$result=dol_mktime(2, 1, 1, 1, 1, 1970, 1);    // 1970-01-01 02:01:01 in GMT area -> 7261
1054
+		$result = dol_mktime(2, 1, 1, 1, 1, 1970, 1); // 1970-01-01 02:01:01 in GMT area -> 7261
1055 1055
 		print __METHOD__." result=".$result."\n";
1056 1056
 		$this->assertEquals(7261, $result);
1057 1057
 
1058
-		$result=dol_mktime(2, 0, 0, 1, 1, 1970, 0);                // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
1058
+		$result = dol_mktime(2, 0, 0, 1, 1, 1970, 0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
1059 1059
 		print __METHOD__." result=".$result."\n";
1060
-		$tz=getServerTimeZoneInt('winter');                  // +1 in Europe/Paris at this time (this time is winter)
1061
-		$this->assertEquals(7200-($tz*3600), $result);        // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter
1060
+		$tz = getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter)
1061
+		$this->assertEquals(7200 - ($tz * 3600), $result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter
1062 1062
 
1063 1063
 		// Some test for local TZ Europe/Paris
1064 1064
 		date_default_timezone_set('Europe/Paris');
1065 1065
 
1066 1066
 		// Check that tz for paris in winter is used
1067
-		$result=dol_mktime(2, 0, 0, 1, 1, 1970, 'server');         // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
1067
+		$result = dol_mktime(2, 0, 0, 1, 1, 1970, 'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
1068 1068
 		print __METHOD__." result=".$result."\n";
1069
-		$this->assertEquals(3600, $result);        			 // 7200 if we are at greenwich winter, 3600 at Europe/Paris
1069
+		$this->assertEquals(3600, $result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris
1070 1070
 
1071 1071
 		// Check that daylight saving time is used
1072
-		$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
1072
+		$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
1073 1073
 		print __METHOD__." result=".$result."\n";
1074
-		$this->assertEquals(1401588000-3600-3600, $result);  // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer
1074
+		$this->assertEquals(1401588000 - 3600 - 3600, $result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer
1075 1075
 
1076 1076
 		date_default_timezone_set($savtz);
1077 1077
 	}
@@ -1084,14 +1084,14 @@  discard block
 block discarded – undo
1084 1084
 	 */
1085 1085
 	public function testDolEscapeJs()
1086 1086
 	{
1087
-		$input="x&<b>#</b>,\"'";    // " will be converted into '
1088
-		$result=dol_escape_js($input);
1087
+		$input = "x&<b>#</b>,\"'"; // " will be converted into '
1088
+		$result = dol_escape_js($input);
1089 1089
 		$this->assertEquals("x&<b>#</b>,\'\'", $result, "Test mode=0");
1090 1090
 
1091
-		$result=dol_escape_js($input, 1);
1091
+		$result = dol_escape_js($input, 1);
1092 1092
 		$this->assertEquals("x&<b>#</b>,\"\'", $result, "Test mode=1");
1093 1093
 
1094
-		$result=dol_escape_js($input, 2);
1094
+		$result = dol_escape_js($input, 2);
1095 1095
 		$this->assertEquals("x&<b>#</b>,\\\"'", $result, "Test mode=2");
1096 1096
 	}
1097 1097
 
@@ -1103,12 +1103,12 @@  discard block
 block discarded – undo
1103 1103
 	*/
1104 1104
 	public function testDolEscapeHtmlTag()
1105 1105
 	{
1106
-		$input='x&<b>#</b>,"';    // & and " are converted into html entities, <b> are removed
1107
-		$result=dol_escape_htmltag($input);
1106
+		$input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are removed
1107
+		$result = dol_escape_htmltag($input);
1108 1108
 		$this->assertEquals('x&amp;#,&quot;', $result);
1109 1109
 
1110
-		$input='x&<b>#</b>,"';    // & and " are converted into html entities, <b> are not removed
1111
-		$result=dol_escape_htmltag($input, 1);
1110
+		$input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are not removed
1111
+		$result = dol_escape_htmltag($input, 1);
1112 1112
 		$this->assertEquals('x&amp;&lt;b&gt;#&lt;/b&gt;,&quot;', $result);
1113 1113
 	}
1114 1114
 
@@ -1120,33 +1120,33 @@  discard block
 block discarded – undo
1120 1120
 	 */
1121 1121
 	public function testDolFormatAddress()
1122 1122
 	{
1123
-		global $conf,$user,$langs,$db;
1124
-		$conf=$this->savconf;
1125
-		$user=$this->savuser;
1126
-		$langs=$this->savlangs;
1127
-		$db=$this->savdb;
1123
+		global $conf, $user, $langs, $db;
1124
+		$conf = $this->savconf;
1125
+		$user = $this->savuser;
1126
+		$langs = $this->savlangs;
1127
+		$db = $this->savdb;
1128 1128
 
1129
-		$object=new Societe($db);
1129
+		$object = new Societe($db);
1130 1130
 		$object->initAsSpecimen();
1131 1131
 
1132
-		$object->country_code='FR';
1133
-		$address=dol_format_address($object);
1132
+		$object->country_code = 'FR';
1133
+		$address = dol_format_address($object);
1134 1134
 		$this->assertEquals("21 jump street\n99999 MyTown", $address);
1135 1135
 
1136
-		$object->country_code='GB';
1137
-		$address=dol_format_address($object);
1136
+		$object->country_code = 'GB';
1137
+		$address = dol_format_address($object);
1138 1138
 		$this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address);
1139 1139
 
1140
-		$object->country_code='US';
1141
-		$address=dol_format_address($object);
1140
+		$object->country_code = 'US';
1141
+		$address = dol_format_address($object);
1142 1142
 		$this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address);
1143 1143
 
1144
-		$object->country_code='AU';
1145
-		$address=dol_format_address($object);
1144
+		$object->country_code = 'AU';
1145
+		$address = dol_format_address($object);
1146 1146
 		$this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address);
1147 1147
 
1148
-		$object->country_code='JP';
1149
-		$address=dol_format_address($object);
1148
+		$object->country_code = 'JP';
1149
+		$address = dol_format_address($object);
1150 1150
 		$this->assertEquals("21 jump street\nMyState, MyTown 99999", $address);
1151 1151
 	}
1152 1152
 
@@ -1158,29 +1158,29 @@  discard block
 block discarded – undo
1158 1158
 	 */
1159 1159
 	public function testDolPrintPhone()
1160 1160
 	{
1161
-		global $conf,$user,$langs,$db;
1162
-		$conf=$this->savconf;
1163
-		$user=$this->savuser;
1164
-		$langs=$this->savlangs;
1165
-		$db=$this->savdb;
1161
+		global $conf, $user, $langs, $db;
1162
+		$conf = $this->savconf;
1163
+		$user = $this->savuser;
1164
+		$langs = $this->savlangs;
1165
+		$db = $this->savdb;
1166 1166
 
1167
-		$object=new Societe($db);
1167
+		$object = new Societe($db);
1168 1168
 		$object->initAsSpecimen();
1169 1169
 
1170
-		$object->country_code='FR';
1171
-		$phone=dol_print_phone('1234567890', $object->country_code);
1170
+		$object->country_code = 'FR';
1171
+		$phone = dol_print_phone('1234567890', $object->country_code);
1172 1172
 		$this->assertEquals('<span style="margin-right: 10px;">12&nbsp;34&nbsp;56&nbsp;78&nbsp;90</span>', $phone, 'Phone for FR 1');
1173 1173
 
1174
-		$object->country_code='FR';
1175
-		$phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, '');
1174
+		$object->country_code = 'FR';
1175
+		$phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, '');
1176 1176
 		$this->assertEquals('<span style="margin-right: 10px;">1234567890</span>', $phone, 'Phone for FR 2');
1177 1177
 
1178
-		$object->country_code='FR';
1179
-		$phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
1178
+		$object->country_code = 'FR';
1179
+		$phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
1180 1180
 		$this->assertEquals('<span style="margin-right: 10px;">12 34 56 78 90</span>', $phone, 'Phone for FR 3');
1181 1181
 
1182
-		$object->country_code='CA';
1183
-		$phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
1182
+		$object->country_code = 'CA';
1183
+		$phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
1184 1184
 		$this->assertEquals('<span style="margin-right: 10px;">(123) 456-7890</span>', $phone, 'Phone for CA 1');
1185 1185
 	}
1186 1186
 
@@ -1192,24 +1192,24 @@  discard block
 block discarded – undo
1192 1192
 	 */
1193 1193
 	public function testImgPicto()
1194 1194
 	{
1195
-		$s=img_picto('title', 'user');
1195
+		$s = img_picto('title', 'user');
1196 1196
 		print __METHOD__." s=".$s."\n";
1197 1197
 		$this->assertStringContainsStringIgnoringCase('fa-user', $s, 'testImgPicto1');
1198 1198
 
1199
-		$s=img_picto('title', 'img.png', 'style="float: right"', 0);
1199
+		$s = img_picto('title', 'img.png', 'style="float: right"', 0);
1200 1200
 		print __METHOD__." s=".$s."\n";
1201 1201
 		$this->assertStringContainsStringIgnoringCase('theme', $s, 'testImgPicto2');
1202 1202
 		$this->assertStringContainsStringIgnoringCase('style="float: right"', $s, 'testImgPicto2');
1203 1203
 
1204
-		$s=img_picto('title', '/fullpath/img.png', '', 1);
1204
+		$s = img_picto('title', '/fullpath/img.png', '', 1);
1205 1205
 		print __METHOD__." s=".$s."\n";
1206 1206
 		$this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto3');
1207 1207
 
1208
-		$s=img_picto('title', '/fullpath/img.png', '', true);
1208
+		$s = img_picto('title', '/fullpath/img.png', '', true);
1209 1209
 		print __METHOD__." s=".$s."\n";
1210 1210
 		$this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto4');
1211 1211
 
1212
-		$s=img_picto('title', 'delete', '', 0, 1);
1212
+		$s = img_picto('title', 'delete', '', 0, 1);
1213 1213
 		print __METHOD__." s=".$s."\n";
1214 1214
 		$this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png', $s, 'testImgPicto5');
1215 1215
 	}
@@ -1221,10 +1221,10 @@  discard block
 block discarded – undo
1221 1221
 	 */
1222 1222
 	public function testDolNow()
1223 1223
 	{
1224
-		$now=dol_now('gmt');
1225
-		$nowtzserver=dol_now('tzserver');
1226
-		print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now')*3600)."\n";
1227
-		$this->assertEquals(getServerTimeZoneInt('now')*3600, ($nowtzserver-$now));
1224
+		$now = dol_now('gmt');
1225
+		$nowtzserver = dol_now('tzserver');
1226
+		print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now') * 3600)."\n";
1227
+		$this->assertEquals(getServerTimeZoneInt('now') * 3600, ($nowtzserver - $now));
1228 1228
 	}
1229 1229
 
1230 1230
 	/**
@@ -1234,25 +1234,25 @@  discard block
 block discarded – undo
1234 1234
 	 */
1235 1235
 	public function testVerifCond()
1236 1236
 	{
1237
-		$verifcond=verifCond('1==1');
1237
+		$verifcond = verifCond('1==1');
1238 1238
 		$this->assertTrue($verifcond, 'Test a true comparison');
1239 1239
 
1240
-		$verifcond=verifCond('1==2');
1240
+		$verifcond = verifCond('1==2');
1241 1241
 		$this->assertFalse($verifcond, 'Test a false comparison');
1242 1242
 
1243
-		$verifcond=verifCond('isModEnabled("facture")');
1243
+		$verifcond = verifCond('isModEnabled("facture")');
1244 1244
 		$this->assertTrue($verifcond, 'Test that the conf property of a module reports true when enabled');
1245 1245
 
1246
-		$verifcond=verifCond('isModEnabled("moduledummy")');
1246
+		$verifcond = verifCond('isModEnabled("moduledummy")');
1247 1247
 		$this->assertFalse($verifcond, 'Test that the conf property of a module reports false when disabled');
1248 1248
 
1249
-		$verifcond=verifCond(0);
1249
+		$verifcond = verifCond(0);
1250 1250
 		$this->assertFalse($verifcond, 'Test that verifConf(0) return False');
1251 1251
 
1252
-		$verifcond=verifCond("0");
1252
+		$verifcond = verifCond("0");
1253 1253
 		$this->assertFalse($verifcond, 'Test that verifConf("0") return False');
1254 1254
 
1255
-		$verifcond=verifCond('');
1255
+		$verifcond = verifCond('');
1256 1256
 		$this->assertTrue($verifcond, 'Test that verifConf("") return False (special case)');
1257 1257
 	}
1258 1258
 
@@ -1263,75 +1263,75 @@  discard block
 block discarded – undo
1263 1263
 	 */
1264 1264
 	public function testGetDefaultTva()
1265 1265
 	{
1266
-		global $conf,$user,$langs,$db;
1267
-		$this->savconf=$conf;
1268
-		$this->savuser=$user;
1269
-		$this->savlangs=$langs;
1270
-		$this->savdb=$db;
1266
+		global $conf, $user, $langs, $db;
1267
+		$this->savconf = $conf;
1268
+		$this->savuser = $user;
1269
+		$this->savlangs = $langs;
1270
+		$this->savdb = $db;
1271 1271
 
1272 1272
 		// Sellers
1273
-		$companyfrnovat=new Societe($db);
1274
-		$companyfrnovat->country_code='FR';
1275
-		$companyfrnovat->tva_assuj=0;
1273
+		$companyfrnovat = new Societe($db);
1274
+		$companyfrnovat->country_code = 'FR';
1275
+		$companyfrnovat->tva_assuj = 0;
1276 1276
 
1277
-		$companyfr=new Societe($db);
1278
-		$companyfr->country_code='FR';
1279
-		$companyfr->tva_assuj=1;
1280
-		$companyfr->tva_intra='FR9999';
1277
+		$companyfr = new Societe($db);
1278
+		$companyfr->country_code = 'FR';
1279
+		$companyfr->tva_assuj = 1;
1280
+		$companyfr->tva_intra = 'FR9999';
1281 1281
 
1282 1282
 		// Buyers
1283
-		$companymc=new Societe($db);
1284
-		$companymc->country_code='MC';
1285
-		$companymc->tva_assuj=1;
1286
-		$companyfr->tva_intra='MC9999';
1283
+		$companymc = new Societe($db);
1284
+		$companymc->country_code = 'MC';
1285
+		$companymc->tva_assuj = 1;
1286
+		$companyfr->tva_intra = 'MC9999';
1287 1287
 
1288
-		$companyit=new Societe($db);
1289
-		$companyit->country_code='IT';
1290
-		$companyit->tva_assuj=1;
1291
-		$companyit->tva_intra='IT99999';
1288
+		$companyit = new Societe($db);
1289
+		$companyit->country_code = 'IT';
1290
+		$companyit->tva_assuj = 1;
1291
+		$companyit->tva_intra = 'IT99999';
1292 1292
 
1293
-		$companyde=new Societe($db);
1294
-		$companyde->country_code='DE';
1295
-		$companyde->tva_assuj=1;
1296
-		$companyde->tva_intra='DE99999';
1293
+		$companyde = new Societe($db);
1294
+		$companyde->country_code = 'DE';
1295
+		$companyde->tva_assuj = 1;
1296
+		$companyde->tva_intra = 'DE99999';
1297 1297
 
1298
-		$notcompanyde=new Societe($db);
1299
-		$notcompanyde->country_code='DE';
1300
-		$notcompanyde->tva_assuj=0;
1301
-		$notcompanyde->tva_intra='';
1302
-		$notcompanyde->typent_code='TE_PRIVATE';
1298
+		$notcompanyde = new Societe($db);
1299
+		$notcompanyde->country_code = 'DE';
1300
+		$notcompanyde->tva_assuj = 0;
1301
+		$notcompanyde->tva_intra = '';
1302
+		$notcompanyde->typent_code = 'TE_PRIVATE';
1303 1303
 
1304
-		$companyus=new Societe($db);
1305
-		$companyus->country_code='US';
1306
-		$companyus->tva_assuj=1;
1307
-		$companyus->tva_intra='';
1304
+		$companyus = new Societe($db);
1305
+		$companyus->country_code = 'US';
1306
+		$companyus->tva_assuj = 1;
1307
+		$companyus->tva_intra = '';
1308 1308
 
1309 1309
 
1310 1310
 		// Test RULE 0 (FR-DE)
1311 1311
 		// Not tested
1312 1312
 
1313 1313
 		// Test RULE 1
1314
-		$vat=get_default_tva($companyfrnovat, $companymc, 0);
1314
+		$vat = get_default_tva($companyfrnovat, $companymc, 0);
1315 1315
 		$this->assertEquals(0, $vat, 'RULE 1');
1316 1316
 
1317 1317
 		// Test RULE 2 (FR-FR)
1318
-		$vat=get_default_tva($companyfr, $companyfr, 0);
1318
+		$vat = get_default_tva($companyfr, $companyfr, 0);
1319 1319
 		$this->assertEquals(20, $vat, 'RULE 2');
1320 1320
 
1321 1321
 		// Test RULE 2 (FR-MC)
1322
-		$vat=get_default_tva($companyfr, $companymc, 0);
1322
+		$vat = get_default_tva($companyfr, $companymc, 0);
1323 1323
 		$this->assertEquals(20, $vat, 'RULE 2');
1324 1324
 
1325 1325
 		// Test RULE 3 (FR-DE company)
1326
-		$vat=get_default_tva($companyfr, $companyit, 0);
1326
+		$vat = get_default_tva($companyfr, $companyit, 0);
1327 1327
 		$this->assertEquals(0, $vat, 'RULE 3');
1328 1328
 
1329 1329
 		// Test RULE 4 (FR-DE not a company)
1330
-		$vat=get_default_tva($companyfr, $notcompanyde, 0);
1330
+		$vat = get_default_tva($companyfr, $notcompanyde, 0);
1331 1331
 		$this->assertEquals(20, $vat, 'RULE 4');
1332 1332
 
1333 1333
 		// Test RULE 5 (FR-US)
1334
-		$vat=get_default_tva($companyfr, $companyus, 0);
1334
+		$vat = get_default_tva($companyfr, $companyus, 0);
1335 1335
 		$this->assertEquals(0, $vat, 'RULE 5');
1336 1336
 
1337 1337
 
@@ -1339,23 +1339,23 @@  discard block
 block discarded – undo
1339 1339
 		$conf->global->SERVICE_ARE_ECOMMERCE_200238EC = 1;
1340 1340
 
1341 1341
 		// Test RULE 1 (FR-US)
1342
-		$vat=get_default_tva($companyfr, $companyus, 0);
1342
+		$vat = get_default_tva($companyfr, $companyus, 0);
1343 1343
 		$this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC');
1344 1344
 
1345 1345
 		// Test RULE 2 (FR-FR)
1346
-		$vat=get_default_tva($companyfr, $companyfr, 0);
1346
+		$vat = get_default_tva($companyfr, $companyfr, 0);
1347 1347
 		$this->assertEquals(20, $vat, 'RULE 2 ECOMMERCE_200238EC');
1348 1348
 
1349 1349
 		// Test RULE 3 (FR-DE company)
1350
-		$vat=get_default_tva($companyfr, $companyde, 0);
1350
+		$vat = get_default_tva($companyfr, $companyde, 0);
1351 1351
 		$this->assertEquals(0, $vat, 'RULE 3 ECOMMERCE_200238EC');
1352 1352
 
1353 1353
 		// Test RULE 4 (FR-DE not a company)
1354
-		$vat=get_default_tva($companyfr, $notcompanyde, 0);
1354
+		$vat = get_default_tva($companyfr, $notcompanyde, 0);
1355 1355
 		$this->assertEquals(19, $vat, 'RULE 4 ECOMMERCE_200238EC');
1356 1356
 
1357 1357
 		// Test RULE 5 (FR-US)
1358
-		$vat=get_default_tva($companyfr, $companyus, 0);
1358
+		$vat = get_default_tva($companyfr, $companyus, 0);
1359 1359
 		$this->assertEquals(0, $vat, 'RULE 5 ECOMMERCE_200238EC');
1360 1360
 	}
1361 1361
 
@@ -1366,73 +1366,73 @@  discard block
 block discarded – undo
1366 1366
 	 */
1367 1367
 	public function testGetDefaultLocalTax()
1368 1368
 	{
1369
-		global $conf,$user,$langs,$db;
1370
-		$this->savconf=$conf;
1371
-		$this->savuser=$user;
1372
-		$this->savlangs=$langs;
1373
-		$this->savdb=$db;
1374
-
1375
-		$companyfrnovat=new Societe($db);
1376
-		$companyfrnovat->country_code='FR';
1377
-		$companyfrnovat->tva_assuj=0;
1378
-		$companyfrnovat->localtax1_assuj=0;
1379
-		$companyfrnovat->localtax2_assuj=0;
1380
-
1381
-		$companyes=new Societe($db);
1382
-		$companyes->country_code='ES';
1383
-		$companyes->tva_assuj=1;
1384
-		$companyes->localtax1_assuj=1;
1385
-		$companyes->localtax2_assuj=1;
1386
-
1387
-		$companymc=new Societe($db);
1388
-		$companymc->country_code='MC';
1389
-		$companymc->tva_assuj=1;
1390
-		$companymc->localtax1_assuj=0;
1391
-		$companymc->localtax2_assuj=0;
1392
-
1393
-		$companyit=new Societe($db);
1394
-		$companyit->country_code='IT';
1395
-		$companyit->tva_assuj=1;
1396
-		$companyit->tva_intra='IT99999';
1397
-		$companyit->localtax1_assuj=0;
1398
-		$companyit->localtax2_assuj=0;
1399
-
1400
-		$notcompanyit=new Societe($db);
1401
-		$notcompanyit->country_code='IT';
1402
-		$notcompanyit->tva_assuj=1;
1403
-		$notcompanyit->tva_intra='';
1404
-		$notcompanyit->typent_code='TE_PRIVATE';
1405
-		$notcompanyit->localtax1_assuj=0;
1406
-		$notcompanyit->localtax2_assuj=0;
1407
-
1408
-		$companyus=new Societe($db);
1409
-		$companyus->country_code='US';
1410
-		$companyus->tva_assuj=1;
1411
-		$companyus->tva_intra='';
1412
-		$companyus->localtax1_assuj=0;
1413
-		$companyus->localtax2_assuj=0;
1369
+		global $conf, $user, $langs, $db;
1370
+		$this->savconf = $conf;
1371
+		$this->savuser = $user;
1372
+		$this->savlangs = $langs;
1373
+		$this->savdb = $db;
1374
+
1375
+		$companyfrnovat = new Societe($db);
1376
+		$companyfrnovat->country_code = 'FR';
1377
+		$companyfrnovat->tva_assuj = 0;
1378
+		$companyfrnovat->localtax1_assuj = 0;
1379
+		$companyfrnovat->localtax2_assuj = 0;
1380
+
1381
+		$companyes = new Societe($db);
1382
+		$companyes->country_code = 'ES';
1383
+		$companyes->tva_assuj = 1;
1384
+		$companyes->localtax1_assuj = 1;
1385
+		$companyes->localtax2_assuj = 1;
1386
+
1387
+		$companymc = new Societe($db);
1388
+		$companymc->country_code = 'MC';
1389
+		$companymc->tva_assuj = 1;
1390
+		$companymc->localtax1_assuj = 0;
1391
+		$companymc->localtax2_assuj = 0;
1392
+
1393
+		$companyit = new Societe($db);
1394
+		$companyit->country_code = 'IT';
1395
+		$companyit->tva_assuj = 1;
1396
+		$companyit->tva_intra = 'IT99999';
1397
+		$companyit->localtax1_assuj = 0;
1398
+		$companyit->localtax2_assuj = 0;
1399
+
1400
+		$notcompanyit = new Societe($db);
1401
+		$notcompanyit->country_code = 'IT';
1402
+		$notcompanyit->tva_assuj = 1;
1403
+		$notcompanyit->tva_intra = '';
1404
+		$notcompanyit->typent_code = 'TE_PRIVATE';
1405
+		$notcompanyit->localtax1_assuj = 0;
1406
+		$notcompanyit->localtax2_assuj = 0;
1407
+
1408
+		$companyus = new Societe($db);
1409
+		$companyus->country_code = 'US';
1410
+		$companyus->tva_assuj = 1;
1411
+		$companyus->tva_intra = '';
1412
+		$companyus->localtax1_assuj = 0;
1413
+		$companyus->localtax2_assuj = 0;
1414 1414
 
1415 1415
 		// Test RULE FR-MC
1416
-		$vat1=get_default_localtax($companyfrnovat, $companymc, 1, 0);
1417
-		$vat2=get_default_localtax($companyfrnovat, $companymc, 2, 0);
1416
+		$vat1 = get_default_localtax($companyfrnovat, $companymc, 1, 0);
1417
+		$vat2 = get_default_localtax($companyfrnovat, $companymc, 2, 0);
1418 1418
 		$this->assertEquals(0, $vat1);
1419 1419
 		$this->assertEquals(0, $vat2);
1420 1420
 
1421 1421
 		// Test RULE ES-ES
1422
-		$vat1=get_default_localtax($companyes, $companyes, 1, 0);
1423
-		$vat2=get_default_localtax($companyes, $companyes, 2, 0);
1422
+		$vat1 = get_default_localtax($companyes, $companyes, 1, 0);
1423
+		$vat2 = get_default_localtax($companyes, $companyes, 2, 0);
1424 1424
 		$this->assertEquals($vat1, 5.2);
1425
-		$this->assertStringStartsWith((string) $vat2, '-19:-15:-9');       // Can be -19 (old version) or '-19:-15:-9' (new setup)
1425
+		$this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup)
1426 1426
 
1427 1427
 		// Test RULE ES-IT
1428
-		$vat1=get_default_localtax($companyes, $companyit, 1, 0);
1429
-		$vat2=get_default_localtax($companyes, $companyit, 2, 0);
1428
+		$vat1 = get_default_localtax($companyes, $companyit, 1, 0);
1429
+		$vat2 = get_default_localtax($companyes, $companyit, 2, 0);
1430 1430
 		$this->assertEquals(0, $vat1);
1431 1431
 		$this->assertEquals(0, $vat2);
1432 1432
 
1433 1433
 		// Test RULE ES-IT
1434
-		$vat1=get_default_localtax($companyes, $notcompanyit, 1, 0);
1435
-		$vat2=get_default_localtax($companyes, $notcompanyit, 2, 0);
1434
+		$vat1 = get_default_localtax($companyes, $notcompanyit, 1, 0);
1435
+		$vat2 = get_default_localtax($companyes, $notcompanyit, 2, 0);
1436 1436
 		$this->assertEquals(0, $vat1);
1437 1437
 		$this->assertEquals(0, $vat2);
1438 1438
 
@@ -1440,8 +1440,8 @@  discard block
 block discarded – undo
1440 1440
 		// Not tested
1441 1441
 
1442 1442
 		// Test RULE ES-US
1443
-		$vat1=get_default_localtax($companyes, $companyus, 1, 0);
1444
-		$vat2=get_default_localtax($companyes, $companyus, 2, 0);
1443
+		$vat1 = get_default_localtax($companyes, $companyus, 1, 0);
1444
+		$vat2 = get_default_localtax($companyes, $companyus, 2, 0);
1445 1445
 		$this->assertEquals(0, $vat1);
1446 1446
 		$this->assertEquals(0, $vat2);
1447 1447
 	}
@@ -1475,14 +1475,14 @@  discard block
 block discarded – undo
1475 1475
 	 */
1476 1476
 	public function testDolExplodeIntoArray()
1477 1477
 	{
1478
-		$stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.';
1479
-		$tmp=dolExplodeIntoArray($stringtoexplode, '.', '=');
1478
+		$stringtoexplode = 'AA=B/B.CC=.EE=FF.HH=GG;.';
1479
+		$tmp = dolExplodeIntoArray($stringtoexplode, '.', '=');
1480 1480
 
1481 1481
 		print __METHOD__." tmp=".json_encode($tmp)."\n";
1482 1482
 		$this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}', json_encode($tmp));
1483 1483
 
1484
-		$stringtoexplode="AA=B/B;CC=\n\rEE=FF\nHH=GG;;;\nII=JJ\n";
1485
-		$tmp=dolExplodeIntoArray($stringtoexplode, "(\r\n|\n|\r|;)", '=');
1484
+		$stringtoexplode = "AA=B/B;CC=\n\rEE=FF\nHH=GG;;;\nII=JJ\n";
1485
+		$tmp = dolExplodeIntoArray($stringtoexplode, "(\r\n|\n|\r|;)", '=');
1486 1486
 
1487 1487
 		print __METHOD__." tmp=".json_encode($tmp)."\n";
1488 1488
 		$this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG","II":"JJ"}', json_encode($tmp));
@@ -1610,48 +1610,48 @@  discard block
 block discarded – undo
1610 1610
 
1611 1611
 		$conf->global->MAIN_START_WEEK = 0;
1612 1612
 
1613
-		$tmp=dol_getdate(24*60*60+1, false, 'UTC');		// 2/1/1970 and 1 second = friday
1613
+		$tmp = dol_getdate(24 * 60 * 60 + 1, false, 'UTC'); // 2/1/1970 and 1 second = friday
1614 1614
 		$this->assertEquals(5, $tmp['wday'], 'Bad value of day in week');
1615 1615
 
1616 1616
 		$conf->global->MAIN_START_WEEK = 1;
1617 1617
 
1618
-		$tmp=dol_getdate(1, false, 'UTC');				// 1/1/1970 and 1 second = thirday
1618
+		$tmp = dol_getdate(1, false, 'UTC'); // 1/1/1970 and 1 second = thirday
1619 1619
 		$this->assertEquals(4, $tmp['wday'], 'Bad value of day in week');
1620 1620
 
1621
-		$tmp=dol_getdate(24*60*60+1, false, 'UTC');		// 2/1/1970 and 1 second = friday
1621
+		$tmp = dol_getdate(24 * 60 * 60 + 1, false, 'UTC'); // 2/1/1970 and 1 second = friday
1622 1622
 		$this->assertEquals(5, $tmp['wday'], 'Bad value of day in week');
1623 1623
 
1624
-		$tmp=dol_getdate(1, false, "Europe/Paris");						// 1/1/1970 and 1 second = thirday
1624
+		$tmp = dol_getdate(1, false, "Europe/Paris"); // 1/1/1970 and 1 second = thirday
1625 1625
 		$this->assertEquals(1970, $tmp['year']);
1626 1626
 		$this->assertEquals(1, $tmp['mon']);
1627 1627
 		$this->assertEquals(1, $tmp['mday']);
1628 1628
 		$this->assertEquals(4, $tmp['wday']);
1629 1629
 		$this->assertEquals(0, $tmp['yday']);
1630
-		$this->assertEquals(1, $tmp['hours']);		// We are winter, so we are GMT+1 even during summer
1630
+		$this->assertEquals(1, $tmp['hours']); // We are winter, so we are GMT+1 even during summer
1631 1631
 		$this->assertEquals(0, $tmp['minutes']);
1632 1632
 		$this->assertEquals(1, $tmp['seconds']);
1633 1633
 
1634
-		$tmp=dol_getdate(15638401, false, "Europe/Paris");					// 1/7/1970 and 1 second = wednesday
1634
+		$tmp = dol_getdate(15638401, false, "Europe/Paris"); // 1/7/1970 and 1 second = wednesday
1635 1635
 		$this->assertEquals(1970, $tmp['year']);
1636 1636
 		$this->assertEquals(7, $tmp['mon']);
1637 1637
 		$this->assertEquals(1, $tmp['mday']);
1638 1638
 		$this->assertEquals(3, $tmp['wday']);
1639 1639
 		$this->assertEquals(181, $tmp['yday']);
1640
-		$this->assertEquals(1, $tmp['hours']);		// There is no daylight in 1970, so we are GMT+1 even during summer
1640
+		$this->assertEquals(1, $tmp['hours']); // There is no daylight in 1970, so we are GMT+1 even during summer
1641 1641
 		$this->assertEquals(0, $tmp['minutes']);
1642 1642
 		$this->assertEquals(1, $tmp['seconds']);
1643 1643
 
1644
-		$tmp=dol_getdate(1593561601, false, "Europe/Paris");				// 1/7/2020 and 1 second = wednesday
1644
+		$tmp = dol_getdate(1593561601, false, "Europe/Paris"); // 1/7/2020 and 1 second = wednesday
1645 1645
 		$this->assertEquals(2020, $tmp['year']);
1646 1646
 		$this->assertEquals(7, $tmp['mon']);
1647 1647
 		$this->assertEquals(1, $tmp['mday']);
1648 1648
 		$this->assertEquals(3, $tmp['wday']);
1649
-		$this->assertEquals(182, $tmp['yday']);		// 182 and not 181, due to the 29th february
1650
-		$this->assertEquals(2, $tmp['hours']);		// There is a daylight, so we are GMT+2
1649
+		$this->assertEquals(182, $tmp['yday']); // 182 and not 181, due to the 29th february
1650
+		$this->assertEquals(2, $tmp['hours']); // There is a daylight, so we are GMT+2
1651 1651
 		$this->assertEquals(0, $tmp['minutes']);
1652 1652
 		$this->assertEquals(1, $tmp['seconds']);
1653 1653
 
1654
-		$tmp=dol_getdate(1, false, 'UTC');						// 1/1/1970 and 1 second = thirday
1654
+		$tmp = dol_getdate(1, false, 'UTC'); // 1/1/1970 and 1 second = thirday
1655 1655
 		$this->assertEquals(1970, $tmp['year']);
1656 1656
 		$this->assertEquals(1, $tmp['mon']);
1657 1657
 		$this->assertEquals(1, $tmp['mday']);
@@ -1662,7 +1662,7 @@  discard block
 block discarded – undo
1662 1662
 		$this->assertEquals(0, $tmp['minutes']);
1663 1663
 		$this->assertEquals(1, $tmp['seconds']);
1664 1664
 
1665
-		$tmp=dol_getdate(15638401, false, 'UTC');				// 1/7/1970 and 1 second = wednesday
1665
+		$tmp = dol_getdate(15638401, false, 'UTC'); // 1/7/1970 and 1 second = wednesday
1666 1666
 		$this->assertEquals(1970, $tmp['year']);
1667 1667
 		$this->assertEquals(7, $tmp['mon']);
1668 1668
 		$this->assertEquals(1, $tmp['mday']);
@@ -1673,12 +1673,12 @@  discard block
 block discarded – undo
1673 1673
 		$this->assertEquals(0, $tmp['minutes']);
1674 1674
 		$this->assertEquals(1, $tmp['seconds']);
1675 1675
 
1676
-		$tmp=dol_getdate(1593561601, false, 'UTC');				// 1/7/2020 and 1 second = wednesday
1676
+		$tmp = dol_getdate(1593561601, false, 'UTC'); // 1/7/2020 and 1 second = wednesday
1677 1677
 		$this->assertEquals(2020, $tmp['year']);
1678 1678
 		$this->assertEquals(7, $tmp['mon']);
1679 1679
 		$this->assertEquals(1, $tmp['mday']);
1680 1680
 		$this->assertEquals(3, $tmp['wday']);
1681
-		$this->assertEquals(182, $tmp['yday']);		// 182 and not 181, due to the 29th february
1681
+		$this->assertEquals(182, $tmp['yday']); // 182 and not 181, due to the 29th february
1682 1682
 		// We must disable this because on CI, timezone is may be UTC or something else
1683 1683
 		//$this->assertEquals(2, $tmp['hours']);	// There is a daylight, so we are GMT+2
1684 1684
 		$this->assertEquals(0, $tmp['minutes']);
@@ -1735,11 +1735,11 @@  discard block
 block discarded – undo
1735 1735
 	{
1736 1736
 		global $conf, $langs;
1737 1737
 
1738
-		$chaine='This is an ISO string';
1738
+		$chaine = 'This is an ISO string';
1739 1739
 		$result = dol_string_is_good_iso($chaine);
1740 1740
 		$this->assertEquals($result, 1);
1741 1741
 
1742
-		$chaine='This is a not ISO string '.chr(0);
1742
+		$chaine = 'This is a not ISO string '.chr(0);
1743 1743
 		$result = dol_string_is_good_iso($chaine);
1744 1744
 		$this->assertEquals($result, 0);
1745 1745
 
@@ -1795,18 +1795,18 @@  discard block
 block discarded – undo
1795 1795
 	{
1796 1796
 		global $conf, $langs;
1797 1797
 
1798
-		$_SERVER['HTTP_X_FORWARDED_FOR']='1.2.3.4';
1799
-		$_SERVER['HTTP_CLIENT_IP']='5.6.7.8';
1798
+		$_SERVER['HTTP_X_FORWARDED_FOR'] = '1.2.3.4';
1799
+		$_SERVER['HTTP_CLIENT_IP'] = '5.6.7.8';
1800 1800
 		$result = getUserRemoteIP();
1801 1801
 		$this->assertEquals($result, '1.2.3.4');
1802 1802
 
1803
-		$_SERVER['HTTP_X_FORWARDED_FOR']='1.2.3.4<corrupted>';
1804
-		$_SERVER['HTTP_CLIENT_IP']='5.6.7.8';
1803
+		$_SERVER['HTTP_X_FORWARDED_FOR'] = '1.2.3.4<corrupted>';
1804
+		$_SERVER['HTTP_CLIENT_IP'] = '5.6.7.8';
1805 1805
 		$result = getUserRemoteIP();
1806 1806
 		$this->assertEquals($result, '5.6.7.8');
1807 1807
 
1808
-		$_SERVER['HTTP_X_FORWARDED_FOR']='[1:2:3:4]';
1809
-		$_SERVER['HTTP_CLIENT_IP']='5.6.7.8';
1808
+		$_SERVER['HTTP_X_FORWARDED_FOR'] = '[1:2:3:4]';
1809
+		$_SERVER['HTTP_CLIENT_IP'] = '5.6.7.8';
1810 1810
 		$result = getUserRemoteIP();
1811 1811
 		$this->assertEquals($result, '[1:2:3:4]');
1812 1812
 
Please login to merge, or discard this patch.
test/phpunit/FactureFournisseurTest.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
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';
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	$user->fetch(1);
38 38
 	$user->getrights();
39 39
 }
40
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
40
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
41 41
 
42 42
 
43 43
 /**
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function testFactureFournisseurCreate()
58 58
 	{
59
-		global $conf,$user,$langs,$db;
60
-		$conf=$this->savconf;
61
-		$user=$this->savuser;
62
-		$langs=$this->savlangs;
63
-		$db=$this->savdb;
59
+		global $conf, $user, $langs, $db;
60
+		$conf = $this->savconf;
61
+		$user = $this->savuser;
62
+		$langs = $this->savlangs;
63
+		$db = $this->savdb;
64 64
 
65
-		$localobject=new FactureFournisseur($db);
65
+		$localobject = new FactureFournisseur($db);
66 66
 		$localobject->initAsSpecimen();
67
-		$result=$localobject->create($user);
67
+		$result = $localobject->create($user);
68 68
 
69 69
 		$this->assertLessThan($result, 0, $localobject->errorsToString());
70 70
 		print __METHOD__." result=".$result."\n";
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function testFactureFournisseurFetch($id)
84 84
 	{
85
-		global $conf,$user,$langs,$db;
86
-		$conf=$this->savconf;
87
-		$user=$this->savuser;
88
-		$langs=$this->savlangs;
89
-		$db=$this->savdb;
85
+		global $conf, $user, $langs, $db;
86
+		$conf = $this->savconf;
87
+		$user = $this->savuser;
88
+		$langs = $this->savlangs;
89
+		$db = $this->savdb;
90 90
 
91
-		$localobject=new FactureFournisseur($db);
92
-		$result=$localobject->fetch($id);
91
+		$localobject = new FactureFournisseur($db);
92
+		$result = $localobject->fetch($id);
93 93
 
94 94
 		$this->assertLessThan($result, 0, $localobject->errorsToString());
95 95
 		print __METHOD__." id=".$id." result=".$result."\n";
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function testFactureFournisseurUpdate($localobject)
109 109
 	{
110
-		global $conf,$user,$langs,$db;
111
-		$conf=$this->savconf;
112
-		$user=$this->savuser;
113
-		$langs=$this->savlangs;
114
-		$db=$this->savdb;
110
+		global $conf, $user, $langs, $db;
111
+		$conf = $this->savconf;
112
+		$user = $this->savuser;
113
+		$langs = $this->savlangs;
114
+		$db = $this->savdb;
115 115
 
116
-		$localobject->note='New note after update';
117
-		$result=$localobject->update($user);
116
+		$localobject->note = 'New note after update';
117
+		$result = $localobject->update($user);
118 118
 
119 119
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
120 120
 		$this->assertLessThan($result, 0, $localobject->errorsToString());
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	public function testFactureFournisseurValid($localobject)
134 134
 	{
135
-		global $conf,$user,$langs,$db;
136
-		$conf=$this->savconf;
137
-		$user=$this->savuser;
138
-		$langs=$this->savlangs;
139
-		$db=$this->savdb;
135
+		global $conf, $user, $langs, $db;
136
+		$conf = $this->savconf;
137
+		$user = $this->savuser;
138
+		$langs = $this->savlangs;
139
+		$db = $this->savdb;
140 140
 
141
-		$result=$localobject->validate($user);
141
+		$result = $localobject->validate($user);
142 142
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
143 143
 
144 144
 		$this->assertLessThan($result, 0, $localobject->errorsToString());
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function testFactureFournisseurOther($localobject)
158 158
 	{
159
-		global $conf,$user,$langs,$db;
160
-		$conf=$this->savconf;
161
-		$user=$this->savuser;
162
-		$langs=$this->savlangs;
163
-		$db=$this->savdb;
159
+		global $conf, $user, $langs, $db;
160
+		$conf = $this->savconf;
161
+		$user = $this->savuser;
162
+		$langs = $this->savlangs;
163
+		$db = $this->savdb;
164 164
 
165 165
 		/*$result=$localobject->setstatus(0);
166 166
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	public function testFactureFournisseurDelete($id)
187 187
 	{
188
-		global $conf,$user,$langs,$db;
189
-		$conf=$this->savconf;
190
-		$user=$this->savuser;
191
-		$langs=$this->savlangs;
192
-		$db=$this->savdb;
193
-
194
-		$localobject=new FactureFournisseur($db);
195
-		$result=$localobject->fetch($id);
196
-		$result=$localobject->delete($user);
188
+		global $conf, $user, $langs, $db;
189
+		$conf = $this->savconf;
190
+		$user = $this->savuser;
191
+		$langs = $this->savlangs;
192
+		$db = $this->savdb;
193
+
194
+		$localobject = new FactureFournisseur($db);
195
+		$result = $localobject->fetch($id);
196
+		$result = $localobject->delete($user);
197 197
 
198 198
 		print __METHOD__." id=".$id." result=".$result."\n";
199 199
 		$this->assertLessThan($result, 0, $localobject->errorsToString());
Please login to merge, or discard this patch.
test/phpunit/CommonClassTest.class.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *      \remarks    Class that extends all PHPunit tests. To share similare code between each test.
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';
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
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
 
40 40
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 		parent::__construct($name);
63 63
 
64 64
 		//$this->sharedFixture
65
-		global $conf,$user,$langs,$db;
66
-		$this->savconf=$conf;
67
-		$this->savuser=$user;
68
-		$this->savlangs=$langs;
69
-		$this->savdb=$db;
65
+		global $conf, $user, $langs, $db;
66
+		$this->savconf = $conf;
67
+		$this->savuser = $user;
68
+		$this->savlangs = $langs;
69
+		$this->savdb = $db;
70 70
 
71 71
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72 72
 		//print " - db ".$db->db;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public static function setUpBeforeClass(): void
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
 		if (!isModEnabled('agenda')) {
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		// Show log file
114 114
 		print "\n----- Test fails. Show last ".$nbLinesToShow." lines of dolibarr.log file -----\n";
115 115
 		foreach ($dernieresLignes as $ligne) {
116
-			print $ligne . "<br>";
116
+			print $ligne."<br>";
117 117
 		}
118 118
 
119 119
 		parent::onNotSuccessfulTest($t);
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function setUp(): void
128 128
 	{
129
-		global $conf,$user,$langs,$db;
129
+		global $conf, $user, $langs, $db;
130 130
 
131
-		$conf=$this->savconf;
132
-		$user=$this->savuser;
133
-		$langs=$this->savlangs;
134
-		$db=$this->savdb;
131
+		$conf = $this->savconf;
132
+		$user = $this->savuser;
133
+		$langs = $this->savlangs;
134
+		$db = $this->savdb;
135 135
 
136 136
 		print __METHOD__."\n";
137 137
 		//print $db->getVersion()."\n";
Please login to merge, or discard this patch.
test/phpunit/WebservicesProductsTest.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
  *      \remarks    To run this script as CLI:  phpunit filename.php
27 27
  */
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 33
 require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
34
-require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
34
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
35 35
 require_once dirname(__FILE__).'/CommonClassTest.class.php';
36 36
 
37 37
 if (empty($user->id)) {
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 	$user->fetch(1);
40 40
 	$user->getrights();
41 41
 }
42
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
42
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
43 43
 
44
-$conf->global->MAIN_UMASK='0666';
44
+$conf->global->MAIN_UMASK = '0666';
45 45
 
46 46
 if (!isModEnabled('service')) {
47 47
 	print "Error: Module service must be enabled.\n";
@@ -64,28 +64,28 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function testWSProductsCreateProductOrService()
66 66
 	{
67
-		global $conf,$user,$langs,$db;
68
-		$conf=$this->savconf;
69
-		$user=$this->savuser;
70
-		$langs=$this->savlangs;
71
-		$db=$this->savdb;
67
+		global $conf, $user, $langs, $db;
68
+		$conf = $this->savconf;
69
+		$user = $this->savuser;
70
+		$langs = $this->savlangs;
71
+		$db = $this->savdb;
72 72
 
73
-		$datestring=dol_print_date(dol_now(), 'dayhourlog');
73
+		$datestring = dol_print_date(dol_now(), 'dayhourlog');
74 74
 
75 75
 		$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
76 76
 		$WS_METHOD  = 'createProductOrService';
77
-		$ns='http://www.dolibarr.org/ns/';
77
+		$ns = 'http://www.dolibarr.org/ns/';
78 78
 
79 79
 		// Set the WebService URL
80 80
 		print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
81 81
 		$soapclient = new nusoap_client($WS_DOL_URL);
82 82
 		if ($soapclient) {
83
-			$soapclient->soap_defencoding='UTF-8';
83
+			$soapclient->soap_defencoding = 'UTF-8';
84 84
 			$soapclient->decodeUTF8(false);
85 85
 		}
86 86
 
87 87
 		// Call the WebService method and store its result in $result.
88
-		$authentication=array(
88
+		$authentication = array(
89 89
 			'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
90 90
 			'sourceapplication'=>'DEMO',
91 91
 			'login'=>'admin',
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 		);
95 95
 
96 96
 		// Test URL
97
-		$result='';
97
+		$result = '';
98 98
 		$parameters = array(
99
-			'authentication'=>$authentication,'product'=>array(
99
+			'authentication'=>$authentication, 'product'=>array(
100 100
 				'ref'=>'NewProductFromWS'.$datestring,
101 101
 				'label'=>'New Product From WS '.$datestring,
102 102
 				'type'=>1,
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 			$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
114 114
 		} catch (SoapFault $exception) {
115 115
 			echo $exception;
116
-			$result=0;
116
+			$result = 0;
117 117
 		}
118
-		if (! $result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
118
+		if (!$result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
119 119
 			//var_dump($soapclient);
120 120
 			print $soapclient->error_str;
121 121
 			print "\n<br>\n";
@@ -141,26 +141,26 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function testWSProductsGetProductOrService($id)
143 143
 	{
144
-		global $conf,$user,$langs,$db;
145
-		$conf=$this->savconf;
146
-		$user=$this->savuser;
147
-		$langs=$this->savlangs;
148
-		$db=$this->savdb;
144
+		global $conf, $user, $langs, $db;
145
+		$conf = $this->savconf;
146
+		$user = $this->savuser;
147
+		$langs = $this->savlangs;
148
+		$db = $this->savdb;
149 149
 
150 150
 		$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
151 151
 		$WS_METHOD  = 'getProductOrService';
152
-		$ns='http://www.dolibarr.org/ns/';
152
+		$ns = 'http://www.dolibarr.org/ns/';
153 153
 
154 154
 		// Set the WebService URL
155 155
 		print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
156 156
 		$soapclient = new nusoap_client($WS_DOL_URL);
157 157
 		if ($soapclient) {
158
-			$soapclient->soap_defencoding='UTF-8';
158
+			$soapclient->soap_defencoding = 'UTF-8';
159 159
 			$soapclient->decodeUTF8(false);
160 160
 		}
161 161
 
162 162
 		// Call the WebService method and store its result in $result.
163
-		$authentication=array(
163
+		$authentication = array(
164 164
 			'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
165 165
 			'sourceapplication'=>'DEMO',
166 166
 			'login'=>'admin',
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 		);
170 170
 
171 171
 		// Test URL
172
-		$result='';
173
-		$parameters = array('authentication'=>$authentication,'id'=>$id,'ref'=>'');
172
+		$result = '';
173
+		$parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'');
174 174
 		print __METHOD__." call method ".$WS_METHOD."\n";
175 175
 		try {
176 176
 			$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
177 177
 		} catch (SoapFault $exception) {
178 178
 			echo $exception;
179
-			$result=0;
179
+			$result = 0;
180 180
 		}
181
-		if (! $result || !empty($result['faultstring'])) {
181
+		if (!$result || !empty($result['faultstring'])) {
182 182
 			//var_dump($soapclient);
183 183
 			print $soapclient->error_str;
184 184
 			print "\n<br>\n";
@@ -204,26 +204,26 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	public function testWSProductsDeleteProductOrService($id)
206 206
 	{
207
-		global $conf,$user,$langs,$db;
208
-		$conf=$this->savconf;
209
-		$user=$this->savuser;
210
-		$langs=$this->savlangs;
211
-		$db=$this->savdb;
207
+		global $conf, $user, $langs, $db;
208
+		$conf = $this->savconf;
209
+		$user = $this->savuser;
210
+		$langs = $this->savlangs;
211
+		$db = $this->savdb;
212 212
 
213 213
 		$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
214 214
 		$WS_METHOD  = 'deleteProductOrService';
215
-		$ns='http://www.dolibarr.org/ns/';
215
+		$ns = 'http://www.dolibarr.org/ns/';
216 216
 
217 217
 		// Set the WebService URL
218 218
 		print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
219 219
 		$soapclient = new nusoap_client($WS_DOL_URL);
220 220
 		if ($soapclient) {
221
-			$soapclient->soap_defencoding='UTF-8';
221
+			$soapclient->soap_defencoding = 'UTF-8';
222 222
 			$soapclient->decodeUTF8(false);
223 223
 		}
224 224
 
225 225
 		// Call the WebService method and store its result in $result.
226
-		$authentication=array(
226
+		$authentication = array(
227 227
 			'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
228 228
 			'sourceapplication'=>'DEMO',
229 229
 			'login'=>'admin',
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
 		);
233 233
 
234 234
 		// Test URL
235
-		$result='';
236
-		$parameters = array('authentication'=>$authentication,'listofid'=>$id);
235
+		$result = '';
236
+		$parameters = array('authentication'=>$authentication, 'listofid'=>$id);
237 237
 		print __METHOD__." call method ".$WS_METHOD."\n";
238 238
 		try {
239 239
 			$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
240 240
 		} catch (SoapFault $exception) {
241 241
 			echo $exception;
242
-			$result=0;
242
+			$result = 0;
243 243
 		}
244
-		if (! $result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
244
+		if (!$result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
245 245
 			//var_dump($soapclient);
246 246
 			print 'Error: '.$soapclient->error_str;
247 247
 			print "\n<br>\n";
Please login to merge, or discard this patch.
test/phpunit/ChargeSocialesTest.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 /**
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function testChargeSocialesCreate()
57 57
 	{
58
-		global $conf,$user,$langs,$db;
59
-		$conf=$this->savconf;
60
-		$user=$this->savuser;
61
-		$langs=$this->savlangs;
62
-		$db=$this->savdb;
58
+		global $conf, $user, $langs, $db;
59
+		$conf = $this->savconf;
60
+		$user = $this->savuser;
61
+		$langs = $this->savlangs;
62
+		$db = $this->savdb;
63 63
 
64
-		$localobject=new ChargeSociales($db);
64
+		$localobject = new ChargeSociales($db);
65 65
 		$localobject->initAsSpecimen();
66
-		$result=$localobject->create($user, $langs, $conf);
66
+		$result = $localobject->create($user, $langs, $conf);
67 67
 		print __METHOD__." result=".$result."\n";
68 68
 
69 69
 		$this->assertLessThan($result, 0);
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function testChargeSocialesFetch($id)
83 83
 	{
84
-		global $conf,$user,$langs,$db;
85
-		$conf=$this->savconf;
86
-		$user=$this->savuser;
87
-		$langs=$this->savlangs;
88
-		$db=$this->savdb;
89
-
90
-		$localobject=new ChargeSociales($db);
91
-		$result=$localobject->fetch($id);
84
+		global $conf, $user, $langs, $db;
85
+		$conf = $this->savconf;
86
+		$user = $this->savuser;
87
+		$langs = $this->savlangs;
88
+		$db = $this->savdb;
89
+
90
+		$localobject = new ChargeSociales($db);
91
+		$result = $localobject->fetch($id);
92 92
 		print __METHOD__." id=".$id." result=".$result."\n";
93 93
 
94 94
 		$this->assertLessThan($result, 0);
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function testChargeSocialesValid($localobject)
108 108
 	{
109
-		global $conf,$user,$langs,$db;
110
-		$conf=$this->savconf;
111
-		$user=$this->savuser;
112
-		$langs=$this->savlangs;
113
-		$db=$this->savdb;
109
+		global $conf, $user, $langs, $db;
110
+		$conf = $this->savconf;
111
+		$user = $this->savuser;
112
+		$langs = $this->savlangs;
113
+		$db = $this->savdb;
114 114
 
115
-		$result=$localobject->setPaid($user);
115
+		$result = $localobject->setPaid($user);
116 116
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
117 117
 
118 118
 		$this->assertLessThan($result, 0);
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function testChargeSocialesOther($localobject)
132 132
 	{
133
-		global $conf,$user,$langs,$db;
134
-		$conf=$this->savconf;
135
-		$user=$this->savuser;
136
-		$langs=$this->savlangs;
137
-		$db=$this->savdb;
133
+		global $conf, $user, $langs, $db;
134
+		$conf = $this->savconf;
135
+		$user = $this->savuser;
136
+		$langs = $this->savlangs;
137
+		$db = $this->savdb;
138 138
 
139
-		$result=$localobject->getNomUrl(1);
139
+		$result = $localobject->getNomUrl(1);
140 140
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
141 141
 		$this->assertNotEquals($result, '');
142 142
 
143
-		$result=$localobject->getSommePaiement();
143
+		$result = $localobject->getSommePaiement();
144 144
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
145 145
 		$this->assertLessThanOrEqual($result, 0);
146 146
 
@@ -158,16 +158,16 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	public function testChargeSocialesDelete($id)
160 160
 	{
161
-		global $conf,$user,$langs,$db;
161
+		global $conf, $user, $langs, $db;
162 162
 
163
-		$conf=$this->savconf;
164
-		$user=$this->savuser;
165
-		$langs=$this->savlangs;
166
-		$db=$this->savdb;
163
+		$conf = $this->savconf;
164
+		$user = $this->savuser;
165
+		$langs = $this->savlangs;
166
+		$db = $this->savdb;
167 167
 
168
-		$localobject=new ChargeSociales($db);
169
-		$result=$localobject->fetch($id);
170
-		$result=$localobject->delete($user);
168
+		$localobject = new ChargeSociales($db);
169
+		$result = $localobject->fetch($id);
170
+		$result = $localobject->delete($user);
171 171
 
172 172
 		print __METHOD__." id=".$id." result=".$result."\n";
173 173
 		$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
test/phpunit/GetUrlLibTest.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
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';
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	$user->fetch(1);
38 38
 	$user->getrights();
39 39
 }
40
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
40
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
41 41
 
42 42
 
43 43
 /**
@@ -56,41 +56,41 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function testGetRootURLFromURL()
58 58
 	{
59
-		global $conf,$user,$langs,$db;
60
-		$conf=$this->savconf;
61
-		$user=$this->savuser;
62
-		$langs=$this->savlangs;
63
-		$db=$this->savdb;
59
+		global $conf, $user, $langs, $db;
60
+		$conf = $this->savconf;
61
+		$user = $this->savuser;
62
+		$langs = $this->savlangs;
63
+		$db = $this->savdb;
64 64
 
65
-		$result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile');
65
+		$result = getRootURLFromURL('http://www.dolimed.com/screenshots/afile');
66 66
 		print __METHOD__." result=".$result."\n";
67 67
 		$this->assertEquals('http://www.dolimed.com', $result, 'Test 1');
68 68
 
69
-		$result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile');
69
+		$result = getRootURLFromURL('https://www.dolimed.com/screenshots/afile');
70 70
 		print __METHOD__." result=".$result."\n";
71 71
 		$this->assertEquals('https://www.dolimed.com', $result, 'Test 2');
72 72
 
73
-		$result=getRootURLFromURL('http://www.dolimed.com/screenshots');
73
+		$result = getRootURLFromURL('http://www.dolimed.com/screenshots');
74 74
 		print __METHOD__." result=".$result."\n";
75 75
 		$this->assertEquals('http://www.dolimed.com', $result);
76 76
 
77
-		$result=getRootURLFromURL('https://www.dolimed.com/screenshots');
77
+		$result = getRootURLFromURL('https://www.dolimed.com/screenshots');
78 78
 		print __METHOD__." result=".$result."\n";
79 79
 		$this->assertEquals('https://www.dolimed.com', $result);
80 80
 
81
-		$result=getRootURLFromURL('http://www.dolimed.com/');
81
+		$result = getRootURLFromURL('http://www.dolimed.com/');
82 82
 		print __METHOD__." result=".$result."\n";
83 83
 		$this->assertEquals('http://www.dolimed.com', $result);
84 84
 
85
-		$result=getRootURLFromURL('https://www.dolimed.com/');
85
+		$result = getRootURLFromURL('https://www.dolimed.com/');
86 86
 		print __METHOD__." result=".$result."\n";
87 87
 		$this->assertEquals('https://www.dolimed.com', $result);
88 88
 
89
-		$result=getRootURLFromURL('http://www.dolimed.com');
89
+		$result = getRootURLFromURL('http://www.dolimed.com');
90 90
 		print __METHOD__." result=".$result."\n";
91 91
 		$this->assertEquals('http://www.dolimed.com', $result);
92 92
 
93
-		$result=getRootURLFromURL('https://www.dolimed.com');
93
+		$result = getRootURLFromURL('https://www.dolimed.com');
94 94
 		print __METHOD__." result=".$result."\n";
95 95
 		$this->assertEquals('https://www.dolimed.com', $result);
96 96
 
@@ -104,65 +104,65 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function testGetDomainFromURL()
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
 		// Tests with param 0
114 114
 
115
-		$result=getDomainFromURL('http://localhost');
115
+		$result = getDomainFromURL('http://localhost');
116 116
 		print __METHOD__." result=".$result."\n";
117 117
 		$this->assertEquals('localhost', $result, 'Test localhost 0');
118 118
 
119
-		$result=getDomainFromURL('http://localhost', 1);
119
+		$result = getDomainFromURL('http://localhost', 1);
120 120
 		print __METHOD__." result=".$result."\n";
121 121
 		$this->assertEquals('localhost', $result, 'Test localhost 1');
122 122
 
123
-		$result=getDomainFromURL('https://dolimed.com');
123
+		$result = getDomainFromURL('https://dolimed.com');
124 124
 		print __METHOD__." result=".$result."\n";
125 125
 		$this->assertEquals('dolimed', $result, 'Test dolimed.com 0');
126 126
 
127
-		$result=getDomainFromURL('http://www.dolimed.com/screenshots/afile');
127
+		$result = getDomainFromURL('http://www.dolimed.com/screenshots/afile');
128 128
 		print __METHOD__." result=".$result."\n";
129 129
 		$this->assertEquals('dolimed', $result, 'Test dolimed.com/... 0');
130 130
 
131
-		$result=getDomainFromURL('http://www.with.dolimed.com/screenshots/afile');
131
+		$result = getDomainFromURL('http://www.with.dolimed.com/screenshots/afile');
132 132
 		print __METHOD__." result=".$result."\n";
133 133
 		$this->assertEquals('dolimed', $result, 'Test ...dolimed.com/ 0');
134 134
 
135 135
 		// Tests with param 1
136 136
 
137
-		$result=getDomainFromURL('https://dolimed.com', 1);
137
+		$result = getDomainFromURL('https://dolimed.com', 1);
138 138
 		print __METHOD__." result=".$result."\n";
139 139
 		$this->assertEquals('dolimed.com', $result, 'Test dolimed.com 1');
140 140
 
141
-		$result=getDomainFromURL('http://www.dolimed.com/screenshots/afile', 1);
141
+		$result = getDomainFromURL('http://www.dolimed.com/screenshots/afile', 1);
142 142
 		print __METHOD__." result=".$result."\n";
143 143
 		$this->assertEquals('dolimed.com', $result, 'Test dolimed.com/... 1');
144 144
 
145
-		$result=getDomainFromURL('http://www.with.dolimed.com/screenshots/afile', 1);
145
+		$result = getDomainFromURL('http://www.with.dolimed.com/screenshots/afile', 1);
146 146
 		print __METHOD__." result=".$result."\n";
147 147
 		$this->assertEquals('dolimed.com', $result, 'Test .../dolimed.com 1');
148 148
 
149 149
 		// Tests with param 2
150 150
 
151
-		$result=getDomainFromURL('http://www.with.dolimed.com/screenshots/afile', 2);
151
+		$result = getDomainFromURL('http://www.with.dolimed.com/screenshots/afile', 2);
152 152
 		print __METHOD__." result=".$result."\n";
153 153
 		$this->assertEquals('with.dolimed.com', $result, 'Test .../dolimed.com 2');
154 154
 
155 155
 		// For domains with top domain on 2 levels
156 156
 
157
-		$result=getDomainFromURL('https://www.with.dolimed.com.mx', 0);
157
+		$result = getDomainFromURL('https://www.with.dolimed.com.mx', 0);
158 158
 		print __METHOD__." result=".$result."\n";
159 159
 		$this->assertEquals('dolimed', $result, 'Test dolimed.com.mx 0');
160 160
 
161
-		$result=getDomainFromURL('https://www.with.dolimed.com.mx', 1);
161
+		$result = getDomainFromURL('https://www.with.dolimed.com.mx', 1);
162 162
 		print __METHOD__." result=".$result."\n";
163 163
 		$this->assertEquals('dolimed.com.mx', $result, 'Test dolimed.com.mx 1');
164 164
 
165
-		$result=getDomainFromURL('https://www.with.dolimed.com.mx', 2);
165
+		$result = getDomainFromURL('https://www.with.dolimed.com.mx', 2);
166 166
 		print __METHOD__." result=".$result."\n";
167 167
 		$this->assertEquals('with.dolimed.com.mx', $result, 'Test dolimed.com.mx 2');
168 168
 
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public function testRemoveHtmlComment()
178 178
 	{
179
-		global $conf,$user,$langs,$db;
180
-		$conf=$this->savconf;
181
-		$user=$this->savuser;
182
-		$langs=$this->savlangs;
183
-		$db=$this->savdb;
179
+		global $conf, $user, $langs, $db;
180
+		$conf = $this->savconf;
181
+		$user = $this->savuser;
182
+		$langs = $this->savlangs;
183
+		$db = $this->savdb;
184 184
 
185
-		$result=removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def');
185
+		$result = removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def');
186 186
 		print __METHOD__." result=".$result."\n";
187 187
 		$this->assertEquals('abcdef', $result, 'Test 1');
188 188
 
189
-		$result=removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def');
189
+		$result = removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def');
190 190
 		print __METHOD__." result=".$result."\n";
191 191
 		$this->assertEquals('abcbbdef', $result, 'Test 1');
192 192
 
Please login to merge, or discard this patch.
test/phpunit/CommandeTest.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 /**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public static function setUpBeforeClass(): void
57 57
 	{
58
-		global $conf,$user,$langs,$db;
58
+		global $conf, $user, $langs, $db;
59 59
 		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
60 60
 
61 61
 		if (!isModEnabled('commande')) {
@@ -74,21 +74,21 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function testCommandeCreate()
76 76
 	{
77
-		global $conf,$user,$langs,$db;
78
-		$conf=$this->savconf;
79
-		$user=$this->savuser;
80
-		$langs=$this->savlangs;
81
-		$db=$this->savdb;
77
+		global $conf, $user, $langs, $db;
78
+		$conf = $this->savconf;
79
+		$user = $this->savuser;
80
+		$langs = $this->savlangs;
81
+		$db = $this->savdb;
82 82
 
83 83
 		$soc = new Societe($db);
84 84
 		$soc->name = "CommandeTest Unittest";
85 85
 		$socid = $soc->create($user);
86 86
 		$this->assertLessThan($socid, 0, $soc->errorsToString());
87 87
 
88
-		$localobject=new Commande($db);
88
+		$localobject = new Commande($db);
89 89
 		$localobject->initAsSpecimen();
90 90
 		$localobject->socid = $socid;
91
-		$result=$localobject->create($user);
91
+		$result = $localobject->create($user);
92 92
 
93 93
 		$this->assertLessThan($result, 0, $localobject->errorsToString());
94 94
 		print __METHOD__." result=".$result."\n";
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function testCommandeFetch($id)
108 108
 	{
109
-		global $conf,$user,$langs,$db;
110
-		$conf=$this->savconf;
111
-		$user=$this->savuser;
112
-		$langs=$this->savlangs;
113
-		$db=$this->savdb;
109
+		global $conf, $user, $langs, $db;
110
+		$conf = $this->savconf;
111
+		$user = $this->savuser;
112
+		$langs = $this->savlangs;
113
+		$db = $this->savdb;
114 114
 
115
-		$localobject=new Commande($db);
116
-		$result=$localobject->fetch($id);
115
+		$localobject = new Commande($db);
116
+		$result = $localobject->fetch($id);
117 117
 
118 118
 		$this->assertLessThan($result, 0);
119 119
 		print __METHOD__." id=".$id." result=".$result."\n";
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function testCommandeUpdate($localobject)
133 133
 	{
134
-		global $conf,$user,$langs,$db;
135
-		$conf=$this->savconf;
136
-		$user=$this->savuser;
137
-		$langs=$this->savlangs;
138
-		$db=$this->savdb;
134
+		global $conf, $user, $langs, $db;
135
+		$conf = $this->savconf;
136
+		$user = $this->savuser;
137
+		$langs = $this->savlangs;
138
+		$db = $this->savdb;
139 139
 
140
-		$localobject->note_private='New note private after update';
141
-		$result=$localobject->update($user);
140
+		$localobject->note_private = 'New note private after update';
141
+		$result = $localobject->update($user);
142 142
 
143 143
 		$this->assertLessThan($result, 0);
144 144
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -156,13 +156,13 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function testCommandeValid($localobject)
158 158
 	{
159
-		global $conf,$user,$langs,$db;
160
-		$conf=$this->savconf;
161
-		$user=$this->savuser;
162
-		$langs=$this->savlangs;
163
-		$db=$this->savdb;
159
+		global $conf, $user, $langs, $db;
160
+		$conf = $this->savconf;
161
+		$user = $this->savuser;
162
+		$langs = $this->savlangs;
163
+		$db = $this->savdb;
164 164
 
165
-		$result=$localobject->valid($user);
165
+		$result = $localobject->valid($user);
166 166
 
167 167
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
168 168
 		$this->assertLessThan($result, 0);
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	public function testCommandeCancel($localobject)
182 182
 	{
183
-		global $conf,$user,$langs,$db;
184
-		$conf=$this->savconf;
185
-		$user=$this->savuser;
186
-		$langs=$this->savlangs;
187
-		$db=$this->savdb;
183
+		global $conf, $user, $langs, $db;
184
+		$conf = $this->savconf;
185
+		$user = $this->savuser;
186
+		$langs = $this->savlangs;
187
+		$db = $this->savdb;
188 188
 
189
-		$result=$localobject->cancel();
189
+		$result = $localobject->cancel();
190 190
 
191 191
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
192 192
 		$this->assertLessThan($result, 0);
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	public function testCommandeOther($localobject)
206 206
 	{
207
-		global $conf,$user,$langs,$db;
208
-		$conf=$this->savconf;
209
-		$user=$this->savuser;
210
-		$langs=$this->savlangs;
211
-		$db=$this->savdb;
207
+		global $conf, $user, $langs, $db;
208
+		$conf = $this->savconf;
209
+		$user = $this->savuser;
210
+		$langs = $this->savlangs;
211
+		$db = $this->savdb;
212 212
 
213 213
 		/*$result=$localobject->setstatus(0);
214 214
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 	 */
234 234
 	public function testCommandeDelete($id)
235 235
 	{
236
-		global $conf,$user,$langs,$db;
237
-		$conf=$this->savconf;
238
-		$user=$this->savuser;
239
-		$langs=$this->savlangs;
240
-		$db=$this->savdb;
241
-
242
-		$localobject=new Commande($db);
243
-		$result=$localobject->fetch($id);
244
-		$result=$localobject->delete($user);
236
+		global $conf, $user, $langs, $db;
237
+		$conf = $this->savconf;
238
+		$user = $this->savuser;
239
+		$langs = $this->savlangs;
240
+		$db = $this->savdb;
241
+
242
+		$localobject = new Commande($db);
243
+		$result = $localobject->fetch($id);
244
+		$result = $localobject->delete($user);
245 245
 
246 246
 		print __METHOD__." id=".$id." result=".$result."\n";
247 247
 		$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
test/phpunit/RepositoryTest.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -24,42 +24,42 @@  discard block
 block discarded – undo
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/files.lib.php';
32 32
 require_once dirname(__FILE__).'/CommonClassTest.class.php';
33 33
 
34
-if (! defined('NOREQUIREUSER')) {
34
+if (!defined('NOREQUIREUSER')) {
35 35
 	define('NOREQUIREUSER', '1');
36 36
 }
37
-if (! defined('NOREQUIREDB')) {
37
+if (!defined('NOREQUIREDB')) {
38 38
 	define('NOREQUIREDB', '1');
39 39
 }
40
-if (! defined('NOREQUIRESOC')) {
40
+if (!defined('NOREQUIRESOC')) {
41 41
 	define('NOREQUIRESOC', '1');
42 42
 }
43
-if (! defined('NOREQUIRETRAN')) {
43
+if (!defined('NOREQUIRETRAN')) {
44 44
 	define('NOREQUIRETRAN', '1');
45 45
 }
46
-if (! defined('NOCSRFCHECK')) {
46
+if (!defined('NOCSRFCHECK')) {
47 47
 	define('NOCSRFCHECK', '1');
48 48
 }
49
-if (! defined('NOTOKENRENEWAL')) {
49
+if (!defined('NOTOKENRENEWAL')) {
50 50
 	define('NOTOKENRENEWAL', '1');
51 51
 }
52
-if (! defined('NOREQUIREMENU')) {
52
+if (!defined('NOREQUIREMENU')) {
53 53
 	define('NOREQUIREMENU', '1'); // If there is no menu to show
54 54
 }
55
-if (! defined('NOREQUIREHTML')) {
55
+if (!defined('NOREQUIREHTML')) {
56 56
 	define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
57 57
 }
58
-if (! defined('NOREQUIREAJAX')) {
58
+if (!defined('NOREQUIREAJAX')) {
59 59
 	define('NOREQUIREAJAX', '1');
60 60
 }
61
-if (! defined("NOLOGIN")) {
62
-	define("NOLOGIN", '1');       // If this page is public (can be called outside logged session)
61
+if (!defined("NOLOGIN")) {
62
+	define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
63 63
 }
64 64
 
65 65
 if (empty($user->id)) {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	$user->fetch(1);
68 68
 	$user->getrights();
69 69
 }
70
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
70
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
71 71
 
72 72
 
73 73
 /**
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function testJqueryOnce()
90 90
 	{
91
-		global $conf,$user,$langs,$db;
91
+		global $conf, $user, $langs, $db;
92 92
 
93 93
 		// Scan dir to guarantee we don't have library jquery twice
94
-		$foundfiles=dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.js', array('ckeditor'));
94
+		$foundfiles = dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.js', array('ckeditor'));
95 95
 		print __METHOD__." count(founddirs)=".count($foundfiles)."\n";
96 96
 		$this->assertEquals(1, count($foundfiles), 'We found jquery lib (jquery.js) twice');
97 97
 
98 98
 		// Scan dir to guarantee we don't have library jquery twice
99
-		$foundfiles=dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.min\.js', array('ckeditor'));
99
+		$foundfiles = dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.min\.js', array('ckeditor'));
100 100
 		print __METHOD__." count(founddirs)=".count($foundfiles)."\n";
101 101
 		$this->assertEquals(1, count($foundfiles), 'We found jquery lib (jquery.min.js) twice '.(empty($foundfiles[0]) ? '' : $foundfiles[0]['fullname']).' '.(empty($foundfiles[1]) ? '' : $foundfiles[1]['fullname']));
102 102
 	}
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function testRepository()
111 111
 	{
112
-		global $conf,$user,$langs,$db;
113
-		$conf=$this->savconf;
114
-		$user=$this->savuser;
115
-		$langs=$this->savlangs;
116
-		$db=$this->savdb;
112
+		global $conf, $user, $langs, $db;
113
+		$conf = $this->savconf;
114
+		$user = $this->savuser;
115
+		$langs = $this->savlangs;
116
+		$db = $this->savdb;
117 117
 
118 118
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
119 119
 		$filesarray = dol_dir_list(DOL_DOCUMENT_ROOT, 'directories', 1, '', array('\/custom\/'), 'fullname', SORT_ASC, 0, 1, '', 1);
Please login to merge, or discard this patch.
test/phpunit/LesscTest.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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';
@@ -32,35 +32,35 @@  discard block
 block discarded – undo
32 32
 require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php';
33 33
 require_once dirname(__FILE__).'/CommonClassTest.class.php';
34 34
 
35
-if (! defined('NOREQUIREUSER')) {
35
+if (!defined('NOREQUIREUSER')) {
36 36
 	define('NOREQUIREUSER', '1');
37 37
 }
38
-if (! defined('NOREQUIREDB')) {
38
+if (!defined('NOREQUIREDB')) {
39 39
 	define('NOREQUIREDB', '1');
40 40
 }
41
-if (! defined('NOREQUIRESOC')) {
41
+if (!defined('NOREQUIRESOC')) {
42 42
 	define('NOREQUIRESOC', '1');
43 43
 }
44
-if (! defined('NOREQUIRETRAN')) {
44
+if (!defined('NOREQUIRETRAN')) {
45 45
 	define('NOREQUIRETRAN', '1');
46 46
 }
47
-if (! defined('NOCSRFCHECK')) {
47
+if (!defined('NOCSRFCHECK')) {
48 48
 	define('NOCSRFCHECK', '1');
49 49
 }
50
-if (! defined('NOTOKENRENEWAL')) {
50
+if (!defined('NOTOKENRENEWAL')) {
51 51
 	define('NOTOKENRENEWAL', '1');
52 52
 }
53
-if (! defined('NOREQUIREMENU')) {
53
+if (!defined('NOREQUIREMENU')) {
54 54
 	define('NOREQUIREMENU', '1'); // If there is no menu to show
55 55
 }
56
-if (! defined('NOREQUIREHTML')) {
56
+if (!defined('NOREQUIREHTML')) {
57 57
 	define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
58 58
 }
59
-if (! defined('NOREQUIREAJAX')) {
59
+if (!defined('NOREQUIREAJAX')) {
60 60
 	define('NOREQUIREAJAX', '1');
61 61
 }
62
-if (! defined("NOLOGIN")) {
63
-	define("NOLOGIN", '1');       // If this page is public (can be called outside logged session)
62
+if (!defined("NOLOGIN")) {
63
+	define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
64 64
 }
65 65
 
66 66
 if (empty($user->id)) {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	$user->fetch(1);
69 69
 	$user->getrights();
70 70
 }
71
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
71
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
72 72
 
73 73
 
74 74
 /**
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function testLessc()
89 89
 	{
90
-		global $conf,$user,$langs,$db;
91
-		$conf=$this->savconf;
92
-		$user=$this->savuser;
93
-		$langs=$this->savlangs;
94
-		$db=$this->savdb;
90
+		global $conf, $user, $langs, $db;
91
+		$conf = $this->savconf;
92
+		$user = $this->savuser;
93
+		$langs = $this->savlangs;
94
+		$db = $this->savdb;
95 95
 
96 96
 		include_once DOL_DOCUMENT_ROOT.'/core/class/lessc.class.php';
97 97
 
Please login to merge, or discard this patch.