diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index 21023c6f545..f3ebb81ea7c 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -267,10 +267,10 @@ class AdherentTest extends PHPUnit_Framework_TestCase $result=$localobject->update($user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - $result=$localobject->update_note($localobject->note,'_private'); + $result=$localobject->update_note($localobject->note, '_private'); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - $result=$localobject->update_note($localobject->note,'_public'); + $result=$localobject->update_note($localobject->note, '_public'); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); @@ -328,7 +328,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase // If option to store clear password has been set, we get 'dolibspec' into PASSWORD field. $expected = ',New firstname,New name,New firstname New name,'. - 'New company,New address,New zip,New town,Belgium,newemail@newemail.com,'.dol_print_date($localobject->birth,'day').',,'. + 'New company,New address,New zip,New town,Belgium,newemail@newemail.com,'.dol_print_date($localobject->birth, 'day').',,'. 'newlogin'; $result = $localobject->makeSubstitution($template); @@ -423,7 +423,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase $this->assertNull($localobject->fk_soc); //Now we remove the third party - $result = $thirdparty->delete($thirdparty->id,$user); + $result = $thirdparty->delete($thirdparty->id, $user); $this->assertEquals($result, 1); return $localobject; diff --git a/test/phpunit/AdminLibTest.php b/test/phpunit/AdminLibTest.php index 75139ba8aea..9b405b5e360 100644 --- a/test/phpunit/AdminLibTest.php +++ b/test/phpunit/AdminLibTest.php @@ -129,18 +129,18 @@ class AdminLibTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $result=versioncompare(array(3,1,-4),array(3,1,1)); + $result=versioncompare(array(3,1,-4), array(3,1,1)); print __METHOD__." result=".$result."\n"; - $this->assertEquals(-3,$result); - $result=versioncompare(array(3,1,0),array(3,1,1)); + $this->assertEquals(-3, $result); + $result=versioncompare(array(3,1,0), array(3,1,1)); print __METHOD__." result=".$result."\n"; - $this->assertEquals(-3,$result); - $result=versioncompare(array(3,1,0),array(3,2,0)); + $this->assertEquals(-3, $result); + $result=versioncompare(array(3,1,0), array(3,2,0)); print __METHOD__." result=".$result."\n"; - $this->assertEquals(-2,$result); - $result=versioncompare(array(3,1,0),array(3,1,0)); + $this->assertEquals(-2, $result); + $result=versioncompare(array(3,1,0), array(3,1,0)); print __METHOD__." result=".$result."\n"; - $this->assertEquals(0,$result); + $this->assertEquals(0, $result); return $result; } diff --git a/test/phpunit/BonPrelevementTest.php b/test/phpunit/BonPrelevementTest.php index 8c6ffbb585d..2ca1cfb431f 100644 --- a/test/phpunit/BonPrelevementTest.php +++ b/test/phpunit/BonPrelevementTest.php @@ -153,7 +153,7 @@ class BonPrelevementTest extends PHPUnit_Framework_TestCase // Create withdraw record and generate SEPA file $localobject=new BonPrelevement($this->savdb); //$localobject->date_solde=dol_now(); - $result=$localobject->Create(0,0,'simu'); + $result=$localobject->Create(0, 0, 'simu'); print __METHOD__." result=".$result."\n"; $this->assertEquals($result, 0); diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index 985250aa705..d831f5b7768 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -184,7 +184,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; // Crabe (japanese) - $newlangs1=new Translate("",$conf); + $newlangs1=new Translate("", $conf); $newlangs1->setDefaultLang('ja_JP'); $localobject->modelpdf='crabe'; $result = $localobject->generateDocument($localobject->modelpdf, $newlangs1); @@ -192,7 +192,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; // Crabe (saudiarabia) - $newlangs2a=new Translate("",$conf); + $newlangs2a=new Translate("", $conf); $newlangs2a->setDefaultLang('sa_SA'); $localobject->modelpdf='crabe'; $result = $localobject->generateDocument($localobject->modelpdf, $newlangs2a); @@ -200,7 +200,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; // Crabe (english_saudiarabia) - $newlangs2b=new Translate("",$conf); + $newlangs2b=new Translate("", $conf); $newlangs2b->setDefaultLang('en_SA'); $localobject->modelpdf='crabe'; $result = $localobject->generateDocument($localobject->modelpdf, $newlangs2b); @@ -208,7 +208,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; // Crabe (greek) - $newlangs3=new Translate("",$conf); + $newlangs3=new Translate("", $conf); $newlangs3->setDefaultLang('el_GR'); $localobject->modelpdf='crabe'; $result = $localobject->generateDocument($localobject->modelpdf, $newlangs3); @@ -216,7 +216,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; // Crabe (chinese) - $newlangs4=new Translate("",$conf); + $newlangs4=new Translate("", $conf); $newlangs4->setDefaultLang('zh_CN'); $localobject->modelpdf='crabe'; $result = $localobject->generateDocument($localobject->modelpdf, $newlangs4); @@ -224,7 +224,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; // Crabe (russian) - $newlangs5=new Translate("",$conf); + $newlangs5=new Translate("", $conf); $newlangs5->setDefaultLang('ru_RU'); $localobject->modelpdf='crabe'; $result = $localobject->generateDocument($localobject->modelpdf, $newlangs5); diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index 2c511246c48..bf365c7ddf7 100755 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -131,7 +131,7 @@ class CMailFileTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $localobject=new CMailFile('Test','test@test.com','from@from.com','Message txt',array(),array(),array(),'','',1,0); + $localobject=new CMailFile('Test', 'test@test.com', 'from@from.com', 'Message txt', array(), array(), array(), '', '', 1, 0); $result=$localobject->sendfile(); print __METHOD__." result=".$result."\n"; @@ -153,47 +153,47 @@ class CMailFileTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $localobject=new CMailFile('','','',''); + $localobject=new CMailFile('', '', '', ''); $src='John Doe '; - $result=$localobject->getValidAddress($src,0); + $result=$localobject->getValidAddress($src, 0); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,'John Doe '); + $this->assertEquals($result, 'John Doe '); $src='John Doe '; - $result=$localobject->getValidAddress($src,1); + $result=$localobject->getValidAddress($src, 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,''); + $this->assertEquals($result, ''); $src='John Doe '; - $result=$localobject->getValidAddress($src,2); + $result=$localobject->getValidAddress($src, 2); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,'john@doe.com'); + $this->assertEquals($result, 'john@doe.com'); $src='John Doe '; - $result=$localobject->getValidAddress($src,3,0); + $result=$localobject->getValidAddress($src, 3, 0); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,'"John Doe" '); + $this->assertEquals($result, '"John Doe" '); $src='John Doe '; - $result=$localobject->getValidAddress($src,3,1); + $result=$localobject->getValidAddress($src, 3, 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,'"=?UTF-8?B?Sm9obiBEb2U=?=" '); + $this->assertEquals($result, '"=?UTF-8?B?Sm9obiBEb2U=?=" '); $src='John Doe '; - $result=$localobject->getValidAddress($src,4); + $result=$localobject->getValidAddress($src, 4); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,'John Doe'); + $this->assertEquals($result, 'John Doe'); $src='John Doe , John Doe2 , John Doe3 '; - $result=$localobject->getValidAddress($src,4); + $result=$localobject->getValidAddress($src, 4); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,'John Doe,John Doe2,John Doe3'); + $this->assertEquals($result, 'John Doe,John Doe2,John Doe3'); $src='John Doe , John Doe2 , John Doe3 '; - $result=$localobject->getValidAddress($src,4,0,2); + $result=$localobject->getValidAddress($src, 4, 0, 2); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,'John Doe,John Doe2...'); + $this->assertEquals($result, 'John Doe,John Doe2...'); return $result; } diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index 19440df33db..005de68d3ef 100644 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -195,7 +195,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase $result=$localobject2->create($user); $cat = new Categorie($this->savdb); $cat->id = $catid; - $result=$cat->add_type($localobject2,"product"); + $result=$cat->add_type($localobject2, "product"); print __METHOD__." result=".$result."\n"; $this->assertGreaterThan(0, $result); @@ -203,7 +203,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase // Get list of categories for product $localcateg=new Categorie($this->savdb); $listofcateg=$localcateg->containing($localobject2->id, Categorie::TYPE_PRODUCT, 'label'); - $this->assertTrue(in_array('Specimen Category for product',$listofcateg), 'Categ not found linked to product when it should'); + $this->assertTrue(in_array('Specimen Category for product', $listofcateg), 'Categ not found linked to product when it should'); return $id; } diff --git a/test/phpunit/ChargeSocialesTest.php b/test/phpunit/ChargeSocialesTest.php index cd01fb906e0..b181c835b01 100644 --- a/test/phpunit/ChargeSocialesTest.php +++ b/test/phpunit/ChargeSocialesTest.php @@ -132,7 +132,7 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase $localobject=new ChargeSociales($this->savdb); $localobject->initAsSpecimen(); - $result=$localobject->create($user,$langs,$conf); + $result=$localobject->create($user, $langs, $conf); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 0aab29e3667..fa424ba71a6 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -30,16 +30,16 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) if (empty($user->id)) { diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 349e19a1072..7c6d9e750b8 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -30,16 +30,16 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) if (empty($user->id)) { @@ -152,33 +152,33 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase foreach($filesarray as $key => $file) { - if (! preg_match('/\.sql$/',$file)) + if (! preg_match('/\.sql$/', $file)) continue; print 'Check sql file '.$file."\n"; $filecontent=file_get_contents($dir.'/'.$file); - $result=strpos($filecontent,'`'); + $result=strpos($filecontent, '`'); print __METHOD__." Result for checking we don't have back quote = ".$result."\n"; $this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.'); - $result=strpos($filecontent,'"'); + $result=strpos($filecontent, '"'); if ($result) { - $result=(! strpos($filecontent,'["') && ! strpos($filecontent,'{"')); + $result=(! strpos($filecontent, '["') && ! strpos($filecontent, '{"')); } print __METHOD__." Result for checking we don't have double quote = ".$result."\n"; $this->assertTrue($result===false, 'Found double quote that is not [" neither {" (used for json content) into '.$file.'. Bad.'); - $result=strpos($filecontent,'int('); + $result=strpos($filecontent, 'int('); print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n"; $this->assertTrue($result===false, 'Found int(x) or tinyint(x) instead of integer or tinyint into '.$file.'. Bad.'); - $result=strpos($filecontent,'ON DELETE CASCADE'); + $result=strpos($filecontent, 'ON DELETE CASCADE'); print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n"; $this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.'); - $result=strpos($filecontent,'NUMERIC('); + $result=strpos($filecontent, 'NUMERIC('); print __METHOD__." Result for checking we don't have 'NUMERIC(' = ".$result."\n"; $this->assertTrue($result===false, 'Found NUMERIC( into '.$file.'. Bad.'); @@ -192,18 +192,18 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase } else { - if (preg_match('/\.key\.sql$/',$file)) + if (preg_match('/\.key\.sql$/', $file)) { // Test for key files only } else { // Test for non key files only - $result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY') == 0); + $result=(strpos($filecontent, 'KEY ') && strpos($filecontent, 'PRIMARY KEY') == 0); print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n"; $this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.'); - $result=stripos($filecontent,'ENGINE=innodb'); + $result=stripos($filecontent, 'ENGINE=innodb'); print __METHOD__." Result for checking we have the ENGINE=innodb string = ".$result."\n"; $this->assertGreaterThan(0, $result, 'The ENGINE=innodb was not found into '.$file.'. Add it or just fix syntax to match case.'); } @@ -229,17 +229,17 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase $filesarray = scandir(DOL_DOCUMENT_ROOT.'/../dev/initdata'); foreach($filesarray as $key => $file) { - if (! preg_match('/\.sql$/',$file)) + if (! preg_match('/\.sql$/', $file)) continue; print 'Check sql file '.$file."\n"; $filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdata/'.$file); - $result=strpos($filecontent,'@gmail.com'); + $result=strpos($filecontent, '@gmail.com'); print __METHOD__." Result for checking we don't have personal data = ".$result."\n"; $this->assertTrue($result===false, 'Found a bad key into file '.$file); - $result=strpos($filecontent,'eldy@'); + $result=strpos($filecontent, 'eldy@'); print __METHOD__." Result for checking we don't have personal data = ".$result."\n"; $this->assertTrue($result===false, 'Found a bad key into file '.$file); } diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index 6a3f7a8696c..eeed83174c6 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -137,7 +137,7 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase $societe=new Societe($db); $societe->fetch($socid); $product=new ProductFournisseur($db); - $product->fetch(0,'PIDRESS'); + $product->fetch(0, 'PIDRESS'); if ($product->id <= 0) { print "\n".__METHOD__." A product with ref PIDRESS must exists into database"; die(); } $quantity=10; diff --git a/test/phpunit/CommonObjectTest.php b/test/phpunit/CommonObjectTest.php index 09200a15b91..634573bc03f 100644 --- a/test/phpunit/CommonObjectTest.php +++ b/test/phpunit/CommonObjectTest.php @@ -159,7 +159,7 @@ class CommonObjectTest extends PHPUnit_Framework_TestCase $result=$localobject->fetch_projet(); print __METHOD__." result=".$result."\n"; - $this->assertLessThanOrEqual($result,0); + $this->assertLessThanOrEqual($result, 0); return $result; } @@ -182,7 +182,7 @@ class CommonObjectTest extends PHPUnit_Framework_TestCase $result=$localobject->fetch_thirdparty(); print __METHOD__." result=".$result."\n"; - $this->assertLessThanOrEqual($result,0); + $this->assertLessThanOrEqual($result, 0); return $result; } } diff --git a/test/phpunit/CompanyLibTest.php b/test/phpunit/CompanyLibTest.php index b06879a5fae..1a08c4512e9 100644 --- a/test/phpunit/CompanyLibTest.php +++ b/test/phpunit/CompanyLibTest.php @@ -131,14 +131,14 @@ class CompanyLibTest extends PHPUnit_Framework_TestCase $result=currency_name('USD'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('US Dollars',$result,'Test to get currency name USD in default language '.$langs->defaultlang); + $this->assertEquals('US Dollars', $result, 'Test to get currency name USD in default language '.$langs->defaultlang); $outputlangs=new Translate('', $conf); $outputlangs->setDefaultLang('fr_FR'); $result=currency_name('USD', 1, $outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('USD - Dollars US',$result,'Test to get currency name USD in default language '.$outputlangs->getDefaultLang()); + $this->assertEquals('USD - Dollars US', $result, 'Test to get currency name USD in default language '.$outputlangs->getDefaultLang()); return $result; } diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index b943020efea..edf103cb894 100755 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -210,11 +210,11 @@ class ContactTest extends PHPUnit_Framework_TestCase $localobject->jabberid='New im id'; $localobject->default_lang='es_ES'; - $result=$localobject->update($localobject->id,$user); + $result=$localobject->update($localobject->id, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0, 'Contact::update error'); - $result=$localobject->update_note($localobject->note_private,'_private'); + $result=$localobject->update_note($localobject->note_private, '_private'); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0, 'Contact::update_note (private) error'); diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php index 63601cb33d3..2d9697f9cfe 100644 --- a/test/phpunit/CoreTest.php +++ b/test/phpunit/CoreTest.php @@ -28,16 +28,16 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; //require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) /** diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index d7f2ad18877..44c1e77d9ae 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -134,37 +134,37 @@ class DateLibTest extends PHPUnit_Framework_TestCase $date1=dol_mktime(0, 0, 0, 1, 1, 2012); $date2=dol_mktime(0, 0, 0, 1, 2, 2012); - $result=num_between_day($date1,$date2,1); + $result=num_between_day($date1, $date2, 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(2,$result); + $this->assertEquals(2, $result); - $result=num_between_day($date1,$date2,0); + $result=num_between_day($date1, $date2, 0); print __METHOD__." result=".$result."\n"; - $this->assertEquals(1,$result); + $this->assertEquals(1, $result); // With different hours $date1=dol_mktime(0, 0, 0, 1, 1, 2012); $date2=dol_mktime(12, 0, 0, 1, 2, 2012); - $result=num_between_day($date1,$date2,1); + $result=num_between_day($date1, $date2, 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(2,$result); + $this->assertEquals(2, $result); - $result=num_between_day($date1,$date2,0); + $result=num_between_day($date1, $date2, 0); print __METHOD__." result=".$result."\n"; - $this->assertEquals(1,$result); + $this->assertEquals(1, $result); // With different date before and after sunlight hour (day to change sunlight hour is 2014-03-30) $date1=dol_mktime(0, 0, 0, 3, 28, 2014, true); $date2=dol_mktime(0, 0, 0, 3, 31, 2014, true); - $result=num_between_day($date1,$date2,1); + $result=num_between_day($date1, $date2, 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(4,$result); + $this->assertEquals(4, $result); - $result=num_between_day($date1,$date2,0); + $result=num_between_day($date1, $date2, 0); print __METHOD__." result=".$result."\n"; - $this->assertEquals(3,$result); + $this->assertEquals(3, $result); return $result; } @@ -186,45 +186,45 @@ class DateLibTest extends PHPUnit_Framework_TestCase $date1=dol_mktime(0, 0, 0, 1, 1, 2013); $date2=dol_mktime(0, 0, 0, 1, 2, 2013); - $result=num_public_holiday($date1,$date2,'FR',1); + $result=num_public_holiday($date1, $date2, 'FR', 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(1,$result,'NumPublicHoliday for Tuesday/Wednesday jan 2013 for FR'); // 1 closed days + $this->assertEquals(1, $result, 'NumPublicHoliday for Tuesday/Wednesday jan 2013 for FR'); // 1 closed days - $result=num_public_holiday($date1,$date2,'XX',1); + $result=num_public_holiday($date1, $date2, 'XX', 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(0,$result,'NumPublicHoliday for Tuesday/Wednesday jan 2013 for XX'); // no closed days (country unknown) + $this->assertEquals(0, $result, 'NumPublicHoliday for Tuesday/Wednesday jan 2013 for XX'); // no closed days (country unknown) // With same hours - Friday/Sunday jan 2013 $date1=dol_mktime(0, 0, 0, 1, 4, 2013); $date2=dol_mktime(0, 0, 0, 1, 6, 2013); - $result=num_public_holiday($date1,$date2,'FR',1); + $result=num_public_holiday($date1, $date2, 'FR', 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(2,$result,'NumPublicHoliday for FR'); // 1 opened day, 2 closed days + $this->assertEquals(2, $result, 'NumPublicHoliday for FR'); // 1 opened day, 2 closed days - $result=num_public_holiday($date1,$date2,'XX',1); + $result=num_public_holiday($date1, $date2, 'XX', 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(2,$result,'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown) + $this->assertEquals(2, $result, 'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown) $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS='12-13,2019-12-14'; $date1=dol_mktime(0, 0, 0, 12, 13, 2018); $date2=dol_mktime(0, 0, 0, 12, 13, 2018); - $result=num_public_holiday($date1,$date2,'YY',1); + $result=num_public_holiday($date1, $date2, 'YY', 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(1,$result,'NumPublicHoliday for YY the 2018-12-13'); // 0 opened day, 1 closed days (even if country unknown) + $this->assertEquals(1, $result, 'NumPublicHoliday for YY the 2018-12-13'); // 0 opened day, 1 closed days (even if country unknown) $date1=dol_mktime(0, 0, 0, 12, 14, 2018); $date2=dol_mktime(0, 0, 0, 12, 14, 2018); - $result=num_public_holiday($date1,$date2,'YY',1); + $result=num_public_holiday($date1, $date2, 'YY', 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(0,$result,'NumPublicHoliday for YY the 2018-12-14'); // 1 opened day, 0 closed days (even if country unknown) + $this->assertEquals(0, $result, 'NumPublicHoliday for YY the 2018-12-14'); // 1 opened day, 0 closed days (even if country unknown) $date1=dol_mktime(0, 0, 0, 12, 14, 2019); $date2=dol_mktime(0, 0, 0, 12, 14, 2019); - $result=num_public_holiday($date1,$date2,'YY',1); + $result=num_public_holiday($date1, $date2, 'YY', 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(1,$result,'NumPublicHoliday for YY the 2019-12-14'); // 0 opened day, 1 closed days (even if country unknown) + $this->assertEquals(1, $result, 'NumPublicHoliday for YY the 2019-12-14'); // 0 opened day, 1 closed days (even if country unknown) } /** @@ -244,25 +244,25 @@ class DateLibTest extends PHPUnit_Framework_TestCase $date1=dol_mktime(0, 0, 0, 1, 1, 2013); $date2=dol_mktime(0, 0, 0, 1, 2, 2013); - $result=num_open_day($date1,$date2,0,1,0,'FR'); + $result=num_open_day($date1, $date2, 0, 1, 0, 'FR'); print __METHOD__." result=".$result."\n"; - $this->assertEquals(1,$result,'NumOpenDay Tuesday/Wednesday jan 2013 for FR'); // 1 opened days + $this->assertEquals(1, $result, 'NumOpenDay Tuesday/Wednesday jan 2013 for FR'); // 1 opened days - $result=num_open_day($date1,$date2,0,1,0,'XX'); + $result=num_open_day($date1, $date2, 0, 1, 0, 'XX'); print __METHOD__." result=".$result."\n"; - $this->assertEquals(2,$result,'NumOpenDay Tuesday/Wednesday jan 2013 for XX'); // 2 opened days (country unknown) + $this->assertEquals(2, $result, 'NumOpenDay Tuesday/Wednesday jan 2013 for XX'); // 2 opened days (country unknown) // With same hours - Friday/Sunday jan 2013 $date1=dol_mktime(0, 0, 0, 1, 4, 2013); $date2=dol_mktime(0, 0, 0, 1, 6, 2013); - $result=num_open_day($date1,$date2,0,1,0,'FR'); + $result=num_open_day($date1, $date2, 0, 1, 0, 'FR'); print __METHOD__." result=".$result."\n"; - $this->assertEquals(1,$result,'NumOpenDay for FR'); // 1 opened day, 2 closed + $this->assertEquals(1, $result, 'NumOpenDay for FR'); // 1 opened day, 2 closed - $result=num_open_day($date1,$date2,'XX',1); + $result=num_open_day($date1, $date2, 'XX', 1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(1,$result,'NumOpenDay for XX'); // 1 opened day, 2 closes (even if country unknown) + $this->assertEquals(1, $result, 'NumOpenDay for XX'); // 1 opened day, 2 closes (even if country unknown) } /** @@ -278,9 +278,9 @@ class DateLibTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $result=convertTime2Seconds(1,1,2); + $result=convertTime2Seconds(1, 1, 2); print __METHOD__." result=".$result."\n"; - $this->assertEquals(3662,$result); + $this->assertEquals(3662, $result); return $result; } @@ -298,13 +298,13 @@ class DateLibTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $result=convertSecondToTime(0,'all',86400); + $result=convertSecondToTime(0, 'all', 86400); print __METHOD__." result=".$result."\n"; - $this->assertEquals('0',$result); + $this->assertEquals('0', $result); - $result=convertSecondToTime(86400,'all',86400); + $result=convertSecondToTime(86400, 'all', 86400); print __METHOD__." result=".$result."\n"; - $this->assertSame('1 '.$langs->trans("Day"),$result); + $this->assertSame('1 '.$langs->trans("Day"), $result); return $result; @@ -324,57 +324,57 @@ class DateLibTest extends PHPUnit_Framework_TestCase $db=$this->savdb; // Check %Y-%m-%d %H:%M:%S format - $result=dol_print_date(0,'%Y-%m-%d %H:%M:%S',true); + $result=dol_print_date(0, '%Y-%m-%d %H:%M:%S', true); print __METHOD__." result=".$result."\n"; - $this->assertEquals('1970-01-01 00:00:00',$result); + $this->assertEquals('1970-01-01 00:00:00', $result); // Check %Y-%m-%d %H:%M:%S format - $result=dol_print_date(16725225600,'%Y-%m-%d %H:%M:%S',true); // http://www.epochconverter.com/ + $result=dol_print_date(16725225600, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ print __METHOD__." result=".$result."\n"; - $this->assertEquals('2500-01-01 00:00:00',$result); + $this->assertEquals('2500-01-01 00:00:00', $result); // Check %Y-%m-%d %H:%M:%S format - $result=dol_print_date(-1830384000,'%Y-%m-%d %H:%M:%S',true); // http://www.epochconverter.com/ + $result=dol_print_date(-1830384000, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ print __METHOD__." result=".$result."\n"; - $this->assertEquals('1912-01-01 00:00:00',$result); // dol_print_date use TZ (good) but epoch converter does not use it. + $this->assertEquals('1912-01-01 00:00:00', $result); // dol_print_date use TZ (good) but epoch converter does not use it. // Check %Y-%m-%d %H:%M:%S format - $result=dol_print_date(-11676096000,'%Y-%m-%d %H:%M:%S',true); // http://www.epochconverter.com/ + $result=dol_print_date(-11676096000, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ print __METHOD__." result=".$result."\n"; - $this->assertEquals('1600-01-01 00:00:00',$result); + $this->assertEquals('1600-01-01 00:00:00', $result); // test with negative timezone - $result=dol_print_date(-1,'%Y-%m-%d %H:%M:%S',true); // http://www.epochconverter.com/ + $result=dol_print_date(-1, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ print __METHOD__." result=".$result."\n"; - $this->assertEquals('1969-12-31 23:59:59',$result); + $this->assertEquals('1969-12-31 23:59:59', $result); // Check dayhour format for fr_FR - $outputlangs=new Translate('',$conf); + $outputlangs=new Translate('', $conf); $outputlangs->setDefaultLang('fr_FR'); $outputlangs->load("main"); - $result=dol_print_date(0+24*3600,'dayhour',true,$outputlangs); + $result=dol_print_date(0+24*3600, 'dayhour', true, $outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('02/01/1970 00:00',$result); + $this->assertEquals('02/01/1970 00:00', $result); // Check %a and %b format for fr_FR - $result=dol_print_date(0,'%a %b %B',true,$outputlangs); + $result=dol_print_date(0, '%a %b %B', true, $outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('Jeu Jan. Janvier',$result); + $this->assertEquals('Jeu Jan. Janvier', $result); // Check day format for en_US - $outputlangs=new Translate('',$conf); + $outputlangs=new Translate('', $conf); $outputlangs->setDefaultLang('en_US'); $outputlangs->load("main"); - $result=dol_print_date(0+24*3600,'day',true,$outputlangs); + $result=dol_print_date(0+24*3600, 'day', true, $outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('01/02/1970',$result); + $this->assertEquals('01/02/1970', $result); // Check %a and %b format for en_US - $result=dol_print_date(0,'%a %b %B',true,$outputlangs); + $result=dol_print_date(0, '%a %b %B', true, $outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('Thu Jan January',$result); + $this->assertEquals('Thu Jan January', $result); return $result; } @@ -393,13 +393,13 @@ class DateLibTest extends PHPUnit_Framework_TestCase $db=$this->savdb; // Check dayhour format for fr_FR - $outputlangs=new Translate('',$conf); + $outputlangs=new Translate('', $conf); $outputlangs->setDefaultLang('fr_FR'); $outputlangs->load("main"); - $result=dol_print_date(dol_time_plus_duree(dol_time_plus_duree(dol_time_plus_duree(0,1,'m'),1,'y'),1,'d'),'dayhour',true,$outputlangs); + $result=dol_print_date(dol_time_plus_duree(dol_time_plus_duree(dol_time_plus_duree(0, 1, 'm'), 1, 'y'), 1, 'd'), 'dayhour', true, $outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('02/02/1971 00:00',$result); + $this->assertEquals('02/02/1971 00:00', $result); return $result; } @@ -420,27 +420,27 @@ class DateLibTest extends PHPUnit_Framework_TestCase $stime='19700102'; $result=dol_stringtotime($stime); print __METHOD__." result=".$result."\n"; - $this->assertEquals(86400,$result); + $this->assertEquals(86400, $result); $stime='1970-01-01T02:00:00Z'; $result=dol_stringtotime($stime); print __METHOD__." result=".$result."\n"; - $this->assertEquals(7200,$result); + $this->assertEquals(7200, $result); $stime='1970-01-01 02:00:00'; $result=dol_stringtotime($stime); print __METHOD__." result=".$result."\n"; - $this->assertEquals(7200,$result); + $this->assertEquals(7200, $result); $stime='19700101T020000Z'; $result=dol_stringtotime($stime); print __METHOD__." result=".$result."\n"; - $this->assertEquals(7200,$result); + $this->assertEquals(7200, $result); $stime='19700101020000'; $result=dol_stringtotime($stime); print __METHOD__." result=".$result."\n"; - $this->assertEquals(7200,$result); + $this->assertEquals(7200, $result); return $result; } diff --git a/test/phpunit/DateLibTzFranceTest.php b/test/phpunit/DateLibTzFranceTest.php index b47cdfbfe7b..a59eb7bf242 100644 --- a/test/phpunit/DateLibTzFranceTest.php +++ b/test/phpunit/DateLibTzFranceTest.php @@ -140,64 +140,64 @@ class DateLibTzFranceTest extends PHPUnit_Framework_TestCase $db=$this->savdb; // Check %Y-%m-%d %H:%M:%S format - $result=dol_print_date(0,'%Y-%m-%d %H:%M:%S',false); + $result=dol_print_date(0, '%Y-%m-%d %H:%M:%S', false); print __METHOD__." result=".$result."\n"; - $this->assertEquals('1970-01-01 01:00:00',$result); + $this->assertEquals('1970-01-01 01:00:00', $result); // Check %Y-%m-%d %H:%M:%S format - $result=dol_print_date(16725225600,'%Y-%m-%d %H:%M:%S',false); + $result=dol_print_date(16725225600, '%Y-%m-%d %H:%M:%S', false); print __METHOD__." result=".$result."\n"; - $this->assertEquals('2500-01-01 01:00:00',$result); + $this->assertEquals('2500-01-01 01:00:00', $result); // Check %Y-%m-%d %H:%M:%S format - $result=dol_print_date(-1830384000,'%Y-%m-%d %H:%M:%S',false); // http://www.epochconverter.com/ + $result=dol_print_date(-1830384000, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/ print __METHOD__." result=".$result."\n"; - $this->assertEquals('1912-01-01 01:00:00',$result); // dol_print_date use a timezone, not epoch converter as it did not exists this year + $this->assertEquals('1912-01-01 01:00:00', $result); // dol_print_date use a timezone, not epoch converter as it did not exists this year // Specific cas during war // 1940, no timezone - $result=dol_print_date(-946771200,'%Y-%m-%d %H:%M:%S',false); // http://www.epochconverter.com/ + $result=dol_print_date(-946771200, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/ print __METHOD__." result=".$result."\n"; - $this->assertEquals('1940-01-01 01:00:00',$result); // dol_print_date use a modern timezone, not epoch converter as it did not exists this year + $this->assertEquals('1940-01-01 01:00:00', $result); // dol_print_date use a modern timezone, not epoch converter as it did not exists this year // 1941, timezone is added by germany to +2 (same for 1942) - $result=dol_print_date(-915148800,'%Y-%m-%d %H:%M:%S',false); // http://www.epochconverter.com/ + $result=dol_print_date(-915148800, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/ print __METHOD__." result=".$result."\n"; - $this->assertEquals('1941-01-01 01:00:00',$result); // dol_print_date use a modern timezone, epoch converter use historic timezone + $this->assertEquals('1941-01-01 01:00:00', $result); // dol_print_date use a modern timezone, epoch converter use historic timezone // 1943, timezone is +1 - $result=dol_print_date(-852076800,'%Y-%m-%d %H:%M:%S',false); // http://www.epochconverter.com/ + $result=dol_print_date(-852076800, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/ print __METHOD__." result=".$result."\n"; - $this->assertEquals('1943-01-01 01:00:00',$result); + $this->assertEquals('1943-01-01 01:00:00', $result); // test with negative timezone - $result=dol_print_date(-1,'%Y-%m-%d %H:%M:%S',false); // http://www.epochconverter.com/ + $result=dol_print_date(-1, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/ print __METHOD__." result=".$result."\n"; - $this->assertEquals('1970-01-01 00:59:59',$result); + $this->assertEquals('1970-01-01 00:59:59', $result); // Check dayhour format for fr_FR - $outputlangs=new Translate('',$conf); + $outputlangs=new Translate('', $conf); $outputlangs->setDefaultLang('fr_FR'); $outputlangs->load("main"); - $result=dol_print_date(0+24*3600,'dayhour',false,$outputlangs); + $result=dol_print_date(0+24*3600, 'dayhour', false, $outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('02/01/1970 01:00',$result); + $this->assertEquals('02/01/1970 01:00', $result); // Check day format for en_US - $outputlangs=new Translate('',$conf); + $outputlangs=new Translate('', $conf); $outputlangs->setDefaultLang('en_US'); $outputlangs->load("main"); - $result=dol_print_date(0+24*3600,'day',false,$outputlangs); + $result=dol_print_date(0+24*3600, 'day', false, $outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('01/02/1970',$result); + $this->assertEquals('01/02/1970', $result); // Check %a and %b format for en_US - $result=dol_print_date(0,'%a %b',false,$outputlangs); + $result=dol_print_date(0, '%a %b', false, $outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('Thu Jan',$result); + $this->assertEquals('Thu Jan', $result); return $result; } diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index a5ee6139a48..1028fc2599d 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -187,7 +187,7 @@ class EntrepotTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $localobject->note='New note after update'; - $result=$localobject->update($localobject->id,$user); + $result=$localobject->update($localobject->id, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index e387eacac6a..1b479cb1f30 100644 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -30,16 +30,16 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/exports/class/export.class.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/files.lib.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) /** @@ -237,21 +237,21 @@ class ExportTest extends PHPUnit_Framework_TestCase // Build export file $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); $expectedresult=1; - $this->assertEquals($expectedresult,$result); + $this->assertEquals($expectedresult, $result); $model='tsv'; // Build export file $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); $expectedresult=1; - $this->assertEquals($expectedresult,$result); + $this->assertEquals($expectedresult, $result); $model='excel'; // Build export file $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); $expectedresult=1; - $this->assertEquals($expectedresult,$result); + $this->assertEquals($expectedresult, $result); return true; } @@ -325,7 +325,7 @@ class ExportTest extends PHPUnit_Framework_TestCase // Load properties of arrays to make export $objexport=new Export($db); - $result=$objexport->load_arrays($user,$filterdatatoexport); // This load ->array_export_xxx properties for datatoexport + $result=$objexport->load_arrays($user, $filterdatatoexport); // This load ->array_export_xxx properties for datatoexport // Loop on each dataset foreach($objexport->array_export_code as $key => $datatoexport) diff --git a/test/phpunit/FactureRecTest.php b/test/phpunit/FactureRecTest.php index 07d728eb0ec..7156827ab72 100644 --- a/test/phpunit/FactureRecTest.php +++ b/test/phpunit/FactureRecTest.php @@ -186,7 +186,7 @@ class FactureRecTest extends PHPUnit_Framework_TestCase $aKeys=array_keys($oVarsA); foreach($aKeys as $sKey) { - if (in_array($sKey,$fieldstoignorearray)) continue; + if (in_array($sKey, $fieldstoignorearray)) continue; if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) { $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index cb23c7d092e..c450d30d056 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -364,7 +364,7 @@ class FactureTest extends PHPUnit_Framework_TestCase $aKeys=array_keys($oVarsA); foreach($aKeys as $sKey) { - if (in_array($sKey,$fieldstoignorearray)) continue; + if (in_array($sKey, $fieldstoignorearray)) continue; if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) { $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index c1a2a21b270..c1038271498 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -134,19 +134,19 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $result=dol_basename('adir/afile'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('afile',$result); + $this->assertEquals('afile', $result); $result=dol_basename('adir/afile/'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('afile',$result); + $this->assertEquals('afile', $result); $result=dol_basename('adir/νεο'); // With cyrillic data. Here basename fails to return correct value print __METHOD__." result=".$result."\n"; - $this->assertEquals('νεο',$result); + $this->assertEquals('νεο', $result); $result=dol_basename('adir/νεο/'); // With cyrillic data. Here basename fails to return correct value print __METHOD__." result=".$result."\n"; - $this->assertEquals('νεο',$result); + $this->assertEquals('νεο', $result); } @@ -166,7 +166,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $file=dirname(__FILE__).'/Example_import_company_1.csv'; $result=dol_count_nb_of_line($file); print __METHOD__." result=".$result."\n"; - $this->assertEquals(3,$result); + $this->assertEquals(3, $result); return $result; } @@ -242,35 +242,35 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $db=$this->savdb; // file.png - $result=dol_mimetype('file.png','',0); - $this->assertEquals('image/png',$result); - $result=dol_mimetype('file.png','',1); - $this->assertEquals('png',$result); - $result=dol_mimetype('file.png','',2); - $this->assertEquals('image.png',$result); - $result=dol_mimetype('file.png','',3); - $this->assertEquals('',$result); + $result=dol_mimetype('file.png', '', 0); + $this->assertEquals('image/png', $result); + $result=dol_mimetype('file.png', '', 1); + $this->assertEquals('png', $result); + $result=dol_mimetype('file.png', '', 2); + $this->assertEquals('image.png', $result); + $result=dol_mimetype('file.png', '', 3); + $this->assertEquals('', $result); // file.odt - $result=dol_mimetype('file.odt','',0); - $this->assertEquals('application/vnd.oasis.opendocument.text',$result); - $result=dol_mimetype('file.odt','',1); - $this->assertEquals('vnd.oasis.opendocument.text',$result); - $result=dol_mimetype('file.odt','',2); - $this->assertEquals('ooffice.png',$result); - $result=dol_mimetype('file.odt','',3); - $this->assertEquals('',$result); + $result=dol_mimetype('file.odt', '', 0); + $this->assertEquals('application/vnd.oasis.opendocument.text', $result); + $result=dol_mimetype('file.odt', '', 1); + $this->assertEquals('vnd.oasis.opendocument.text', $result); + $result=dol_mimetype('file.odt', '', 2); + $this->assertEquals('ooffice.png', $result); + $result=dol_mimetype('file.odt', '', 3); + $this->assertEquals('', $result); // file.php - $result=dol_mimetype('file.php','',0); - $this->assertEquals('text/plain',$result); - $result=dol_mimetype('file.php','',1); - $this->assertEquals('plain',$result); - $result=dol_mimetype('file.php','',2); - $this->assertEquals('php.png',$result); - $result=dol_mimetype('file.php','',3); - $this->assertEquals('php',$result); + $result=dol_mimetype('file.php', '', 0); + $this->assertEquals('text/plain', $result); + $result=dol_mimetype('file.php', '', 1); + $this->assertEquals('plain', $result); + $result=dol_mimetype('file.php', '', 2); + $this->assertEquals('php.png', $result); + $result=dol_mimetype('file.php', '', 3); + $this->assertEquals('php', $result); // file.php.noexe - $result=dol_mimetype('file.php.noexe','',0); - $this->assertEquals('text/plain',$result); + $result=dol_mimetype('file.php.noexe', '', 0); + $this->assertEquals('text/plain', $result); } @@ -291,24 +291,24 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $dirout2=$conf->admin->dir_temp.'/test2'; $count=0; - $result=dol_delete_dir_recursive($dirout,$count); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it + $result=dol_delete_dir_recursive($dirout, $count); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(0,$result); + $this->assertGreaterThanOrEqual(0, $result); $count=0; $countdeleted=0; - $result=dol_delete_dir_recursive($dirout,$count,1,0,$countdeleted); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it + $result=dol_delete_dir_recursive($dirout, $count, 1, 0, $countdeleted); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(0,$result); - $this->assertGreaterThanOrEqual(0,$countdeleted); + $this->assertGreaterThanOrEqual(0, $result); + $this->assertGreaterThanOrEqual(0, $countdeleted); dol_mkdir($dirout2); $count=0; $countdeleted=0; - $result=dol_delete_dir_recursive($dirout2,$count,1,0,$countdeleted); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it + $result=dol_delete_dir_recursive($dirout2, $count, 1, 0, $countdeleted); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(1,$result); - $this->assertGreaterThanOrEqual(1,$countdeleted); + $this->assertGreaterThanOrEqual(1, $result); + $this->assertGreaterThanOrEqual(1, $countdeleted); } @@ -332,56 +332,56 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $result=dol_copy($file, '/adir/that/does/not/exists/file.csv'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan(0,$result,'copy dir that does not exists'); // We should have error + $this->assertLessThan(0, $result, 'copy dir that does not exists'); // We should have error - $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,1); + $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 1); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(1,$result, 'copy file ('.$file.') into a dir that exists ('.$conf->admin->dir_temp.'/file.csv'.')'); // Should be 1 + $this->assertGreaterThanOrEqual(1, $result, 'copy file ('.$file.') into a dir that exists ('.$conf->admin->dir_temp.'/file.csv'.')'); // Should be 1 // Again to test with overwriting=0 - $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,0); + $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 0); print __METHOD__." result=".$result."\n"; - $this->assertEquals(0,$result, 'copy destination already exists, no overwrite'); // Should be 0 + $this->assertEquals(0, $result, 'copy destination already exists, no overwrite'); // Should be 0 // Again to test with overwriting=1 - $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,1); + $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 1); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(1,$result,'copy destination already exists, overwrite'); // Should be 1 + $this->assertGreaterThanOrEqual(1, $result, 'copy destination already exists, overwrite'); // Should be 1 // To test a move that should work - $result=dol_move($conf->admin->dir_temp.'/file.csv',$conf->admin->dir_temp.'/file2.csv',0,1); + $result=dol_move($conf->admin->dir_temp.'/file.csv', $conf->admin->dir_temp.'/file2.csv', 0, 1); print __METHOD__." result=".$result."\n"; - $this->assertTrue($result,'move with default mask'); + $this->assertTrue($result, 'move with default mask'); // To test a move that should work with forced mask - $result=dol_move($conf->admin->dir_temp.'/file2.csv',$conf->admin->dir_temp.'/file3.csv','0754',1); // file shoutld be rwxr-wr-- + $result=dol_move($conf->admin->dir_temp.'/file2.csv', $conf->admin->dir_temp.'/file3.csv', '0754', 1); // file shoutld be rwxr-wr-- print __METHOD__." result=".$result."\n"; - $this->assertTrue($result,'move with forced mask'); + $this->assertTrue($result, 'move with forced mask'); // To test a delete that should success $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv'); print __METHOD__." result=".$result."\n"; - $this->assertTrue($result,'delete file'); + $this->assertTrue($result, 'delete file'); // Again to test there is error when deleting a non existing file with option disableglob - $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv',1,1); + $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv', 1, 1); print __METHOD__." result=".$result."\n"; - $this->assertFalse($result,'delete file that does not exists with disableglo must return ko'); + $this->assertFalse($result, 'delete file that does not exists with disableglo must return ko'); // Again to test there is no error when deleting a non existing file without option disableglob - $result=dol_delete_file($conf->admin->dir_temp.'/file3csv',0,1); + $result=dol_delete_file($conf->admin->dir_temp.'/file3csv', 0, 1); print __METHOD__." result=".$result."\n"; - $this->assertTrue($result,'delete file that does not exists without disabling glob must return ok'); + $this->assertTrue($result, 'delete file that does not exists without disabling glob must return ok'); // Test copy with special char / delete with blob - $result=dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv',0,1); + $result=dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv', 0, 1); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(1,$result,'copy file with special chars, overwrite'); // Should be 1 + $this->assertGreaterThanOrEqual(1, $result, 'copy file with special chars, overwrite'); // Should be 1 // Try to delete using a glob criteria $result=dol_delete_file($conf->admin->dir_temp.'/file with [x]*é.csv'); print __METHOD__." result=".$result."\n"; - $this->assertTrue($result,'delete file using glob'); + $this->assertTrue($result, 'delete file using glob'); } /** @@ -407,15 +407,15 @@ class FilesLibTest extends PHPUnit_Framework_TestCase dol_delete_file($fileout); $count=0; - dol_delete_dir_recursive($dirout,$count,1); + dol_delete_dir_recursive($dirout, $count, 1); $result=dol_compress_file($filein, $fileout, $format); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(1,$result); + $this->assertGreaterThanOrEqual(1, $result); $result=dol_uncompress($fileout, $dirout); - print __METHOD__." result=".join(',',$result)."\n"; - $this->assertEquals(0,count($result)); + print __METHOD__." result=".join(',', $result)."\n"; + $this->assertEquals(0, count($result)); } /** @@ -433,7 +433,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase // Scan dir to guaruante we on't have library jquery twice (we accept exception of duplicte into ckeditor because all dir is removed for debian package, so there is no duplicate). $founddirs=dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.js', array('ckeditor')); print __METHOD__." count(founddirs)=".count($founddirs)."\n"; - $this->assertEquals(1,count($founddirs)); + $this->assertEquals(1, count($founddirs)); } @@ -464,7 +464,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $user->rights->facture->creer = 0; $filename='SPECIMEN.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read'); - $this->assertEquals(1,$result['accessallowed']); + $this->assertEquals(1, $result['accessallowed']); // Check read permission @@ -472,32 +472,32 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $user->rights->facture->creer = 1; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read'); - $this->assertEquals(1,$result['accessallowed']); + $this->assertEquals(1, $result['accessallowed']); $user->rights->facture->lire = 0; $user->rights->facture->creer = 0; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read'); - $this->assertEquals(0,$result['accessallowed']); + $this->assertEquals(0, $result['accessallowed']); // Check write permission $user->rights->facture->lire = 0; $user->rights->facture->creer = 0; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write'); - $this->assertEquals(0,$result['accessallowed']); + $this->assertEquals(0, $result['accessallowed']); $user->rights->facture->lire = 1; $user->rights->facture->creer = 1; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write'); - $this->assertEquals(1,$result['accessallowed']); + $this->assertEquals(1, $result['accessallowed']); $user->rights->facture->lire = 1; $user->rights->facture->creer = 0; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write'); - $this->assertEquals(0,$result['accessallowed']); + $this->assertEquals(0, $result['accessallowed']); // We restore user properties diff --git a/test/phpunit/FormAdminTest.php b/test/phpunit/FormAdminTest.php index 10998f7776f..dc6ed409375 100644 --- a/test/phpunit/FormAdminTest.php +++ b/test/phpunit/FormAdminTest.php @@ -132,7 +132,7 @@ class FormAdminTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $localobject=new FormAdmin($this->savdb); - $result=$localobject->select_paper_format('','paperformat_id','A4'); + $result=$localobject->select_paper_format('', 'paperformat_id', 'A4'); $this->assertEquals($result, ''); print __METHOD__." result=".$result."\n"; diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php index a11c50b7198..2f6a45e2599 100644 --- a/test/phpunit/Functions2LibTest.php +++ b/test/phpunit/Functions2LibTest.php @@ -29,16 +29,16 @@ global $conf,$user,$langs,$db; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/functions2.lib.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) /** @@ -130,7 +130,7 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase { $result=jsUnEscape('%u03BD%u03B5%u03BF'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('νεο',$result); + $this->assertEquals('νεο', $result); } /** @@ -218,7 +218,7 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase $ip='a299.299.299.299'; $result=is_ip($ip); print __METHOD__." for ".$ip." result=".$result."\n"; - $this->assertEquals(0,$result,$ip); + $this->assertEquals(0, $result, $ip); // Reserved IP range (not checked by is_ip function) $ip='169.254.0.0'; @@ -229,22 +229,22 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase $ip='1.2.3.4'; $result=is_ip($ip); print __METHOD__." for ".$ip." result=".$result."\n"; - $this->assertEquals(1,$result,$ip); + $this->assertEquals(1, $result, $ip); // Private IP ranges $ip='10.0.0.0'; $result=is_ip($ip); print __METHOD__." for ".$ip." result=".$result."\n"; - $this->assertEquals(2,$result,$ip); + $this->assertEquals(2, $result, $ip); $ip='172.16.0.0'; $result=is_ip($ip); print __METHOD__." for ".$ip." result=".$result."\n"; - $this->assertEquals(2,$result,$ip); + $this->assertEquals(2, $result, $ip); $ip='192.168.0.0'; $result=is_ip($ip); print __METHOD__." for ".$ip." result=".$result."\n"; - $this->assertEquals(2,$result,$ip); + $this->assertEquals(2, $result, $ip); } } diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index b693290b9c4..2ab796dfba8 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -30,16 +30,16 @@ global $conf,$user,$langs,$db; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) /** * Class for PHPUnit tests @@ -249,8 +249,8 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase // MSIE 5.0 $user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; $tmp=getBrowserInfo($user_agent); - $this->assertEquals('ie',$tmp['browsername']); - $this->assertEquals('5.0',$tmp['browserversion']); + $this->assertEquals('ie', $tmp['browsername']); + $this->assertEquals('5.0', $tmp['browserversion']); $this->assertEmpty($tmp['phone']); $this->assertFalse($tmp['tablet']); $this->assertEquals('classic', $tmp['layout']); @@ -258,40 +258,40 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase // Firefox 0.9.1 $user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; $tmp=getBrowserInfo($user_agent); - $this->assertEquals('firefox',$tmp['browsername']); - $this->assertEquals('0.9.1',$tmp['browserversion']); + $this->assertEquals('firefox', $tmp['browsername']); + $this->assertEquals('0.9.1', $tmp['browserversion']); $this->assertEmpty($tmp['phone']); $this->assertFalse($tmp['tablet']); $this->assertEquals('classic', $tmp['layout']); $user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]'; $tmp=getBrowserInfo($user_agent); - $this->assertEquals('opera',$tmp['browsername']); - $this->assertEquals('6.03',$tmp['browserversion']); + $this->assertEquals('opera', $tmp['browsername']); + $this->assertEquals('6.03', $tmp['browserversion']); $this->assertEmpty($tmp['phone']); $this->assertFalse($tmp['tablet']); $this->assertEquals('classic', $tmp['layout']); $user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21'; $tmp=getBrowserInfo($user_agent); - $this->assertEquals('chrome',$tmp['browsername']); - $this->assertEquals('19.0.1042.0',$tmp['browserversion']); + $this->assertEquals('chrome', $tmp['browsername']); + $this->assertEquals('19.0.1042.0', $tmp['browserversion']); $this->assertEmpty($tmp['phone']); $this->assertFalse($tmp['tablet']); $this->assertEquals('classic', $tmp['layout']); $user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)'; $tmp=getBrowserInfo($user_agent); - $this->assertEquals('chrome',$tmp['browsername']); - $this->assertEquals('17.0.963.56',$tmp['browserversion']); + $this->assertEquals('chrome', $tmp['browsername']); + $this->assertEquals('17.0.963.56', $tmp['browserversion']); $this->assertEmpty($tmp['phone']); $this->assertFalse($tmp['tablet']); $this->assertEquals('classic', $tmp['layout']); $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'; $tmp=getBrowserInfo($user_agent); - $this->assertEquals('safari',$tmp['browsername']); - $this->assertEquals('533.21.1',$tmp['browserversion']); + $this->assertEquals('safari', $tmp['browsername']); + $this->assertEquals('533.21.1', $tmp['browserversion']); $this->assertEmpty($tmp['phone']); $this->assertFalse($tmp['tablet']); $this->assertEquals('classic', $tmp['layout']); @@ -299,8 +299,8 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase //Internet Explorer 11 $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; $tmp=getBrowserInfo($user_agent); - $this->assertEquals('ie',$tmp['browsername']); - $this->assertEquals('11.0',$tmp['browserversion']); + $this->assertEquals('ie', $tmp['browsername']); + $this->assertEquals('11.0', $tmp['browserversion']); $this->assertEmpty($tmp['phone']); $this->assertFalse($tmp['tablet']); $this->assertEquals('classic', $tmp['layout']); @@ -308,8 +308,8 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase //Internet Explorer 11 bis $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko'; $tmp=getBrowserInfo($user_agent); - $this->assertEquals('ie',$tmp['browsername']); - $this->assertEquals('11.0',$tmp['browserversion']); + $this->assertEquals('ie', $tmp['browsername']); + $this->assertEquals('11.0', $tmp['browserversion']); $this->assertEmpty($tmp['phone']); $this->assertFalse($tmp['tablet']); $this->assertEquals('classic', $tmp['layout']); @@ -317,11 +317,11 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase //iPad $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'; $tmp=getBrowserInfo($user_agent); - $this->assertEquals('safari',$tmp['browsername']); - $this->assertEquals('8536.25',$tmp['browserversion']); - $this->assertEquals('ios',$tmp['browseros']); - $this->assertEquals('tablet',$tmp['layout']); - $this->assertEquals('iphone',$tmp['phone']); + $this->assertEquals('safari', $tmp['browsername']); + $this->assertEquals('8536.25', $tmp['browserversion']); + $this->assertEquals('ios', $tmp['browseros']); + $this->assertEquals('tablet', $tmp['layout']); + $this->assertEquals('iphone', $tmp['phone']); } @@ -455,31 +455,31 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase { $input="A string\n"; $after=dol_htmlcleanlastbr($input); - $this->assertEquals("A string",$after); + $this->assertEquals("A string", $after); $input="A string first\nA string second\n"; $after=dol_htmlcleanlastbr($input); - $this->assertEquals("A string first\nA string second",$after); + $this->assertEquals("A string first\nA string second", $after); $input="A string\n\n\n"; $after=dol_htmlcleanlastbr($input); - $this->assertEquals("A string",$after); + $this->assertEquals("A string", $after); $input="A string
"; $after=dol_htmlcleanlastbr($input); - $this->assertEquals("A string",$after); + $this->assertEquals("A string", $after); $input="A string first
\nA string second
"; $after=dol_htmlcleanlastbr($input); - $this->assertEquals("A string first
\nA string second",$after); + $this->assertEquals("A string first
\nA string second", $after); $input="A string\n
\n"; $after=dol_htmlcleanlastbr($input); - $this->assertEquals("A string",$after); + $this->assertEquals("A string", $after); $input="A string\n

\n\n"; $after=dol_htmlcleanlastbr($input); - $this->assertEquals("A string",$after); + $this->assertEquals("A string", $after); return true; } @@ -493,15 +493,15 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase { $text1="A string 1"; $text2="A string 2"; // text 1 and 2 are text, concat need only \n $after=dol_concatdesc($text1, $text2); - $this->assertEquals("A string 1\nA string 2",$after); + $this->assertEquals("A string 1\nA string 2", $after); $text1="A
string 1"; $text2="A string 2"; // text 1 is html, concat need
\n $after=dol_concatdesc($text1, $text2); - $this->assertEquals("A
string 1
\nA string 2",$after); + $this->assertEquals("A
string 1
\nA string 2", $after); $text1="A string 1"; $text2="A string 2"; // text 2 is html, concat need
\n $after=dol_concatdesc($text1, $text2); - $this->assertEquals("A string 1
\nA string 2",$after); + $this->assertEquals("A string 1
\nA string 2", $after); return true; } @@ -515,48 +515,48 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase public function testDolStringNohtmltag() { $text="A\nstring\n\nand more\n"; - $after=dol_string_nohtmltag($text,0); - $this->assertEquals("A\nstring\n\nand more",$after,"test1a"); + $after=dol_string_nohtmltag($text, 0); + $this->assertEquals("A\nstring\n\nand more", $after, "test1a"); $text="A string
\n
\n\nwith html tag
\n"; $after=dol_string_nohtmltag($text, 0); - $this->assertEquals("A string\n\n\n\n\nwith html tag",$after,"test2a 2 br and 3 \n give 5 \n"); + $this->assertEquals("A string\n\n\n\n\nwith html tag", $after, "test2a 2 br and 3 \n give 5 \n"); $text="A string
\n
\n\nwith html tag
\n"; $after=dol_string_nohtmltag($text, 1); - $this->assertEquals("A string with html tag",$after,"test2b 2 br and 3 \n give 1 space"); + $this->assertEquals("A string with html tag", $after, "test2b 2 br and 3 \n give 1 space"); $text="A string
\n
\n\nwith html tag
\n"; $after=dol_string_nohtmltag($text, 2); - $this->assertEquals("A string\n\nwith html tag",$after,"test2c 2 br and 3 \n give 2 \n"); + $this->assertEquals("A string\n\nwith html tag", $after, "test2c 2 br and 3 \n give 2 \n"); $text="A string
Another string"; - $after=dol_string_nohtmltag($text,0); - $this->assertEquals("A string\nAnother string",$after,"test4"); + $after=dol_string_nohtmltag($text, 0); + $this->assertEquals("A string\nAnother string", $after, "test4"); $text="A string
Another string"; - $after=dol_string_nohtmltag($text,1); - $this->assertEquals("A string Another string",$after,"test5"); + $after=dol_string_nohtmltag($text, 1); + $this->assertEquals("A string Another string", $after, "test5"); $text='ABC'; - $after=dol_string_nohtmltag($text,1); - $this->assertEquals("ABC",$after,"test6"); + $after=dol_string_nohtmltag($text, 1); + $this->assertEquals("ABC", $after, "test6"); $text='DEF'; - $after=dol_string_nohtmltag($text,1); - $this->assertEquals("DEF",$after,"test7"); + $after=dol_string_nohtmltag($text, 1); + $this->assertEquals("DEF", $after, "test7"); $text='HIJ'; - $after=dol_string_nohtmltag($text,0); - $this->assertEquals("HIJ",$after,"test8"); + $after=dol_string_nohtmltag($text, 0); + $this->assertEquals("HIJ", $after, "test8"); $text="A string\n\nwith html tag and '<' chars
\n"; $after=dol_string_nohtmltag($text, 0); - $this->assertEquals("A string\n\nwith html tag and '<' chars",$after,"test9"); + $this->assertEquals("A string\n\nwith html tag and '<' chars", $after, "test9"); $text="A string\n\nwith tag with < chars
\n"; $after=dol_string_nohtmltag($text, 1); - $this->assertEquals("A string with tag with < chars",$after,"test10"); + $this->assertEquals("A string with tag with < chars", $after, "test10"); return true; } @@ -573,38 +573,38 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase // Text not already HTML $input="A string\nwith a é, &, < and >."; - $after=dol_htmlentitiesbr($input,0); // Add
before \n - $this->assertEquals("A string
\nwith a é, &, < and >.",$after); + $after=dol_htmlentitiesbr($input, 0); // Add
before \n + $this->assertEquals("A string
\nwith a é, &, < and >.", $after); $input="A string\nwith a é, &, < and >."; - $after=dol_htmlentitiesbr($input,1); // Replace \n with
- $this->assertEquals("A string
with a é, &, < and >.",$after); + $after=dol_htmlentitiesbr($input, 1); // Replace \n with
+ $this->assertEquals("A string
with a é, &, < and >.", $after); $input="A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned - $after=dol_htmlentitiesbr($input,0); // Add
before \n - $this->assertEquals("A string
\nwith a é, &, < and >.",$after); + $after=dol_htmlentitiesbr($input, 0); // Add
before \n + $this->assertEquals("A string
\nwith a é, &, < and >.", $after); $input="A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned - $after=dol_htmlentitiesbr($input,1); // Replace \n with
- $this->assertEquals("A string
with a é, &, < and >.",$after); + $after=dol_htmlentitiesbr($input, 1); // Replace \n with
+ $this->assertEquals("A string
with a é, &, < and >.", $after); // Text already HTML, so &,<,> should not be converted $input="A string
\nwith a é, &, < and >."; $after=dol_htmlentitiesbr($input); - $this->assertEquals("A string
\nwith a é, &, < and >.",$after); + $this->assertEquals("A string
\nwith a é, &, < and >.", $after); $input="
  • \nA string with a é, &, < and >.
  • \nAnother string"; $after=dol_htmlentitiesbr($input); - $this->assertEquals("
  • \nA string with a é, &, < and >.
  • \nAnother string",$after); + $this->assertEquals("
  • \nA string with a é, &, < and >.
  • \nAnother string", $after); $input="A string
    \nwith a é, &, < and >.
    "; // With some
    at end that should be cleaned $after=dol_htmlentitiesbr($input); - $this->assertEquals("A string
    \nwith a é, &, < and >.",$after); + $this->assertEquals("A string
    \nwith a é, &, < and >.", $after); $input="
  • \nA string with a é, &, < and >.
  • \nAnother string
    "; // With some
    at end that should be cleaned $after=dol_htmlentitiesbr($input); - $this->assertEquals("
  • \nA string with a é, &, < and >.
  • \nAnother string",$after); + $this->assertEquals("
  • \nA string with a é, &, < and >.
  • \nAnother string", $after); // TODO Add test with param $removelasteolbr = 0 @@ -621,18 +621,18 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase { // This is not a html string so nb of lines depends on \n $input="A string\nwith a é, &, < and > and bold tag.\nThird line"; - $after=dol_nboflines_bis($input,0); - $this->assertEquals($after,3); + $after=dol_nboflines_bis($input, 0); + $this->assertEquals($after, 3); // This is a html string so nb of lines depends on
    $input="A string\nwith a é, &, < and > and bold tag.\nThird line"; - $after=dol_nboflines_bis($input,0); - $this->assertEquals($after,1); + $after=dol_nboflines_bis($input, 0); + $this->assertEquals($after, 1); // This is a html string so nb of lines depends on
    $input="A string
    with a é, &, < and > and bold tag.
    Third line"; - $after=dol_nboflines_bis($input,0); - $this->assertEquals($after,3); + $after=dol_nboflines_bis($input, 0); + $this->assertEquals($after, 3); return true; } @@ -649,7 +649,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; $after=dol_string_unaccent($input); - $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.",$after); + $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.", $after); } @@ -684,49 +684,49 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase { // Default trunc (will add ... if truncation truncation or keep last char if only one char) $input="éeéeéeàa"; - $after=dol_trunc($input,3); - $this->assertEquals("éeé...",$after,'Test A1'); - $after=dol_trunc($input,2); - $this->assertEquals("ée...",$after,'Test A2'); - $after=dol_trunc($input,1); - $this->assertEquals("é...",$after,'Test A3'); + $after=dol_trunc($input, 3); + $this->assertEquals("éeé...", $after, 'Test A1'); + $after=dol_trunc($input, 2); + $this->assertEquals("ée...", $after, 'Test A2'); + $after=dol_trunc($input, 1); + $this->assertEquals("é...", $after, 'Test A3'); $input="éeéeé"; - $after=dol_trunc($input,3); - $this->assertEquals("éeéeé",$after,'Test B1'); - $after=dol_trunc($input,2); - $this->assertEquals("éeéeé",$after,'Test B2'); - $after=dol_trunc($input,1); - $this->assertEquals("é...",$after,'Test B3'); + $after=dol_trunc($input, 3); + $this->assertEquals("éeéeé", $after, 'Test B1'); + $after=dol_trunc($input, 2); + $this->assertEquals("éeéeé", $after, 'Test B2'); + $after=dol_trunc($input, 1); + $this->assertEquals("é...", $after, 'Test B3'); $input="éeée"; - $after=dol_trunc($input,3); - $this->assertEquals("éeée",$after,'Test C1'); - $after=dol_trunc($input,2); - $this->assertEquals("éeée",$after,'Test C2'); - $after=dol_trunc($input,1); - $this->assertEquals("éeée",$after,'Test C3'); + $after=dol_trunc($input, 3); + $this->assertEquals("éeée", $after, 'Test C1'); + $after=dol_trunc($input, 2); + $this->assertEquals("éeée", $after, 'Test C2'); + $after=dol_trunc($input, 1); + $this->assertEquals("éeée", $after, 'Test C3'); $input="éeé"; - $after=dol_trunc($input,3); - $this->assertEquals("éeé",$after,'Test C'); - $after=dol_trunc($input,2); - $this->assertEquals("éeé",$after,'Test D'); - $after=dol_trunc($input,1); - $this->assertEquals("éeé",$after,'Test E'); + $after=dol_trunc($input, 3); + $this->assertEquals("éeé", $after, 'Test C'); + $after=dol_trunc($input, 2); + $this->assertEquals("éeé", $after, 'Test D'); + $after=dol_trunc($input, 1); + $this->assertEquals("éeé", $after, 'Test E'); // Trunc with no ... $input="éeéeéeàa"; - $after=dol_trunc($input,3,'right','UTF-8',1); - $this->assertEquals("éeé",$after,'Test F'); - $after=dol_trunc($input,2,'right','UTF-8',1); - $this->assertEquals("ée",$after,'Test G'); + $after=dol_trunc($input, 3, 'right', 'UTF-8', 1); + $this->assertEquals("éeé", $after, 'Test F'); + $after=dol_trunc($input, 2, 'right', 'UTF-8', 1); + $this->assertEquals("ée", $after, 'Test G'); $input="éeé"; - $after=dol_trunc($input,3,'right','UTF-8',1); - $this->assertEquals("éeé",$after,'Test H'); - $after=dol_trunc($input,2,'right','UTF-8',1); - $this->assertEquals("ée",$after,'Test I'); - $after=dol_trunc($input,1,'right','UTF-8',1); - $this->assertEquals("é",$after,'Test J'); + $after=dol_trunc($input, 3, 'right', 'UTF-8', 1); + $this->assertEquals("éeé", $after, 'Test H'); + $after=dol_trunc($input, 2, 'right', 'UTF-8', 1); + $this->assertEquals("ée", $after, 'Test I'); + $after=dol_trunc($input, 1, 'right', 'UTF-8', 1); + $this->assertEquals("é", $after, 'Test J'); $input="éeéeéeàa"; - $after=dol_trunc($input,4,'middle'); - $this->assertEquals("ée...àa",$after,'Test K'); + $after=dol_trunc($input, 4, 'middle'); + $this->assertEquals("ée...àa", $after, 'Test K'); return true; } @@ -746,43 +746,43 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase date_default_timezone_set('UTC'); // Check bad hours - $result=dol_mktime(25,0,0,1,1,1970,1,1); // Error (25 hours) + $result=dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1); // Error (25 hours) print __METHOD__." result=".$result."\n"; - $this->assertEquals('',$result); - $result=dol_mktime(2,61,0,1,1,1970,1,1); // Error (61 minutes) + $this->assertEquals('', $result); + $result=dol_mktime(2, 61, 0, 1, 1, 1970, 1, 1); // Error (61 minutes) print __METHOD__." result=".$result."\n"; - $this->assertEquals('',$result); - $result=dol_mktime(2,1,61,1,1,1970,1,1); // Error (61 seconds) + $this->assertEquals('', $result); + $result=dol_mktime(2, 1, 61, 1, 1, 1970, 1, 1); // Error (61 seconds) print __METHOD__." result=".$result."\n"; - $this->assertEquals('',$result); - $result=dol_mktime(2,1,1,1,32,1970,1,1); // Error (day 32) + $this->assertEquals('', $result); + $result=dol_mktime(2, 1, 1, 1, 32, 1970, 1, 1); // Error (day 32) print __METHOD__." result=".$result."\n"; - $this->assertEquals('',$result); - $result=dol_mktime(2,1,1,13,1,1970,1,1); // Error (month 13) + $this->assertEquals('', $result); + $result=dol_mktime(2, 1, 1, 13, 1, 1970, 1, 1); // Error (month 13) print __METHOD__." result=".$result."\n"; - $this->assertEquals('',$result); + $this->assertEquals('', $result); - $result=dol_mktime(2,1,1,1,1,1970,1); // 1970-01-01 02:01:01 in GMT area -> 7261 + $result=dol_mktime(2, 1, 1, 1, 1, 1970, 1); // 1970-01-01 02:01:01 in GMT area -> 7261 print __METHOD__." result=".$result."\n"; - $this->assertEquals(7261,$result); + $this->assertEquals(7261, $result); - $result=dol_mktime(2,0,0,1,1,1970,0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT + $result=dol_mktime(2, 0, 0, 1, 1, 1970, 0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT print __METHOD__." result=".$result."\n"; $tz=getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter) - $this->assertEquals(7200-($tz*3600),$result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter + $this->assertEquals(7200-($tz*3600), $result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter // Some test for local TZ Europe/Paris date_default_timezone_set('Europe/Paris'); // Check that tz for paris in winter is used - $result=dol_mktime(2,0,0,1,1,1970,'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT + $result=dol_mktime(2, 0, 0, 1, 1, 1970, 'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT print __METHOD__." result=".$result."\n"; - $this->assertEquals(3600,$result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris + $this->assertEquals(3600, $result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris // Check that daylight saving time is used - $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 + $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 print __METHOD__." result=".$result."\n"; - $this->assertEquals(1401588000-3600-3600,$result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer + $this->assertEquals(1401588000-3600-3600, $result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer date_default_timezone_set($savtz); } @@ -797,13 +797,13 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase { $input="x&#,\"'"; // " will be converted into ' $result=dol_escape_js($input); - $this->assertEquals("x&#,\'\'",$result,"Test mode=0"); + $this->assertEquals("x&#,\'\'", $result, "Test mode=0"); - $result=dol_escape_js($input,1); - $this->assertEquals("x&#,\"\'",$result,"Test mode=1"); + $result=dol_escape_js($input, 1); + $this->assertEquals("x&#,\"\'", $result, "Test mode=1"); - $result=dol_escape_js($input,2); - $this->assertEquals("x&#,\\\"'",$result,"Test mode=2"); + $result=dol_escape_js($input, 2); + $this->assertEquals("x&#,\\\"'", $result, "Test mode=2"); } @@ -816,11 +816,11 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase { $input='x&#,"'; // & and " are converted into html entities, are removed $result=dol_escape_htmltag($input); - $this->assertEquals('x&#,"',$result); + $this->assertEquals('x&#,"', $result); $input='x&#,"'; // & and " are converted into html entities, are not removed - $result=dol_escape_htmltag($input,1); - $this->assertEquals('x&<b>#</b>,"',$result); + $result=dol_escape_htmltag($input, 1); + $this->assertEquals('x&<b>#</b>,"', $result); } @@ -842,19 +842,19 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $object->country_code='FR'; $address=dol_format_address($object); - $this->assertEquals("21 jump street\n99999 MyTown",$address); + $this->assertEquals("21 jump street\n99999 MyTown", $address); $object->country_code='GB'; $address=dol_format_address($object); - $this->assertEquals("21 jump street\nMyTown, MyState\n99999",$address); + $this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address); $object->country_code='US'; $address=dol_format_address($object); - $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address); + $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); $object->country_code='AU'; $address=dol_format_address($object); - $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address); + $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); } @@ -899,26 +899,26 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testImgPicto() { - $s=img_picto('title','user'); + $s=img_picto('title', 'user'); print __METHOD__." s=".$s."\n"; - $this->assertContains('theme',$s,'testImgPicto1'); + $this->assertContains('theme', $s, 'testImgPicto1'); - $s=img_picto('title','img.png','style="float: right"',0); + $s=img_picto('title', 'img.png', 'style="float: right"', 0); print __METHOD__." s=".$s."\n"; - $this->assertContains('theme',$s,'testImgPicto2'); - $this->assertContains('style="float: right"',$s,'testImgPicto2'); + $this->assertContains('theme', $s, 'testImgPicto2'); + $this->assertContains('style="float: right"', $s, 'testImgPicto2'); $s=img_picto('title', '/fullpath/img.png', '', 1); print __METHOD__." s=".$s."\n"; - $this->assertEquals('',$s,'testImgPicto3'); + $this->assertEquals('', $s, 'testImgPicto3'); $s=img_picto('title', '/fullpath/img.png', '', true); print __METHOD__." s=".$s."\n"; - $this->assertEquals('',$s,'testImgPicto4'); + $this->assertEquals('', $s, 'testImgPicto4'); $s=img_picto('title', 'delete', '', 0, 1); print __METHOD__." s=".$s."\n"; - $this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png',$s,'testImgPicto5'); + $this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png', $s, 'testImgPicto5'); } /** @@ -931,7 +931,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $now=dol_now('gmt'); $nowtzserver=dol_now('tzserver'); print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now')*3600)."\n"; - $this->assertEquals(getServerTimeZoneInt('now')*3600,($nowtzserver-$now)); + $this->assertEquals(getServerTimeZoneInt('now')*3600, ($nowtzserver-$now)); } /** @@ -942,16 +942,16 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase public function testVerifCond() { $verifcond=verifCond('1==1'); - $this->assertTrue($verifcond,'Test a true comparison'); + $this->assertTrue($verifcond, 'Test a true comparison'); $verifcond=verifCond('1==2'); - $this->assertFalse($verifcond,'Test a false comparison'); + $this->assertFalse($verifcond, 'Test a false comparison'); $verifcond=verifCond('$conf->facture->enabled'); - $this->assertTrue($verifcond,'Test that conf property of a module report true when enabled'); + $this->assertTrue($verifcond, 'Test that conf property of a module report true when enabled'); $verifcond=verifCond('$conf->moduledummy->enabled'); - $this->assertFalse($verifcond,'Test that conf property of a module report false when disabled'); + $this->assertFalse($verifcond, 'Test that conf property of a module report false when disabled'); $verifcond=verifCond(''); $this->assertTrue($verifcond); @@ -1012,28 +1012,28 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase // Not tested // Test RULE 1 - $vat=get_default_tva($companyfrnovat,$companymc,0); - $this->assertEquals(0,$vat,'RULE 1'); + $vat=get_default_tva($companyfrnovat, $companymc, 0); + $this->assertEquals(0, $vat, 'RULE 1'); // Test RULE 2 (FR-FR) - $vat=get_default_tva($companyfr,$companyfr,0); - $this->assertEquals(20,$vat,'RULE 2'); + $vat=get_default_tva($companyfr, $companyfr, 0); + $this->assertEquals(20, $vat, 'RULE 2'); // Test RULE 2 (FR-MC) - $vat=get_default_tva($companyfr,$companymc,0); - $this->assertEquals(20,$vat,'RULE 2'); + $vat=get_default_tva($companyfr, $companymc, 0); + $this->assertEquals(20, $vat, 'RULE 2'); // Test RULE 3 (FR-DE company) - $vat=get_default_tva($companyfr,$companyit,0); - $this->assertEquals(0,$vat,'RULE 3'); + $vat=get_default_tva($companyfr, $companyit, 0); + $this->assertEquals(0, $vat, 'RULE 3'); // Test RULE 4 (FR-DE not a company) - $vat=get_default_tva($companyfr,$notcompanyde,0); - $this->assertEquals(20,$vat,'RULE 4'); + $vat=get_default_tva($companyfr, $notcompanyde, 0); + $this->assertEquals(20, $vat, 'RULE 4'); // Test RULE 5 (FR-US) - $vat=get_default_tva($companyfr,$companyus,0); - $this->assertEquals(0,$vat,'RULE 5'); + $vat=get_default_tva($companyfr, $companyus, 0); + $this->assertEquals(0, $vat, 'RULE 5'); // We do same tests but with option SERVICE_ARE_ECOMMERCE_200238EC on. @@ -1041,24 +1041,24 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase // Test RULE 1 (FR-US) - $vat=get_default_tva($companyfr,$companyus,0); - $this->assertEquals(0,$vat,'RULE 1 ECOMMERCE_200238EC'); + $vat=get_default_tva($companyfr, $companyus, 0); + $this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC'); // Test RULE 2 (FR-FR) - $vat=get_default_tva($companyfr,$companyfr,0); - $this->assertEquals(20,$vat,'RULE 2 ECOMMERCE_200238EC'); + $vat=get_default_tva($companyfr, $companyfr, 0); + $this->assertEquals(20, $vat, 'RULE 2 ECOMMERCE_200238EC'); // Test RULE 3 (FR-DE company) - $vat=get_default_tva($companyfr,$companyde,0); - $this->assertEquals(0,$vat,'RULE 3 ECOMMERCE_200238EC'); + $vat=get_default_tva($companyfr, $companyde, 0); + $this->assertEquals(0, $vat, 'RULE 3 ECOMMERCE_200238EC'); // Test RULE 4 (FR-DE not a company) - $vat=get_default_tva($companyfr,$notcompanyde,0); - $this->assertEquals(19,$vat,'RULE 4 ECOMMERCE_200238EC'); + $vat=get_default_tva($companyfr, $notcompanyde, 0); + $this->assertEquals(19, $vat, 'RULE 4 ECOMMERCE_200238EC'); // Test RULE 5 (FR-US) - $vat=get_default_tva($companyfr,$companyus,0); - $this->assertEquals(0,$vat,'RULE 5 ECOMMERCE_200238EC'); + $vat=get_default_tva($companyfr, $companyus, 0); + $this->assertEquals(0, $vat, 'RULE 5 ECOMMERCE_200238EC'); } /** @@ -1115,37 +1115,37 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $companyus->localtax2_assuj=0; // Test RULE FR-MC - $vat1=get_default_localtax($companyfrnovat,$companymc,1,0); - $vat2=get_default_localtax($companyfrnovat,$companymc,2,0); - $this->assertEquals(0,$vat1); - $this->assertEquals(0,$vat2); + $vat1=get_default_localtax($companyfrnovat, $companymc, 1, 0); + $vat2=get_default_localtax($companyfrnovat, $companymc, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); // Test RULE ES-ES - $vat1=get_default_localtax($companyes,$companyes,1,0); - $vat2=get_default_localtax($companyes,$companyes,2,0); + $vat1=get_default_localtax($companyes, $companyes, 1, 0); + $vat2=get_default_localtax($companyes, $companyes, 2, 0); $this->assertEquals($vat1, 5.2); $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) // Test RULE ES-IT - $vat1=get_default_localtax($companyes,$companyit,1,0); - $vat2=get_default_localtax($companyes,$companyit,2,0); - $this->assertEquals(0,$vat1); - $this->assertEquals(0,$vat2); + $vat1=get_default_localtax($companyes, $companyit, 1, 0); + $vat2=get_default_localtax($companyes, $companyit, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); // Test RULE ES-IT - $vat1=get_default_localtax($companyes,$notcompanyit,1,0); - $vat2=get_default_localtax($companyes,$notcompanyit,2,0); - $this->assertEquals(0,$vat1); - $this->assertEquals(0,$vat2); + $vat1=get_default_localtax($companyes, $notcompanyit, 1, 0); + $vat2=get_default_localtax($companyes, $notcompanyit, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); // Test RULE FR-IT // Not tested // Test RULE ES-US - $vat1=get_default_localtax($companyes,$companyus,1,0); - $vat2=get_default_localtax($companyes,$companyus,2,0); - $this->assertEquals(0,$vat1); - $this->assertEquals(0,$vat2); + $vat1=get_default_localtax($companyes, $companyus, 1, 0); + $vat2=get_default_localtax($companyes, $companyus, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); } @@ -1157,10 +1157,10 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase public function testDolExplodeIntoArray() { $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.'; - $tmp=dolExplodeIntoArray($stringtoexplode,'.','='); + $tmp=dolExplodeIntoArray($stringtoexplode, '.', '='); print __METHOD__." tmp=".json_encode($tmp)."\n"; - $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}',json_encode($tmp)); + $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}', json_encode($tmp)); } /** @@ -1194,22 +1194,22 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase public function testDolPrice2Num() { $this->assertEquals(1000, price2num('1 000.0')); - $this->assertEquals(1000, price2num('1 000','MT')); - $this->assertEquals(1000, price2num('1 000','MU')); + $this->assertEquals(1000, price2num('1 000', 'MT')); + $this->assertEquals(1000, price2num('1 000', 'MU')); $this->assertEquals(1000.123456, price2num('1 000.123456')); // Round down - $this->assertEquals(1000.12, price2num('1 000.123452','MT')); - $this->assertEquals(1000.12345, price2num('1 000.123452','MU'),"Test MU"); + $this->assertEquals(1000.12, price2num('1 000.123452', 'MT')); + $this->assertEquals(1000.12345, price2num('1 000.123452', 'MU'), "Test MU"); // Round up - $this->assertEquals(1000.13, price2num('1 000.125456','MT')); - $this->assertEquals(1000.12546, price2num('1 000.125456','MU'),"Test MU"); + $this->assertEquals(1000.13, price2num('1 000.125456', 'MT')); + $this->assertEquals(1000.12546, price2num('1 000.125456', 'MU'), "Test MU"); // Text can't be converted - $this->assertEquals('12.4$',price2num('12.4$')); - $this->assertEquals('12r.4$',price2num('12r.4$')); + $this->assertEquals('12.4$', price2num('12.4$')); + $this->assertEquals('12r.4$', price2num('12r.4$')); return true; } diff --git a/test/phpunit/GetUrlLibTest.php b/test/phpunit/GetUrlLibTest.php index c99f71a972f..754cea5f9c9 100644 --- a/test/phpunit/GetUrlLibTest.php +++ b/test/phpunit/GetUrlLibTest.php @@ -134,35 +134,35 @@ class GetUrlLibTest extends PHPUnit_Framework_TestCase $result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com',$result,'Test 1'); + $this->assertEquals('http://www.dolimed.com', $result, 'Test 1'); $result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com',$result,'Test 2'); + $this->assertEquals('https://www.dolimed.com', $result, 'Test 2'); $result=getRootURLFromURL('http://www.dolimed.com/screenshots'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com',$result); + $this->assertEquals('http://www.dolimed.com', $result); $result=getRootURLFromURL('https://www.dolimed.com/screenshots'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com',$result); + $this->assertEquals('https://www.dolimed.com', $result); $result=getRootURLFromURL('http://www.dolimed.com/'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com',$result); + $this->assertEquals('http://www.dolimed.com', $result); $result=getRootURLFromURL('https://www.dolimed.com/'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com',$result); + $this->assertEquals('https://www.dolimed.com', $result); $result=getRootURLFromURL('http://www.dolimed.com'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com',$result); + $this->assertEquals('http://www.dolimed.com', $result); $result=getRootURLFromURL('https://www.dolimed.com'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com',$result); + $this->assertEquals('https://www.dolimed.com', $result); return 1; } @@ -183,11 +183,11 @@ class GetUrlLibTest extends PHPUnit_Framework_TestCase $result=removeHtmlComment('abcdef'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('abcdef',$result,'Test 1'); + $this->assertEquals('abcdef', $result, 'Test 1'); $result=removeHtmlComment('abcbbdef'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('abcbbdef',$result,'Test 1'); + $this->assertEquals('abcbbdef', $result, 'Test 1'); return 1; } diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index 37684e731d5..ce50174dc0b 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -204,11 +204,11 @@ class HolidayTest extends PHPUnit_Framework_TestCase $localobject->jabberid='New im id'; $localobject->default_lang='es_ES'; - $result=$localobject->update($localobject->id,$user); + $result=$localobject->update($localobject->id, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0, 'Holiday::update error'); - $result=$localobject->update_note($localobject->note_private,'_private'); + $result=$localobject->update_note($localobject->note_private, '_private'); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0, 'Holiday::update_note (private) error'); @@ -223,7 +223,7 @@ class HolidayTest extends PHPUnit_Framework_TestCase $this->assertLessThan($result, 0, 'Holiday::fetch error'); print __METHOD__." old=".$localobject->note." new=".$newobject->note."\n"; - $this->assertEquals($localobject->note, $newobject->note,'Holiday::update_note error compare note'); + $this->assertEquals($localobject->note, $newobject->note, 'Holiday::update_note error compare note'); //print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n"; //$this->assertEquals($localobject->note_public, $newobject->note_public); diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index 1083eacf270..0d579b7295d 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -128,14 +128,14 @@ class ImagesLibTest extends PHPUnit_Framework_TestCase $file=dirname(__FILE__).'/img250x50.jpg'; $tmp=dol_getImageSize($file); print __METHOD__." result=".$tmp['width'].'/'.$tmp['height']."\n"; - $this->assertEquals($tmp['width'],250); - $this->assertEquals($tmp['height'],50); + $this->assertEquals($tmp['width'], 250); + $this->assertEquals($tmp['height'], 50); $file=dirname(__FILE__).'/img250x20.png'; $tmp=dol_getImageSize($file); print __METHOD__." result=".$tmp['width'].'/'.$tmp['height']."\n"; - $this->assertEquals($tmp['width'],250); - $this->assertEquals($tmp['height'],20); + $this->assertEquals($tmp['width'], 250); + $this->assertEquals($tmp['height'], 20); /*$file=dirname(__FILE__).'/filenotfound.png'; $tmp=dol_getImageSize($file); diff --git a/test/phpunit/ImportTest.php b/test/phpunit/ImportTest.php index 52be24049bc..9797905acdb 100644 --- a/test/phpunit/ImportTest.php +++ b/test/phpunit/ImportTest.php @@ -28,16 +28,16 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) /** diff --git a/test/phpunit/LangTest.php b/test/phpunit/LangTest.php index b9643e3404b..82c2b45d8c7 100644 --- a/test/phpunit/LangTest.php +++ b/test/phpunit/LangTest.php @@ -30,16 +30,16 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) if (empty($user->id)) { @@ -148,17 +148,17 @@ class LangTest extends PHPUnit_Framework_TestCase $filesarray = scandir(DOL_DOCUMENT_ROOT.'/langs'); foreach($filesarray as $key => $code) { - if (! preg_match('/^[a-z]+_[A-Z]+$/',$code)) continue; + if (! preg_match('/^[a-z]+_[A-Z]+$/', $code)) continue; print 'Check language file for lang code='.$code."\n"; - $tmplangs=new Translate('',$conf); + $tmplangs=new Translate('', $conf); $langcode=$code; $tmplangs->setDefaultLang($langcode); $tmplangs->load("main"); $result=$tmplangs->transnoentitiesnoconv("SeparatorDecimal"); print __METHOD__." SeparatorDecimal=".$result."\n"; - $this->assertContains($result,array('.',',','/',' ','','None'), 'Error for decimal separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported + $this->assertContains($result, array('.',',','/',' ','','None'), 'Error for decimal separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported $result=$tmplangs->transnoentitiesnoconv("SeparatorThousand"); print __METHOD__." SeparatorThousand=".$result."\n"; @@ -167,10 +167,10 @@ class LangTest extends PHPUnit_Framework_TestCase // Test java string contains only d,M,y,/,-,. and not m,... $result=$tmplangs->transnoentitiesnoconv("FormatDateShortJava"); print __METHOD__." FormatDateShortJava=".$result."\n"; - $this->assertRegExp('/^[dMy\/\-\.]+$/',$result,'FormatDateShortJava KO for lang code '.$code); + $this->assertRegExp('/^[dMy\/\-\.]+$/', $result, 'FormatDateShortJava KO for lang code '.$code); $result=$tmplangs->trans("FormatDateShortJavaInput"); print __METHOD__." FormatDateShortJavaInput=".$result."\n"; - $this->assertRegExp('/^[dMy\/\-\.]+$/',$result,'FormatDateShortJavaInput KO for lang code '.$code); + $this->assertRegExp('/^[dMy\/\-\.]+$/', $result, 'FormatDateShortJavaInput KO for lang code '.$code); unset($tmplangs); } diff --git a/test/phpunit/MarginsLibTest.php b/test/phpunit/MarginsLibTest.php index 5966cb65a74..f967d822f9a 100644 --- a/test/phpunit/MarginsLibTest.php +++ b/test/phpunit/MarginsLibTest.php @@ -133,19 +133,19 @@ class MarginsLibTest extends PHPUnit_Framework_TestCase $result=getMarginInfos(10, 0, 19.6, 0, 0, 0, 8); //var_dump($result); print __METHOD__." result[0]=".$result[0]."\n"; - $this->assertEquals(8,$result[0]); + $this->assertEquals(8, $result[0]); print __METHOD__." result[1]=".$result[1]."\n"; - $this->assertEquals(25,$result[1]); + $this->assertEquals(25, $result[1]); print __METHOD__." result[2]=".$result[2]."\n"; - $this->assertEquals(20,$result[2]); + $this->assertEquals(20, $result[2]); $result=getMarginInfos(10, 10, 19.6, 0, 0, 0, 8); print __METHOD__." result[0]=".$result[0]."\n"; - $this->assertEquals(8,$result[0]); + $this->assertEquals(8, $result[0]); print __METHOD__." result[1]=".$result[1]."\n"; - $this->assertEquals(12.5,$result[1]); + $this->assertEquals(12.5, $result[1]); print __METHOD__." result[2]=".$result[2]."\n"; - $this->assertEquals(1/9*100,$result[2]); + $this->assertEquals(1/9*100, $result[2]); return 0; } diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index 0d229de8aa0..16ac7cc0082 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -148,7 +148,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result=$numbering->getNextValue($mysoc, $localobject); print __METHOD__." result=".$result."\n"; $this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1 - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); print __METHOD__." result2=".$result."\n"; $result3=$localobject->validate($user, $result); // create invoice by forcing ref print __METHOD__." result3=".$result."\n"; @@ -166,7 +166,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result=$numbering->getNextValue($mysoc, $localobject2); print __METHOD__." result=".$result."\n"; $this->assertEquals('1916-0002', $result); // counter must be now 2 (not reseted) - $result2=$localobject2->create($user,1); + $result2=$localobject2->create($user, 1); print __METHOD__." result2=".$result."\n"; $result3=$localobject2->validate($user, $result); // create invoice by forcing ref print __METHOD__." result3=".$result."\n"; @@ -187,7 +187,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice'); // counter must start to 1 @@ -214,7 +214,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice'); // counter must start to 1 @@ -226,7 +226,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required) $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject2); - $result2=$localobject2->create($user,1); + $result2=$localobject2->create($user, 1); $result3=$localobject2->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('192101-0001', $result); // counter must be reseted to 1 @@ -245,7 +245,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice'); // counter must start to 1 @@ -257,7 +257,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required) $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject2); - $result2=$localobject2->create($user,1); + $result2=$localobject2->create($user, 1); $result3=$localobject2->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2st invoice'); // counter must be now 2 @@ -292,7 +292,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase print __METHOD__." result for last=".$result."\n"; $this->assertEquals('', $result); // no existing ref into reset range $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('193001-0001', $result); // counter must start to 1 @@ -308,7 +308,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase print __METHOD__." result for last=".$result."\n"; $this->assertEquals('', $result); // last ref into reset range should be '' $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('193012-0001', $result); // counter must be reset to 1 @@ -318,7 +318,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('193101-0002', $result); // counter must be 2 @@ -342,7 +342,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('194001-0001', $result); // counter must start to 1 @@ -352,7 +352,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('194012-0001', $result); // counter must be reset to 1 @@ -362,7 +362,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('194101-0002', $result); // counter must be 2 @@ -386,7 +386,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('195001-0001', $result); // counter must start to 1 @@ -396,7 +396,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('195012-0001', $result); // counter must be reset to 1 @@ -406,7 +406,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('195101-0002', $result); // counter must be 2 @@ -430,7 +430,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('195901-0001', $result); // counter must start to 1 @@ -440,7 +440,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('196012-0001', $result); // counter must be reset to 1 @@ -450,7 +450,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('196001-0002', $result); // counter must be 2 @@ -474,7 +474,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('197001-0001', $result); // counter must start to 1 @@ -484,7 +484,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('197112-0001', $result); // counter must be reset to 1 @@ -494,7 +494,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('197101-0002', $result); // counter must be 2 @@ -517,7 +517,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('198001-0001', $result); // counter must start to 1 @@ -527,7 +527,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('198001-0002', $result); // counter must start to 2 @@ -537,7 +537,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('198002-0001', $result); // counter must start to 1 @@ -547,7 +547,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('198101-0001', $result); // counter must start to 1 @@ -566,7 +566,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($tmpthirdparty, $localobject); - $result2=$localobject->create($user,1); + $result2=$localobject->create($user, 1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('A198201-0001', $result); // counter must start to 1 diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index ef6f069e6bf..a596f9c88d1 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -135,7 +135,7 @@ class PaypalTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $urltotest=getPaypalPaymentUrl(1,'free'); + $urltotest=getPaypalPaymentUrl(1, 'free'); print "urltotest=".$urltotest."\n"; $result=getURLContent($urltotest, 'GET'); diff --git a/test/phpunit/PdfDocTest.php b/test/phpunit/PdfDocTest.php index 0cf37b48762..d7f81534cde 100644 --- a/test/phpunit/PdfDocTest.php +++ b/test/phpunit/PdfDocTest.php @@ -134,7 +134,7 @@ class PdfDocTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $localproduct=new Product($this->savdb); - $localproduct->fetch(0,'PIDRESS'); + $localproduct->fetch(0, 'PIDRESS'); $product_id=$localproduct->id; if ($product_id <= 0) { print "\n".__METHOD__." A product with ref PIDRESS must exists into database"; die(); } @@ -146,13 +146,13 @@ class PdfDocTest extends PHPUnit_Framework_TestCase $localobject->lines[0]->label='Label 1'; $localobject->lines[0]->desc="This is a description with a é accent\n(Country of origin: France)"; - $result=pdf_getlinedesc($localobject,0,$langs); + $result=pdf_getlinedesc($localobject, 0, $langs); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,"PIDRESS - Label 1
    This is a description with a é accent
    (Country of origin: France)"); + $this->assertEquals($result, "PIDRESS - Label 1
    This is a description with a é accent
    (Country of origin: France)"); - $result=doc_getlinedesc($localobject->lines[0],$langs); + $result=doc_getlinedesc($localobject->lines[0], $langs); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,"PIDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)"); + $this->assertEquals($result, "PIDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)"); } /** @@ -165,10 +165,10 @@ class PdfDocTest extends PHPUnit_Framework_TestCase $file=dirname(__FILE__).'/img250x50.jpg'; $result=pdf_getHeightForLogo($file); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,22); + $this->assertEquals($result, 22); $file=dirname(__FILE__).'/img250x20.png'; $result=pdf_getHeightForLogo($file); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,10.4); + $this->assertEquals($result, 10.4); } } diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 1c7b05d462b..2fe61f4fa0f 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -156,25 +156,25 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->country_code='FR'; $mysoc->country_id=1; $result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0); - print __METHOD__." result1=".join(', ',$result1)."\n"; + print __METHOD__." result1=".join(', ', $result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0),$result1,'Test1 FR'); + $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0), $result1, 'Test1 FR'); // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value) $mysoc->country_code='FR'; $mysoc->country_id=1; $result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205); - print __METHOD__." result1=".join(', ',$result1)."\n"; + print __METHOD__." result1=".join(', ', $result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0),$result1,'Test1b FR'); + $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0), $result1, 'Test1b FR'); // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 $mysoc->country_code='FR'; $mysoc->country_id=1; $result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20); - print __METHOD__." result1=".join(', ',$result1)."\n"; + print __METHOD__." result1=".join(', ', $result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0),$result1,'Test1c FR'); + $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0), $result1, 'Test1c FR'); /* * Country Spain @@ -186,9 +186,9 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax1_assuj=0; $mysoc->localtax2_assuj=0; $result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 - print __METHOD__." result2=".join(', ',$result2)."\n"; + print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test1 ES'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test1 ES'); // 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (other method autodetect) $mysoc->country_code='ES'; @@ -196,9 +196,9 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax1_assuj=0; $mysoc->localtax2_assuj=0; $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 - print __METHOD__." result2=".join(', ',$result2)."\n"; + print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test2 ES'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test2 ES'); // -------------------------------------------------------- @@ -208,9 +208,9 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax1_assuj=1; $mysoc->localtax2_assuj=0; $result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ',$result2)."\n"; + print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0),$result2,'Test3 ES'); + $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0), $result2, 'Test3 ES'); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect) $mysoc->country_code='ES'; @@ -218,9 +218,9 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax1_assuj=1; $mysoc->localtax2_assuj=0; $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ',$result2)."\n"; + print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0),$result2,'Test4 ES'); + $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0), $result2, 'Test4 ES'); // -------------------------------------------------------- @@ -231,7 +231,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 1); // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19),$result2,'Test5 ES for service'); + $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19), $result2, 'Test5 ES for service'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a service and not a product $mysoc->country_code='ES'; @@ -239,9 +239,9 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax1_assuj=0; $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ',$result2)."\n"; + print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test6 ES for product'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test6 ES for product'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a product and not a service $mysoc->country_code='ES'; @@ -249,9 +249,9 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax1_assuj=0; $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 1); - print __METHOD__." result2=".join(', ',$result2)."\n"; + print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19),$result2,'Test6 ES for service'); + $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19), $result2, 'Test6 ES for service'); // -------------------------------------------------------- @@ -261,9 +261,9 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax1_assuj=0; $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ',$result2)."\n"; + print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0),$result2,'Test7 ES for product'); + $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0), $result2, 'Test7 ES for product'); // Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect), we provide a service and not a product $mysoc->country_code='ES'; @@ -271,8 +271,8 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax1_assuj=0; $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 1); - print __METHOD__." result2=".join(', ',$result2)."\n"; - $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19),$result2,'Test8 ES for service'); + print __METHOD__." result2=".join(', ', $result2)."\n"; + $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19), $result2, 'Test8 ES for service'); /* @@ -287,9 +287,9 @@ class PricesTest extends PHPUnit_Framework_TestCase //$localtaxes=getLocalTaxesFromRate(18, 0, null, $mysoc); //var_dump($locataxes); $result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 - print __METHOD__." result3=".join(', ',$result3)."\n"; + print __METHOD__." result3=".join(', ', $result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0),$result3,'Test9 CI'); + $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0), $result3, 'Test9 CI'); // 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect) $mysoc->country_code='CI'; @@ -297,9 +297,9 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax1_assuj=1; $mysoc->localtax2_assuj=0; $result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 - print __METHOD__." result3=".join(', ',$result3)."\n"; + print __METHOD__." result3=".join(', ', $result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0),$result3,'Test10 CI'); + $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0), $result3, 'Test10 CI'); return true; } @@ -327,15 +327,15 @@ class PricesTest extends PHPUnit_Framework_TestCase $localobject->initAsSpecimen('nolines'); $invoiceid=$localobject->create($user); - $localobject->addline('Desc',1.24,1,10,0,0,0,0,'','',0,0,0,'HT'); - $localobject->addline('Desc',1.24,1,10,0,0,0,0,'','',0,0,0,'HT'); + $localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT'); + $localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT'); $newlocalobject=new Facture($this->savdb); $newlocalobject->fetch($invoiceid); - $this->assertEquals(2.48,$newlocalobject->total_ht, "testUpdatePrice test1"); - $this->assertEquals(0.24,$newlocalobject->total_tva, "testUpdatePrice test2"); - $this->assertEquals(2.72,$newlocalobject->total_ttc, "testUpdatePrice test3"); + $this->assertEquals(2.48, $newlocalobject->total_ht, "testUpdatePrice test1"); + $this->assertEquals(0.24, $newlocalobject->total_tva, "testUpdatePrice test2"); + $this->assertEquals(2.72, $newlocalobject->total_ttc, "testUpdatePrice test3"); // Two lines of 1.24 give 2.48 HT and 2.73 TTC with global vat rounding mode @@ -343,13 +343,13 @@ class PricesTest extends PHPUnit_Framework_TestCase $localobject->initAsSpecimen('nolines'); $invoiceid=$localobject->create($user); - $localobject->addline('Desc',1.24,1,10,0,0,0,0,'','',0,0,0,'HT'); - $localobject->addline('Desc',1.24,1,10,0,0,0,0,'','',0,0,0,'HT'); + $localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT'); + $localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT'); $newlocalobject=new Facture($this->savdb); $newlocalobject->fetch($invoiceid); - $this->assertEquals(2.48,$newlocalobject->total_ht, "testUpdatePrice test4"); + $this->assertEquals(2.48, $newlocalobject->total_ht, "testUpdatePrice test4"); //$this->assertEquals(0.25,$newlocalobject->total_tva); //$this->assertEquals(2.73,$newlocalobject->total_ttc); } diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index 125982bd852..742dca85590 100644 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -186,7 +186,7 @@ class ProductTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $localobject->note='New note after update'; - $result=$localobject->update($localobject->id,$user); + $result=$localobject->update($localobject->id, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index 7b2d345a41a..153e4166b8e 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -120,7 +120,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase $result=getURLContent($url, 'GET', '', 1, array()); print __METHOD__." result = ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; - $this->assertEquals($result['curl_error_no'],''); + $this->assertEquals($result['curl_error_no'], ''); $object=json_decode($result['content'], true); $this->assertNotNull($object, "Parsing of json result must no be null"); $this->assertEquals('200', $object['success']['code']); @@ -158,7 +158,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase $result=getURLContent($url, 'GET', '', 1, array()); //print __METHOD__." Result for unexisting user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; - $this->assertEquals($result['curl_error_no'],''); + $this->assertEquals($result['curl_error_no'], ''); $object=json_decode($result['content'], true); $this->assertNotNull($object, "Parsing of json result must no be null"); $this->assertEquals(404, $object['error']['code']); @@ -169,7 +169,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase $result=getURLContent($url, 'GET', '', 1, array()); //print __METHOD__." Result for existing user user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; - $this->assertEquals($result['curl_error_no'],''); + $this->assertEquals($result['curl_error_no'], ''); $object=json_decode($result['content'], true); $this->assertNotNull($object, "Parsing of json result must no be null"); $this->assertEquals(1, $object['statut']); @@ -198,7 +198,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase $result=getURLContent($url, 'POST', $body, 1, $addheaders); //print __METHOD__." Result for creating incomplete user".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; - $this->assertEquals($result['curl_error_no'],''); + $this->assertEquals($result['curl_error_no'], ''); $object=json_decode($result['content'], true); $this->assertNotNull($object, "Parsing of json result must no be null"); $this->assertEquals(500, $object['error']['code'], $object['error']['code'].' '.$object['error']['message']); @@ -216,7 +216,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase $result=getURLContent($url, 'POST', $body, 1, $addheaders); print __METHOD__." Result code for creating user ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; - $this->assertEquals($result['curl_error_no'],''); + $this->assertEquals($result['curl_error_no'], ''); $resid=json_decode($result['content'], true); $this->assertNotNull($resid, "Parsing of json result must no be null"); $this->assertGreaterThan(0, $resid, $object['error']['code'].' '.$object['error']['message']); @@ -226,7 +226,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase $result=getURLContent($url, 'POST', $body, 1, $addheaders); //print __METHOD__." Result for creating duplicate user".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; - $this->assertEquals($result['curl_error_no'],''); + $this->assertEquals($result['curl_error_no'], ''); $object=json_decode($result['content'], true); $this->assertNotNull($object, "Parsing of json result must no be null"); $this->assertEquals(500, $object['error']['code'], $object['error']['code'].' '.$object['error']['message']); diff --git a/test/phpunit/ScriptsTest.php b/test/phpunit/ScriptsTest.php index 0c49567a4a4..d7011d23e06 100644 --- a/test/phpunit/ScriptsTest.php +++ b/test/phpunit/ScriptsTest.php @@ -30,16 +30,16 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) if (empty($user->id)) { @@ -147,10 +147,10 @@ class ScriptsTest extends PHPUnit_Framework_TestCase $result=exec($script, $output, $returnvar); print __METHOD__." result=".$result."\n"; - print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." output=".join("\n", $output)."\n"; print __METHOD__." returnvar=".$returnvar."\n"; - $this->assertEquals($result,'Failed to find bank account with ref BANKDUMMY.'); - $this->assertEquals($returnvar,255); + $this->assertEquals($result, 'Failed to find bank account with ref BANKDUMMY.'); + $this->assertEquals($returnvar, 255); return $result; } @@ -199,23 +199,23 @@ class ScriptsTest extends PHPUnit_Framework_TestCase $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test thirdparties'; $result=exec($script, $output, $returnvar); print __METHOD__." result=".$result."\n"; - print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." output=".join("\n", $output)."\n"; print __METHOD__." returnvar=".$returnvar."\n"; - $this->assertEquals($returnvar,0,'email_expire_services_to_customers.php thirdparties'); + $this->assertEquals($returnvar, 0, 'email_expire_services_to_customers.php thirdparties'); $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test contacts -30'; $result=exec($script, $output, $returnvar); print __METHOD__." result=".$result."\n"; - print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." output=".join("\n", $output)."\n"; print __METHOD__." returnvar=".$returnvar."\n"; - $this->assertEquals($returnvar,0,'email_expire_services_to_customers.php contacts'); + $this->assertEquals($returnvar, 0, 'email_expire_services_to_customers.php contacts'); $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_representatives.php test -30'; $result=exec($script, $output, $returnvar); print __METHOD__." result=".$result."\n"; - print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." output=".join("\n", $output)."\n"; print __METHOD__." returnvar=".$returnvar."\n"; - $this->assertEquals($returnvar,0,'email_expire_services_to_representatives.php'); + $this->assertEquals($returnvar, 0, 'email_expire_services_to_representatives.php'); return $result; } @@ -237,23 +237,23 @@ class ScriptsTest extends PHPUnit_Framework_TestCase $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties'; $result=exec($script, $output, $returnvar); print __METHOD__." result=".$result."\n"; - print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." output=".join("\n", $output)."\n"; print __METHOD__." returnvar=".$returnvar."\n"; - $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties'); + $this->assertEquals($returnvar, 0, 'email_unpaid_invoices_to_customers.php thirdparties'); $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test contacts -30'; $result=exec($script, $output, $returnvar); print __METHOD__." result=".$result."\n"; - print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." output=".join("\n", $output)."\n"; print __METHOD__." returnvar=".$returnvar."\n"; - $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php contacts'); + $this->assertEquals($returnvar, 0, 'email_unpaid_invoices_to_customers.php contacts'); $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_representatives.php test thirdparties'; $result=exec($script, $output, $returnvar); print __METHOD__." result=".$result."\n"; - print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." output=".join("\n", $output)."\n"; print __METHOD__." returnvar=".$returnvar."\n"; - $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties'); + $this->assertEquals($returnvar, 0, 'email_unpaid_invoices_to_customers.php thirdparties'); return $result; } diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index f77189d4434..263dc831ade 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -30,16 +30,16 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) if (empty($user->id)) { @@ -152,51 +152,51 @@ class SecurityTest extends PHPUnit_Framework_TestCase $_GET["param5"]="a_1-b"; // Test int - $result=GETPOST('id','int'); // Must return nothing + $result=GETPOST('id', 'int'); // Must return nothing print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,''); + $this->assertEquals($result, ''); - $result=GETPOST("param1",'int'); + $result=GETPOST("param1", 'int'); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,222); + $this->assertEquals($result, 222); - $result=GETPOST("param1",'int',2); + $result=GETPOST("param1", 'int', 2); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,333); + $this->assertEquals($result, 333); // Test alpha - $result=GETPOST("param2",'alpha'); + $result=GETPOST("param2", 'alpha'); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,$_GET["param2"]); + $this->assertEquals($result, $_GET["param2"]); - $result=GETPOST("param3",'alpha'); // Must return '' as there is a forbidden char " + $result=GETPOST("param3", 'alpha'); // Must return '' as there is a forbidden char " print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,''); + $this->assertEquals($result, ''); - $result=GETPOST("param4",'alpha'); // Must return '' as there is a forbidden char ../ + $result=GETPOST("param4", 'alpha'); // Must return '' as there is a forbidden char ../ print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,''); + $this->assertEquals($result, ''); // Test aZ09 - $result=GETPOST("param1",'aZ09'); // Must return '' as there is a forbidden char ../ + $result=GETPOST("param1", 'aZ09'); // Must return '' as there is a forbidden char ../ print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,$_GET["param1"]); + $this->assertEquals($result, $_GET["param1"]); - $result=GETPOST("param2",'aZ09'); // Must return '' as there is a forbidden char ../ + $result=GETPOST("param2", 'aZ09'); // Must return '' as there is a forbidden char ../ print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,''); + $this->assertEquals($result, ''); - $result=GETPOST("param3",'aZ09'); // Must return '' as there is a forbidden char ../ + $result=GETPOST("param3", 'aZ09'); // Must return '' as there is a forbidden char ../ print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,''); + $this->assertEquals($result, ''); - $result=GETPOST("param4",'aZ09'); // Must return '' as there is a forbidden char ../ + $result=GETPOST("param4", 'aZ09'); // Must return '' as there is a forbidden char ../ print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,''); + $this->assertEquals($result, ''); - $result=GETPOST("param5",'aZ09'); + $result=GETPOST("param5", 'aZ09'); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result,$_GET["param5"]); + $this->assertEquals($result, $_GET["param5"]); return $result; } @@ -208,25 +208,25 @@ class SecurityTest extends PHPUnit_Framework_TestCase */ public function testCheckLoginPassEntity() { - $login=checkLoginPassEntity('loginbidon','passwordbidon',1,array('dolibarr')); + $login=checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr')); print __METHOD__." login=".$login."\n"; - $this->assertEquals($login,''); + $this->assertEquals($login, ''); - $login=checkLoginPassEntity('admin','passwordbidon',1,array('dolibarr')); + $login=checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr')); print __METHOD__." login=".$login."\n"; - $this->assertEquals($login,''); + $this->assertEquals($login, ''); - $login=checkLoginPassEntity('admin','admin',1,array('dolibarr')); // Should works because admin/admin exists + $login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists print __METHOD__." login=".$login."\n"; - $this->assertEquals($login,'admin'); + $this->assertEquals($login, 'admin'); - $login=checkLoginPassEntity('admin','admin',1,array('http','dolibarr')); // Should work because of second authetntication method + $login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authetntication method print __METHOD__." login=".$login."\n"; - $this->assertEquals($login,'admin'); + $this->assertEquals($login, 'admin'); - $login=checkLoginPassEntity('admin','admin',1,array('forceuser')); + $login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); print __METHOD__." login=".$login."\n"; - $this->assertEquals($login,''); // Expected '' because should failed because login 'auto' does not exists + $this->assertEquals($login, ''); // Expected '' because should failed because login 'auto' does not exists } /** @@ -241,12 +241,12 @@ class SecurityTest extends PHPUnit_Framework_TestCase $encodedstring=dol_encode($stringtotest); $decodedstring=dol_decode($encodedstring); print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n"; - $this->assertEquals($stringtotest,$decodedstring, 'Use dol_encode/decode with no parameter'); + $this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with no parameter'); $encodedstring=dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); $decodedstring=dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n"; - $this->assertEquals($stringtotest,$decodedstring, 'Use dol_encode/decode with a key parameter'); + $this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with a key parameter'); return 0; } @@ -297,7 +297,7 @@ class SecurityTest extends PHPUnit_Framework_TestCase //$dummyuser=new User($db); //$result=restrictedArea($dummyuser,'societe'); - $result=restrictedArea($user,'societe'); - $this->assertEquals(1,$result); + $result=restrictedArea($user, 'societe'); + $this->assertEquals(1, $result); } } diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index 3e9ee3c2002..c102d3467e1 100755 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -209,11 +209,11 @@ class SocieteTest extends PHPUnit_Framework_TestCase $localobject->idprof3='new idprof3'; $localobject->idprof4='new idprof4'; - $result=$localobject->update($localobject->id,$user); + $result=$localobject->update($localobject->id, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - $result=$localobject->update_note($localobject->note_private,'_private'); + $result=$localobject->update_note($localobject->note_private, '_private'); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0, 'Holiday::update_note (private) error'); @@ -262,10 +262,10 @@ class SocieteTest extends PHPUnit_Framework_TestCase $localobject->country_code='FR'; $localobject->idprof1=493861496; $localobject->idprof2=49386149600021; - $result=$localobject->id_prof_check(1,$localobject); // Must be > 0 + $result=$localobject->id_prof_check(1, $localobject); // Must be > 0 print __METHOD__." OK FR idprof1 result=".$result."\n"; $this->assertGreaterThanOrEqual(1, $result); - $result=$localobject->id_prof_check(2,$localobject); // Must be > 0 + $result=$localobject->id_prof_check(2, $localobject); // Must be > 0 print __METHOD__." OK FR idprof2 result=".$result."\n"; $this->assertGreaterThanOrEqual(1, $result); @@ -273,17 +273,17 @@ class SocieteTest extends PHPUnit_Framework_TestCase $localobject->country_code='FR'; $localobject->idprof1='id1ko'; $localobject->idprof2='id2ko'; - $result=$localobject->id_prof_check(1,$localobject); // Must be <= 0 + $result=$localobject->id_prof_check(1, $localobject); // Must be <= 0 print __METHOD__." KO FR idprof1 result=".$result."\n"; $this->assertLessThan(1, $result); - $result=$localobject->id_prof_check(2,$localobject); // Must be <= 0 + $result=$localobject->id_prof_check(2, $localobject); // Must be <= 0 print __METHOD__." KO FR idprof2 result=".$result."\n"; $this->assertLessThan(1, $result); // KO ES $localobject->country_code='ES'; $localobject->idprof1='id1ko'; - $result=$localobject->id_prof_check(1,$localobject); // Must be <= 0 + $result=$localobject->id_prof_check(1, $localobject); // Must be <= 0 print __METHOD__." KO ES idprof1 result=".$result."\n"; $this->assertLessThan(1, $result); @@ -291,10 +291,10 @@ class SocieteTest extends PHPUnit_Framework_TestCase $localobject->country_code='AR'; $localobject->idprof1='id1ko'; $localobject->idprof2='id2ko'; - $result=$localobject->id_prof_check(1,$localobject); // Must be > 0 + $result=$localobject->id_prof_check(1, $localobject); // Must be > 0 print __METHOD__." OK AR idprof1 result=".$result."\n"; $this->assertGreaterThanOrEqual(0, $result); - $result=$localobject->id_prof_check(2,$localobject); // Must be > 0 + $result=$localobject->id_prof_check(2, $localobject); // Must be > 0 print __METHOD__." OK AR idprof2 result=".$result."\n"; $this->assertGreaterThanOrEqual(1, $result); @@ -323,11 +323,11 @@ class SocieteTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - $result=$localobject->set_price_level(1,$user); + $result=$localobject->set_price_level(1, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - $result=$localobject->set_remise_client(10,'Gift',$user); + $result=$localobject->set_remise_client(10, 'Gift', $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); diff --git a/test/phpunit/UserGroupTest.php b/test/phpunit/UserGroupTest.php index 4b3b0244ec7..ba78fdfd8db 100644 --- a/test/phpunit/UserGroupTest.php +++ b/test/phpunit/UserGroupTest.php @@ -203,7 +203,7 @@ class UserGroupTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $result=$localobject->addrights(1,'bookmarks'); + $result=$localobject->addrights(1, 'bookmarks'); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); @@ -226,7 +226,7 @@ class UserGroupTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $result=$localobject->delrights(1,'bookmarks'); + $result=$localobject->delrights(1, 'bookmarks'); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index 9b8e5217183..b6994863347 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -192,7 +192,7 @@ class UserTest extends PHPUnit_Framework_TestCase $newlocalobject=new User($this->savdb); $newlocalobject->initAsSpecimen(); $this->changeProperties($newlocalobject); - $this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('id','socid','societe_id','ref','pass','pass_indatabase','pass_indatabase_crypted','datec','datem','datelastlogin','datepreviouslogin')), array()); // Actual, Expected + $this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id','socid','societe_id','ref','pass','pass_indatabase','pass_indatabase_crypted','datec','datem','datelastlogin','datepreviouslogin')), array()); // Actual, Expected return $localobject; } @@ -332,7 +332,7 @@ class UserTest extends PHPUnit_Framework_TestCase $oVarsB=get_object_vars($oB); $aKeys=array_keys($oVarsA); foreach($aKeys as $sKey) { - if (in_array($sKey,$fieldstoignorearray)) + if (in_array($sKey, $fieldstoignorearray)) continue; if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) { $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index 92a336c846e..e916e3d5a89 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -248,7 +248,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication,'invoice'=>$body); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); + $result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, ''); } catch(SoapFault $exception) { @@ -267,7 +267,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result['result']['result_code']."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); $this->assertEquals('ref-phpunit-2', $result['ref_ext']); @@ -306,7 +306,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication, 'id'=>null, 'ref'=>null, 'ref_ext'=>'ref-phpunit-2'); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); + $result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, ''); } catch(SoapFault $exception) { @@ -323,7 +323,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase print "\n"; } print __METHOD__." result=".$result['result']['result_code']."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); $this->assertEquals('ref-phpunit-2', $result['invoice']['ref_ext']); @@ -406,7 +406,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication,'invoice'=>$body); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); + $result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, ''); } catch(SoapFault $exception) { @@ -424,7 +424,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result['result']['result_code'].$result['result']['result_label']."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); $this->assertEquals('ref-phpunit-2', $result['ref_ext']); diff --git a/test/phpunit/WebservicesOrdersTest.php b/test/phpunit/WebservicesOrdersTest.php index a155e5de973..2dc22eb2027 100644 --- a/test/phpunit/WebservicesOrdersTest.php +++ b/test/phpunit/WebservicesOrdersTest.php @@ -160,7 +160,7 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication,'id'=>1); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; @@ -176,7 +176,7 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); return $result; } diff --git a/test/phpunit/WebservicesOtherTest.php b/test/phpunit/WebservicesOtherTest.php index 16b1cd7d531..af329bd9de5 100644 --- a/test/phpunit/WebservicesOtherTest.php +++ b/test/phpunit/WebservicesOtherTest.php @@ -161,7 +161,7 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; @@ -181,7 +181,7 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); // Test method that does not exists $WS_METHOD='methodthatdoesnotexists'; @@ -189,7 +189,7 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; diff --git a/test/phpunit/WebservicesProductsTest.php b/test/phpunit/WebservicesProductsTest.php index 60c90ea30d4..1e80fd8f433 100644 --- a/test/phpunit/WebservicesProductsTest.php +++ b/test/phpunit/WebservicesProductsTest.php @@ -141,7 +141,7 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $datestring=dol_print_date(dol_now(),'dayhourlog'); + $datestring=dol_print_date(dol_now(), 'dayhourlog'); $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; $WS_METHOD = 'createProductOrService'; @@ -178,7 +178,7 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase ); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; @@ -194,7 +194,7 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); return $result['id']; } @@ -241,7 +241,7 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication,'id'=>$id,'ref'=>''); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; @@ -257,7 +257,7 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); return $id; } @@ -304,7 +304,7 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication,'listofid'=>$id); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; @@ -320,7 +320,7 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); return 0; } diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index 51be1a5dbf6..56425198e09 100644 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -205,7 +205,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication, 'thirdparty'=>$body); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); + $result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; @@ -221,8 +221,8 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result['result']['result_code']."\n"; - $this->assertEquals('OK',$result['result']['result_code']); - $this->assertEquals('name',$result['ref']); + $this->assertEquals('OK', $result['result']['result_code']); + $this->assertEquals('name', $result['ref']); return $result; } @@ -259,7 +259,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication, 'id'=>$id); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->_ns,''); + $result = $this->soapclient->call($WS_METHOD, $parameters, $this->_ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; @@ -275,7 +275,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result['result']['result_code']."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); $this->assertEquals($id, $result['thirdparty']['id']); $this->assertEquals('name', $result['thirdparty']['ref']); $this->assertEquals('12', $result['thirdparty']['ref_ext']); @@ -321,7 +321,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication, 'id'=>'', 'ref'=>'', 'ref_ext'=>'12'); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->_ns,''); + $result = $this->soapclient->call($WS_METHOD, $parameters, $this->_ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; @@ -338,7 +338,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result['result']['result_code']."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); $this->assertEquals($id, $result['thirdparty']['id']); $this->assertEquals('name', $result['thirdparty']['ref']); $this->assertEquals('12', $result['thirdparty']['ref_ext']); @@ -381,7 +381,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'', 'ref_ext'=>''); print __METHOD__." call method ".$WS_METHOD."\n"; try { - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->_ns,''); + $result = $this->soapclient->call($WS_METHOD, $parameters, $this->_ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; @@ -396,7 +396,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result['result']['result_code']."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + $this->assertEquals('OK', $result['result']['result_code']); return $result; } diff --git a/test/phpunit/WebservicesUserTest.php b/test/phpunit/WebservicesUserTest.php index 3c97ee719a9..32a96434ac8 100644 --- a/test/phpunit/WebservicesUserTest.php +++ b/test/phpunit/WebservicesUserTest.php @@ -161,7 +161,7 @@ class WebservicesUserTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'admin'); print __METHOD__."Call method ".$WS_METHOD."\n"; try { - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; @@ -188,7 +188,7 @@ class WebservicesUserTest extends PHPUnit_Framework_TestCase $parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'refthatdoesnotexists'); print __METHOD__."Call method ".$WS_METHOD."\n"; try { - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); } catch(SoapFault $exception) { echo $exception; $result=0; diff --git a/test/phpunit/XCalLibTest.php b/test/phpunit/XCalLibTest.php index 165b8d247b2..bcc9ce0128c 100644 --- a/test/phpunit/XCalLibTest.php +++ b/test/phpunit/XCalLibTest.php @@ -133,10 +133,10 @@ class XCalLibTest extends PHPUnit_Framework_TestCase $stringtoencode='ABCD=1234;'; $result=quotedPrintEncode($stringtoencode); print __METHOD__." result=".$result."\n"; - $this->assertEquals('ABCD=3D1234;',$result); + $this->assertEquals('ABCD=3D1234;', $result); $resultback=quotedPrintDecode($result); print __METHOD__." result=".$resultback."\n"; - $this->assertEquals($stringtoencode,$resultback); + $this->assertEquals($stringtoencode, $resultback); } }