From bb09bcece4b5b877cca6f2d82af4541e74eeb059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 16 Aug 2018 16:03:56 +0200 Subject: [PATCH 01/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3eb0941568a55..b93de1c4de2b7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DOLIBARR ERP & CRM -![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) +![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg?branch=4.0) ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda, ...). From 2aa0956f15ffde4ca09f4ae0c693dc23379c8d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 16 Aug 2018 16:08:04 +0200 Subject: [PATCH 02/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b93de1c4de2b7..e89f2d46daabb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DOLIBARR ERP & CRM -![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg?branch=4.0) ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) +![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/4.0.svg) ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda, ...). From 102b698c76c49bf7222fd69d9378671346389d52 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Fri, 31 Aug 2018 11:38:45 +0200 Subject: [PATCH 03/11] Fix search company by code --- htdocs/core/class/html.form.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bd7feb9414d1b..50f8d1f96793d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1103,7 +1103,8 @@ function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showe if (! empty($conf->barcode->enabled)) { $sql .= " OR s.barcode LIKE '".$this->db->escape($filterkey)."%'"; - } + } + $sql.= " OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey)."%' OR s.code_fournisseur LIKE '".$this->db->escape($prefix.$filterkey)."%'"; $sql.=")"; } $sql.=$this->db->order("nom","ASC"); From 945e92539929f5129d9f38b74b54056d2d5ea956 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 1 Sep 2018 14:41:44 +0200 Subject: [PATCH 04/11] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 50f8d1f96793d..3eb96cf7e6ff5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1102,9 +1102,9 @@ function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showe if (count($scrit) > 1) $sql.=")"; if (! empty($conf->barcode->enabled)) { - $sql .= " OR s.barcode LIKE '".$this->db->escape($filterkey)."%'"; - } - $sql.= " OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey)."%' OR s.code_fournisseur LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + $sql .= " OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + } + $sql.= " OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey)."%' OR s.code_fournisseur LIKE '".$this->db->escape($prefix.$filterkey)."%'"; $sql.=")"; } $sql.=$this->db->order("nom","ASC"); From 53caac13a962a7b2b32615e9b0eda6b8e0afec9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Sep 2018 13:57:51 +0200 Subject: [PATCH 05/11] Test phpunit --- test/phpunit/AdherentTest.php | 4 +++- test/phpunit/AdminLibTest.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index 34ec0a8091730..864f9b757fb5f 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -61,7 +61,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/AdminLibTest.php b/test/phpunit/AdminLibTest.php index 5cf34e969b1e0..cc83eefe84ec0 100644 --- a/test/phpunit/AdminLibTest.php +++ b/test/phpunit/AdminLibTest.php @@ -59,7 +59,9 @@ class AdminLibTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; From a69c3caf2c6a5a579312abf21a9ce922f1a5d017 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Sep 2018 14:10:06 +0200 Subject: [PATCH 06/11] Prepare compatibility with phpunit 6.1 --- test/phpunit/AdherentTest.php | 6 +- test/phpunit/AdminLibTest.php | 12 ++-- test/phpunit/BankAccountTest.php | 4 +- test/phpunit/BonPrelevementTest.php | 2 + test/phpunit/BuildDocTest.php | 4 +- test/phpunit/CMailFileTest.php | 6 +- test/phpunit/CategorieTest.php | 4 +- test/phpunit/ChargeSocialesTest.php | 20 ++++--- test/phpunit/CommandeFournisseurTest.php | 4 +- test/phpunit/CommandeTest.php | 4 +- test/phpunit/CommonObjectTest.php | 4 +- test/phpunit/CompanyBankAccountTest.php | 2 + test/phpunit/ContactTest.php | 4 +- test/phpunit/ContratTest.php | 2 + test/phpunit/CoreTest.php | 12 ++-- test/phpunit/DateLibTest.php | 32 ++++++----- test/phpunit/DateLibTzFranceTest.php | 2 + test/phpunit/DiscountTest.php | 2 + test/phpunit/EntrepotTest.php | 2 + test/phpunit/ExportTest.php | 2 + test/phpunit/FactureFournisseurTest.php | 2 + test/phpunit/FactureRecTest.php | 2 + test/phpunit/FactureTest.php | 4 +- test/phpunit/FactureTestRounding.php | 2 + test/phpunit/FichinterTest.php | 2 + test/phpunit/FilesLibTest.php | 6 +- test/phpunit/FormAdminTest.php | 2 + test/phpunit/Functions2LibTest.php | 4 +- test/phpunit/FunctionsLibTest.php | 16 +++--- test/phpunit/HolidayTest.php | 8 ++- test/phpunit/ImagesLibTest.php | 2 + test/phpunit/ImportTest.php | 2 + test/phpunit/JsonLibTest.php | 10 ++-- test/phpunit/LangTest.php | 2 + test/phpunit/MarginsLibTest.php | 6 +- test/phpunit/ModulesTest.php | 2 + test/phpunit/MouvementStockTest.php | 2 + test/phpunit/NumberingModulesTest.php | 6 +- test/phpunit/PaypalTest.php | 6 +- test/phpunit/PdfDocTest.php | 2 + test/phpunit/PgsqlTest.php | 6 +- test/phpunit/PricesTest.php | 8 ++- test/phpunit/ProductTest.php | 4 +- test/phpunit/ProjectTest.php | 2 + test/phpunit/PropalTest.php | 2 + test/phpunit/RestAPIUserTest.php | 22 ++++---- test/phpunit/ScriptsTest.php | 2 + test/phpunit/SecurityTest.php | 2 + test/phpunit/SocieteTest.php | 4 +- test/phpunit/SqlTest.php | 18 +++--- test/phpunit/UserGroupTest.php | 18 +++--- test/phpunit/UserTest.php | 4 +- test/phpunit/WebservicesInvoicesTest.php | 36 ++++++------ test/phpunit/WebservicesOrdersTest.php | 4 +- test/phpunit/WebservicesOtherTest.php | 4 +- test/phpunit/WebservicesProductsTest.php | 4 +- test/phpunit/WebservicesThirdpartyTest.php | 66 +++++++++++----------- test/phpunit/WebservicesUserTest.php | 4 +- test/phpunit/XCalLibTest.php | 4 +- 59 files changed, 275 insertions(+), 157 deletions(-) diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index 42b4ff7cf7fd5..316f74a7cc0a3 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -61,7 +61,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -79,7 +81,7 @@ public static function setUpBeforeClass() global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - if (! empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { + if (! empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { print "\n".__METHOD__." Company must be setup to have name-firstname in order 'Firstname Lastname'\n"; die(); } diff --git a/test/phpunit/AdminLibTest.php b/test/phpunit/AdminLibTest.php index d7f3d17a583df..937ede95f3b27 100644 --- a/test/phpunit/AdminLibTest.php +++ b/test/phpunit/AdminLibTest.php @@ -59,7 +59,9 @@ class AdminLibTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -142,21 +144,21 @@ public function testVersionCompare() return $result; } - + /** * testEnableModule - * + * * @return void */ public function testEnableModule() { global $conf, $db, $langs, $user; - + require_once dirname(__FILE__).'/../../htdocs/core/modules/modExpenseReport.class.php'; print "Enable module modExpenseReport"; $moduledescriptor=new modExpenseReport($db); $moduledescriptor->init(); $conf->setValues($db); } - + } diff --git a/test/phpunit/BankAccountTest.php b/test/phpunit/BankAccountTest.php index a212ff0317a08..f6c135158d5df 100644 --- a/test/phpunit/BankAccountTest.php +++ b/test/phpunit/BankAccountTest.php @@ -61,7 +61,9 @@ class BankAccountTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/BonPrelevementTest.php b/test/phpunit/BonPrelevementTest.php index 0124b25e6c66c..de0c3be3416be 100644 --- a/test/phpunit/BonPrelevementTest.php +++ b/test/phpunit/BonPrelevementTest.php @@ -62,6 +62,8 @@ class BonPrelevementTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index 25b7bd15c03ed..1c8ac48c8680e 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -89,7 +89,9 @@ class BuildDocTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index 092d2e1f41c8e..ddc696761706c 100755 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -59,7 +59,9 @@ class CMailFileTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -103,7 +105,7 @@ protected function setUp() $db=$this->savdb; $conf->global->MAIN_DISABLE_ALL_MAILS=1; // If I comment/remove this lien, unit test still works alone but failed when ran from AllTest. Don't know why. - + print __METHOD__."\n"; } /** diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index 574a8d793f94b..394267d40e1cf 100644 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -60,7 +60,9 @@ class CategorieTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/ChargeSocialesTest.php b/test/phpunit/ChargeSocialesTest.php index 0836036afa596..8f06564eb1cbb 100644 --- a/test/phpunit/ChargeSocialesTest.php +++ b/test/phpunit/ChargeSocialesTest.php @@ -60,6 +60,8 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; @@ -117,7 +119,7 @@ protected function tearDown() /** * testChargeSocialesCreate - * + * * @return void */ public function testChargeSocialesCreate() @@ -139,10 +141,10 @@ public function testChargeSocialesCreate() /** * testChargeSocialesFetch - * + * * @param int $id Id of social contribution * @return void - * + * * @depends testChargeSocialesCreate * The depends says test is run only if previous is ok */ @@ -164,10 +166,10 @@ public function testChargeSocialesFetch($id) /** * testChargeSocialesValid - * + * * @param Object $localobject Social contribution * @return void - * + * * @depends testChargeSocialesFetch * The depends says test is run only if previous is ok */ @@ -188,10 +190,10 @@ public function testChargeSocialesValid($localobject) /** * testChargeSocialesOther - * + * * @param Object $localobject Social contribution * @return void - * + * * @depends testChargeSocialesValid * The depends says test is run only if previous is ok */ @@ -216,10 +218,10 @@ public function testChargeSocialesOther($localobject) /** * testChargeSocialesDelete - * + * * @param int $id Social contribution * @return void - * + * * @depends testChargeSocialesOther * The depends says test is run only if previous is ok */ diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index 03880a56eca8e..61dcce7f06c15 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -61,7 +61,9 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index aaba882cc8716..73d0977d7fd69 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -59,7 +59,9 @@ class CommandeTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/CommonObjectTest.php b/test/phpunit/CommonObjectTest.php index 18f96034fd10d..09200a15b9167 100644 --- a/test/phpunit/CommonObjectTest.php +++ b/test/phpunit/CommonObjectTest.php @@ -60,7 +60,9 @@ class CommonObjectTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/CompanyBankAccountTest.php b/test/phpunit/CompanyBankAccountTest.php index 95ea937a01743..5c72dca72a0ef 100644 --- a/test/phpunit/CompanyBankAccountTest.php +++ b/test/phpunit/CompanyBankAccountTest.php @@ -60,6 +60,8 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index cb0f37875b38b..b943020efea85 100755 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -68,6 +68,8 @@ class ContactTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; @@ -207,7 +209,7 @@ public function testContactUpdate($localobject) $localobject->email='newemail@newemail.com'; $localobject->jabberid='New im id'; $localobject->default_lang='es_ES'; - + $result=$localobject->update($localobject->id,$user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0, 'Contact::update error'); diff --git a/test/phpunit/ContratTest.php b/test/phpunit/ContratTest.php index 5adf002c885eb..7e7dfb64922fd 100644 --- a/test/phpunit/ContratTest.php +++ b/test/phpunit/ContratTest.php @@ -60,6 +60,8 @@ class ContratTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php index 3a158260e96e3..43f74c840fe3d 100644 --- a/test/phpunit/CoreTest.php +++ b/test/phpunit/CoreTest.php @@ -62,7 +62,9 @@ class CoreTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -290,22 +292,22 @@ function test_sql_and_script_inject($val, $type) } // Run tests - + $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices'; $result=test_sql_and_script_inject($_SERVER["PHP_SELF"], 2); $expectedresult=0; $this->assertEquals($expectedresult, $result, 'Error on test_sql_and_script_inject 1a'); - + $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices;badaction'; $result=test_sql_and_script_inject($_SERVER["PHP_SELF"], 2); $expectedresult=1; $this->assertEquals($expectedresult, $result, 'Error on test_sql_and_script_inject 1b'); - + $_GET['aaa']=""; $result=test_sql_and_script_inject($_GET['aaa'], 0); $expectedresult=1; $this->assertEquals($expectedresult, $result, 'Error on test_sql_and_script_inject 2'); - + $_POST['bbb']=""; $result=test_sql_and_script_inject($_POST['bbb'], 2); $expectedresult=1; diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 02d85164d79b2..734465d0853fb 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -60,6 +60,8 @@ class DateLibTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; @@ -179,32 +181,32 @@ public function testNumPublicHoliday() $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + // With same hours - Tuesday/Wednesday jan 2013 $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); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumPublicHoliday for Tuesday/Wednesday jan 2013 for FR'); // 1 closed days - + $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) - + // 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); 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); print __METHOD__." result=".$result."\n"; $this->assertEquals(2,$result,'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown) } - + /** * testNumOpenDay * @@ -217,32 +219,32 @@ public function testNumOpenDay() $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + // With same hours - Tuesday/Wednesday jan 2013 $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'); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumOpenDay Tuesday/Wednesday jan 2013 for FR'); // 1 opened days - + $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) - + // 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'); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumOpenDay for FR'); // 1 opened day, 2 closed - + $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) } - + /** * testConvertTime2Seconds * diff --git a/test/phpunit/DateLibTzFranceTest.php b/test/phpunit/DateLibTzFranceTest.php index 668af0002042f..b41688c153fcf 100644 --- a/test/phpunit/DateLibTzFranceTest.php +++ b/test/phpunit/DateLibTzFranceTest.php @@ -60,6 +60,8 @@ class DateLibTzFranceTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/DiscountTest.php b/test/phpunit/DiscountTest.php index cf4d5033597f8..724a97e6f3eac 100644 --- a/test/phpunit/DiscountTest.php +++ b/test/phpunit/DiscountTest.php @@ -60,6 +60,8 @@ class DiscountTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index d3d7c300308d7..6f27685faa713 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -60,6 +60,8 @@ class EntrepotTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index 7c14b0ccd64f9..af1c1e95a26b0 100644 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -64,6 +64,8 @@ class ExportTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/FactureFournisseurTest.php b/test/phpunit/FactureFournisseurTest.php index 199d397f50d2b..b91092f294ee2 100644 --- a/test/phpunit/FactureFournisseurTest.php +++ b/test/phpunit/FactureFournisseurTest.php @@ -60,6 +60,8 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/FactureRecTest.php b/test/phpunit/FactureRecTest.php index f7f857fe3170f..07d728eb0ecc1 100644 --- a/test/phpunit/FactureRecTest.php +++ b/test/phpunit/FactureRecTest.php @@ -61,6 +61,8 @@ class FactureRecTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index 142a528498919..678992ed77cb8 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -59,7 +59,9 @@ class FactureTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/FactureTestRounding.php b/test/phpunit/FactureTestRounding.php index 5fe0df4e5d09f..4ed76d900bf53 100644 --- a/test/phpunit/FactureTestRounding.php +++ b/test/phpunit/FactureTestRounding.php @@ -60,6 +60,8 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/FichinterTest.php b/test/phpunit/FichinterTest.php index baa72b7020aa5..4d6e122449879 100644 --- a/test/phpunit/FichinterTest.php +++ b/test/phpunit/FichinterTest.php @@ -60,6 +60,8 @@ class FichinterTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index f9000006b46c9..8e4cc4b009beb 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -61,6 +61,8 @@ class FilesLibTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; @@ -399,7 +401,7 @@ public function testDolCompressUnCompress() print __METHOD__." result=".join(',',$result)."\n"; $this->assertEquals(0,count($result)); } - + /** * testDolDirList * @@ -411,7 +413,7 @@ public function testDolCompressUnCompress() public function testDolDirList() { global $conf,$user,$langs,$db; - + // 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"; diff --git a/test/phpunit/FormAdminTest.php b/test/phpunit/FormAdminTest.php index 30c9660021099..876e733b56ddb 100644 --- a/test/phpunit/FormAdminTest.php +++ b/test/phpunit/FormAdminTest.php @@ -60,6 +60,8 @@ class FormAdminTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php index 470a570bf6efd..87b2eaefe58d9 100644 --- a/test/phpunit/Functions2LibTest.php +++ b/test/phpunit/Functions2LibTest.php @@ -63,7 +63,9 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index ca06655c84514..4da3beb48eec5 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -63,7 +63,9 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -130,21 +132,21 @@ public function testDolBuildPath() /*$tmp=dol_buildpath('/google/oauth2callback.php', 0); var_dump($tmp); */ - + /*$tmp=dol_buildpath('/google/oauth2callback.php', 1); var_dump($tmp); */ - + $result=dol_buildpath('/google/oauth2callback.php', 2); print __METHOD__." result=".$result."\n"; $this->assertStringStartsWith('http', $result); - + $result=dol_buildpath('/google/oauth2callback.php', 3); print __METHOD__." result=".$result."\n"; $this->assertStringStartsWith('http', $result); } - - + + /** * testGetBrowserInfo * @@ -999,5 +1001,5 @@ public function testDolGetDate() return true; } - + } diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index a04646a8a1420..1239cff2f92ec 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -62,6 +62,8 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; @@ -201,11 +203,11 @@ public function testHolidayUpdate($localobject) $localobject->email='newemail@newemail.com'; $localobject->jabberid='New im id'; $localobject->default_lang='es_ES'; - + $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'); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0, 'Holiday::update_note (private) error'); @@ -213,7 +215,7 @@ public function testHolidayUpdate($localobject) $result=$localobject->update_note($localobject->note_public, '_public'); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0, 'Holiday::update_note (public) error'); - + $newobject=new Holiday($this->savdb); $result=$newobject->fetch($localobject->id); diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index 41c7005e25d7d..cc4e6bd7462ae 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -61,6 +61,8 @@ class ImagesLibTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/ImportTest.php b/test/phpunit/ImportTest.php index 067b06910c947..0e80b6384e87f 100644 --- a/test/phpunit/ImportTest.php +++ b/test/phpunit/ImportTest.php @@ -62,6 +62,8 @@ class ImportTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/JsonLibTest.php b/test/phpunit/JsonLibTest.php index 66999e31c65b2..cd63ed2f221a9 100644 --- a/test/phpunit/JsonLibTest.php +++ b/test/phpunit/JsonLibTest.php @@ -62,7 +62,9 @@ class JsonLibTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -134,7 +136,7 @@ public function testJsonEncode() // Do a test with an array starting with 0 $arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; - + $encoded=json_encode($arraytotest); $this->assertEquals($arrayencodedexpected,$encoded); $decoded=json_decode($encoded,true); @@ -148,7 +150,7 @@ public function testJsonEncode() // Same test but array start with 2 instead of 0 $arraytotest=array(2=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; - + $encoded=json_encode($arraytotest); $this->assertEquals($arrayencodedexpected,$encoded); $decoded=json_decode($encoded,true); @@ -158,7 +160,7 @@ public function testJsonEncode() $this->assertEquals($arrayencodedexpected,$encoded); $decoded=dol_json_decode($encoded,true); $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); - + // Test with object $now=gmmktime(12,0,0,1,1,1970); $objecttotest=new stdClass(); diff --git a/test/phpunit/LangTest.php b/test/phpunit/LangTest.php index 4487568c1d63b..61a34b3727199 100644 --- a/test/phpunit/LangTest.php +++ b/test/phpunit/LangTest.php @@ -72,6 +72,8 @@ class LangTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/MarginsLibTest.php b/test/phpunit/MarginsLibTest.php index 7c2e8f68ef637..ae06128925c1f 100644 --- a/test/phpunit/MarginsLibTest.php +++ b/test/phpunit/MarginsLibTest.php @@ -60,6 +60,8 @@ class MarginsLibTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; @@ -136,7 +138,7 @@ public function testGetMarginInfos() $this->assertEquals(25,$result[1]); print __METHOD__." result[2]=".$result[2]."\n"; $this->assertEquals(20,$result[2]); - + $result=getMarginInfos(10, 10, 19.6, 0, 0, 0, 8); var_dump($result); print __METHOD__." result[0]=".$result[0]."\n"; @@ -145,7 +147,7 @@ public function testGetMarginInfos() $this->assertEquals(12.5,$result[1]); print __METHOD__." result[2]=".$result[2]."\n"; $this->assertEquals(1/9*100,$result[2]); - + return 0; } diff --git a/test/phpunit/ModulesTest.php b/test/phpunit/ModulesTest.php index e769ce9dd5116..46b2fb4ee9101 100755 --- a/test/phpunit/ModulesTest.php +++ b/test/phpunit/ModulesTest.php @@ -59,6 +59,8 @@ class ModulesTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index 826b55851e2fe..2779b3011d6fb 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -62,6 +62,8 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index b29cd03b2c9fc..26302e19ea956 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -59,6 +59,8 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; @@ -75,7 +77,7 @@ function __construct() public static function setUpBeforeClass() { global $conf,$user,$langs,$db; - + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. print __METHOD__."\n"; @@ -138,7 +140,7 @@ public function testFactureMercure() $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}'; $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}'; $conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0; - + $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index fb48279cd6661..59c28be2177af 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -61,6 +61,8 @@ class PaypalTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; @@ -135,9 +137,9 @@ public function testPaypalOk() $urltotest=getPaypalPaymentUrl(1,'free'); print "urltotest=".$urltotest."\n"; - + $result=getURLContent($urltotest, 'GET'); - + print __METHOD__." result=".$result."\n"; $this->assertLessThanOrEqual($result, 0); diff --git a/test/phpunit/PdfDocTest.php b/test/phpunit/PdfDocTest.php index 13cb1b59ae31d..0cf37b48762df 100644 --- a/test/phpunit/PdfDocTest.php +++ b/test/phpunit/PdfDocTest.php @@ -63,6 +63,8 @@ class PdfDocTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/PgsqlTest.php b/test/phpunit/PgsqlTest.php index 05efcaeb30bdf..8347bc32905f4 100644 --- a/test/phpunit/PgsqlTest.php +++ b/test/phpunit/PgsqlTest.php @@ -62,6 +62,8 @@ class PgsqlTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; @@ -167,13 +169,13 @@ public function testConvertSQLFromMysql() $result=DoliDBPgsql::convertSQLFromMysql($sql); print __METHOD__." result=".$result."\n"; $this->assertEquals($result, "SELECT a.b, STRING_AGG(a.c, ',') FROM table GROUP BY a.b", 'Test GROUP_CONCAT (without SEPARATOR)'); - + // Test GROUP_CONCAT (with SEPARATOR) $sql="SELECT a.b, GROUP_CONCAT(a.c SEPARATOR ',') FROM table GROUP BY a.b"; $result=DoliDBPgsql::convertSQLFromMysql($sql); print __METHOD__." result=".$result."\n"; $this->assertEquals($result, "SELECT a.b, STRING_AGG(a.c, ',') FROM table GROUP BY a.b", 'Test GROUP_CONCAT (with SEPARATOR)'); - + return $result; } } diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index aee698c1a6e78..9a89f8339b436 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -67,7 +67,9 @@ class PricesTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -160,8 +162,8 @@ public function testCalculPriceTotal() 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.56),$result1,'Test1 FR'); - - + + /* * Country Spain */ diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index 199aace802c0f..f9d3390c69343 100644 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -60,7 +60,9 @@ class ProductTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/ProjectTest.php b/test/phpunit/ProjectTest.php index c2f5d5b816179..ea7cf01c32887 100644 --- a/test/phpunit/ProjectTest.php +++ b/test/phpunit/ProjectTest.php @@ -61,6 +61,8 @@ class ProjectTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/PropalTest.php b/test/phpunit/PropalTest.php index 707673e0d0f3a..23b07c25a2615 100644 --- a/test/phpunit/PropalTest.php +++ b/test/phpunit/PropalTest.php @@ -60,6 +60,8 @@ class PropalTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index 189c17a0bd31a..d25d0f1bc5282 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -64,7 +64,9 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -106,7 +108,7 @@ protected function setUp() $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + $this->api_url=DOL_MAIN_URL_ROOT.'/api/index.php'; $login='admin'; @@ -149,7 +151,7 @@ public function testRestGetUser() $url = $this->api_url.'/user/123456789?api_key='.$this->api_key; //$addheaders=array('Content-Type: application/json'); - + print __METHOD__." Request url=".$url."\n"; $result=getURLContent($url, 'GET', '', 1, array()); //print __METHOD__." Result for unexisting user: ".var_export($result, true)."\n"; @@ -158,7 +160,7 @@ public function testRestGetUser() $object=json_decode($result['content'], true); $this->assertNotNull($object, "Parsing of json result must no be null"); $this->assertEquals(404, $object['error']['code']); - + $url = $this->api_url.'/user/1?api_key='.$this->api_key; print __METHOD__." Request url=".$url."\n"; @@ -172,18 +174,18 @@ public function testRestGetUser() } public function testRestCreateUser() { - + // attemp to create without mandatory fields : $url = $this->api_url.'/user?api_key='.$this->api_key; $addheaders=array('Content-Type: application/json'); - + $bodyobj = array( "lastname"=>"testRestUser", "password"=>"testRestPassword", "email"=>"test@restuser.com" ); $body = json_encode($bodyobj); - + print __METHOD__." Request url=".$url."\n"; $result=getURLContent($url, 'POST', $body, 1, $addheaders); //print __METHOD__." Result for creating incomplete user".var_export($result, true)."\n"; @@ -207,17 +209,17 @@ public function testRestCreateUser() { 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'],''); - $object=json_decode($result['content'], true); + $object=json_decode($result['content'], true); $this->assertNotNull($object, "Parsing of json result must no be null"); $this->assertGreaterThan(0, $object['id'], $object['error']['code'].' '.$object['error']['message']); - + // attempt to create duplicated user print __METHOD__." Request url=".$url."\n"; $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'],''); - $object=json_decode($result['content'], true); + $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 b7916c39d9fa0..0c49567a4a4cf 100644 --- a/test/phpunit/ScriptsTest.php +++ b/test/phpunit/ScriptsTest.php @@ -72,6 +72,8 @@ class ScriptsTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 00714e7bfabca..2796ecb2c32d6 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -72,6 +72,8 @@ class SecurityTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index 24b868b743e51..5f1ed299cdc80 100755 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -60,7 +60,9 @@ class SocieteTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/SqlTest.php b/test/phpunit/SqlTest.php index 0a9acc50220fd..f2e3729fbe4e8 100644 --- a/test/phpunit/SqlTest.php +++ b/test/phpunit/SqlTest.php @@ -72,7 +72,9 @@ class SqlTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -143,16 +145,16 @@ public function testSql() $listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration'); - foreach ($listofsqldir as $dir) + foreach ($listofsqldir as $dir) { print 'Process dir '.$dir."\n"; $filesarray = scandir($dir); - - foreach($filesarray as $key => $file) + + foreach($filesarray as $key => $file) { if (! preg_match('/\.sql$/',$file)) continue; - + print 'Check sql file '.$file."\n"; $filecontent=file_get_contents($dir.'/'.$file); @@ -167,7 +169,7 @@ public function testSql() $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.'); - + if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration') { // Test for migration files only @@ -176,9 +178,9 @@ public function testSql() else { if (preg_match('/\.key\.sql$/',$file)) - { + { // Test for files key files only - + } else { diff --git a/test/phpunit/UserGroupTest.php b/test/phpunit/UserGroupTest.php index d41eefcbd395b..b1e9b3bb43f68 100644 --- a/test/phpunit/UserGroupTest.php +++ b/test/phpunit/UserGroupTest.php @@ -59,7 +59,9 @@ class UserGroupTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -117,7 +119,7 @@ protected function tearDown() /** * testUserGroupCreate - * + * * @return void */ public function testUserGroupCreate() @@ -139,7 +141,7 @@ public function testUserGroupCreate() /** * testUserGroupFetch - * + * * @param int $id Id of group * @return void * @depends testUserGroupCreate @@ -163,7 +165,7 @@ public function testUserGroupFetch($id) /** * testUserGroupUpdate - * + * * @param Object $localobject Group * @return void * @depends testUserGroupFetch @@ -187,7 +189,7 @@ public function testUserGroupUpdate($localobject) /** * testUserGroupAddRight - * + * * @param Object $localobject Object to show * @return void * @depends testUserGroupUpdate @@ -210,7 +212,7 @@ public function testUserGroupAddRight($localobject) /** * testUserGroupDelRight - * + * * @param Object $localobject Object * @return void * @depends testUserGroupAddRight @@ -233,7 +235,7 @@ public function testUserGroupDelRight($localobject) /** * testUserGroupOther - * + * * @param Object $localobject Object * @return void * @depends testUserGroupDelRight @@ -261,7 +263,7 @@ public function testUserGroupOther($localobject) /** * testUserGroupDelete - * + * * @param int $id Id of object * @return void * @depends testUserGroupOther diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index 4e0c0ba58cafd..912dd6f382bfb 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -59,7 +59,9 @@ class UserTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index ce3275bb58e56..6e2ae6fbda1ad 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -55,9 +55,9 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase protected $savdb; protected $soapclient; protected $socid; - + protected $ns = 'http://www.dolibarr.org/ns/'; - + /** * Constructor * We save global variables into local variables @@ -66,6 +66,8 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; @@ -73,8 +75,8 @@ function __construct() $this->savlangs=$langs; $this->savdb=$db; $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php'; - - + + // Set the WebService URL print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; $this->soapclient = new nusoap_client($WS_DOL_URL); @@ -83,7 +85,7 @@ function __construct() $this->soapclient->soap_defencoding='UTF-8'; $this->soapclient->decodeUTF8(false); } - + // create third_parties, needed to test an invoice $societe=new Societe($db); $societe->ref=''; @@ -95,11 +97,11 @@ function __construct() $societe->date_creation=$now; $societe->tva_assuj=0; $societe->particulier=0; - + $societe->create($user); - + $this->socid = $societe->id; - + print __METHOD__." societe created id=".$societe->id."\n"; print __METHOD__." db->type=".$db->type." user->id=".$user->id; @@ -135,9 +137,9 @@ protected function setUp() $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + print __METHOD__."\n"; - + } /** @@ -171,7 +173,7 @@ public function testWSInvoicesCreateInvoice() $societe->fetch('', '', 'ref-phpunit'); print __METHOD__." societe loaded id=".$societe->id."\n"; */ - + $body = array ( "id" => NULL, "ref" => NULL, @@ -252,13 +254,13 @@ public function testWSInvoicesCreateInvoice() return $result; } - + /** * testWSInvoicesGetInvoiceByRefExt - * + * * Retrieve an invoice using ref_ext * @depends testWSInvoicesCreateInvoice - * + * * @param array $result Invoice created by create method * @return array Invoice */ @@ -308,13 +310,13 @@ public function testWSInvoicesGetInvoiceByRefExt($result) return $result; } - + /** * testWSInvoicesUpdateInvoiceByRefExt - * + * * Update an invoice using ref_ext * @depends testWSInvoicesCreateInvoice - * + * * @param array $result invoice created by create method * @return array Invoice */ diff --git a/test/phpunit/WebservicesOrdersTest.php b/test/phpunit/WebservicesOrdersTest.php index 06ead4f487307..d9c718c399abe 100644 --- a/test/phpunit/WebservicesOrdersTest.php +++ b/test/phpunit/WebservicesOrdersTest.php @@ -61,7 +61,9 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/WebservicesOtherTest.php b/test/phpunit/WebservicesOtherTest.php index d04fc6b9b9cff..d31d4ed9cc08d 100644 --- a/test/phpunit/WebservicesOtherTest.php +++ b/test/phpunit/WebservicesOtherTest.php @@ -61,7 +61,9 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/WebservicesProductsTest.php b/test/phpunit/WebservicesProductsTest.php index fecc58a65e10b..e9cdee38b8afb 100644 --- a/test/phpunit/WebservicesProductsTest.php +++ b/test/phpunit/WebservicesProductsTest.php @@ -68,7 +68,9 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index 2888c432e7325..7bfd171436ae0 100644 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -53,12 +53,12 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase protected $savlangs; protected $savdb; protected $soapclient; - + private $_WS_DOL_URL; private $_ns='http://www.dolibarr.org/ns/'; - - - + + + /** * Constructor @@ -68,15 +68,17 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; $this->savlangs=$langs; $this->savdb=$db; - + $this->_WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php'; - + // Set the WebService URL print __METHOD__." create nusoap_client for URL=".$this->_WS_DOL_URL."\n"; $this->soapclient = new nusoap_client($this->_WS_DOL_URL); @@ -146,10 +148,10 @@ public function testWSThirdpartycreateThirdParty() $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + $WS_METHOD = 'createThirdParty'; - - + + // Call the WebService method and store its result in $result. $authentication=array( 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, @@ -157,7 +159,7 @@ public function testWSThirdpartycreateThirdParty() 'login'=>'admin', 'password'=>'admin', 'entity'=>''); - + $body = array ( "id" => NULL, "ref" => "name", @@ -195,7 +197,7 @@ public function testWSThirdpartycreateThirdParty() "vat_used" => "", "vat_number" => "" ); - + // Test URL $result=''; $parameters = array('authentication'=>$authentication, 'thirdparty'=>$body); @@ -215,20 +217,20 @@ public function testWSThirdpartycreateThirdParty() print $this->soapclient->response; print "\n"; } - + print __METHOD__." result=".$result['result']['result_code']."\n"; $this->assertEquals('OK',$result['result']['result_code']); - $this->assertEquals('name',$result['ref']); - + $this->assertEquals('name',$result['ref']); + return $result; } /** * testWSThirdpartygetThirdPartyById - * + * * Use id to retrieve thirdparty * @depends testWSThirdpartycreateThirdParty - * + * * @param array $result thirdparty created by create method * @return array thirpdarty updated */ @@ -278,18 +280,18 @@ public function testWSThirdpartygetThirdPartyById($result) $this->assertEquals('0', $result['thirdparty']['status']); $this->assertEquals('1', $result['thirdparty']['client']); $this->assertEquals('0', $result['thirdparty']['supplier']); - - + + return $result; } - + /** * testWSThirdpartygetThirdPartyByRefExt * * Use ref_ext to retrieve thirdparty * * @depends testWSThirdpartycreateThirdParty - * + * * @param array $result thirdparty created by create method * @return array thirdparty */ @@ -301,9 +303,9 @@ public function testWSThirdpartygetThirdPartyByRefExt($result) $langs=$this->savlangs; $db=$this->savdb; $id = $result['id']; - + $WS_METHOD = 'getThirdParty'; - + // Call the WebService method and store its result in $result. $authentication=array( 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, @@ -311,7 +313,7 @@ public function testWSThirdpartygetThirdPartyByRefExt($result) 'login'=>'admin', 'password'=>'admin', 'entity'=>''); - + // Test URL $result=''; $parameters = array('authentication'=>$authentication, 'id'=>'', 'ref'=>'', 'ref_ext'=>'12'); @@ -332,7 +334,7 @@ public function testWSThirdpartygetThirdPartyByRefExt($result) print $this->soapclient->response; print "\n"; } - + print __METHOD__." result=".$result['result']['result_code']."\n"; $this->assertEquals('OK',$result['result']['result_code']); $this->assertEquals($id, $result['thirdparty']['id']); @@ -341,11 +343,11 @@ public function testWSThirdpartygetThirdPartyByRefExt($result) $this->assertEquals('0', $result['thirdparty']['status']); $this->assertEquals('1', $result['thirdparty']['client']); $this->assertEquals('0', $result['thirdparty']['supplier']); - - + + return $result; } - + /** * testWSThirdpartydeleteThirdParty * @@ -362,9 +364,9 @@ public function testWSThirdpartydeleteThirdPartyById($result) $langs=$this->savlangs; $db=$this->savdb; $id = $result['id']; - + $WS_METHOD = 'deleteThirdParty'; - + // Call the WebService method and store its result in $result. $authentication=array( 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, @@ -372,7 +374,7 @@ public function testWSThirdpartydeleteThirdPartyById($result) 'login'=>'admin', 'password'=>'admin', 'entity'=>''); - + $result=''; $parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'', 'ref_ext'=>''); print __METHOD__." call method ".$WS_METHOD."\n"; @@ -393,7 +395,7 @@ public function testWSThirdpartydeleteThirdPartyById($result) print __METHOD__." result=".$result['result']['result_code']."\n"; $this->assertEquals('OK',$result['result']['result_code']); - + return $result; } diff --git a/test/phpunit/WebservicesUserTest.php b/test/phpunit/WebservicesUserTest.php index 9be9716710434..b4cc865bf5cc4 100644 --- a/test/phpunit/WebservicesUserTest.php +++ b/test/phpunit/WebservicesUserTest.php @@ -61,7 +61,9 @@ class WebservicesUserTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/XCalLibTest.php b/test/phpunit/XCalLibTest.php index 3bbf3469b1737..932f68aa18d47 100644 --- a/test/phpunit/XCalLibTest.php +++ b/test/phpunit/XCalLibTest.php @@ -59,7 +59,9 @@ class XCalLibTest extends PHPUnit_Framework_TestCase */ function __construct() { - //$this->sharedFixture + parent::__construct(); + + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; From df721a5fbcd7e4ea04160d1779670f0b864dc07f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Sep 2018 14:18:04 +0200 Subject: [PATCH 07/11] Only min and max php version --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index bac020e13c58b..4c7a714eba1ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,6 +63,14 @@ matrix: - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: + - php: '5.4' + env: DB=mysql + - php: '5.5' + env: DB=mysql + - php: '5.6' + env: DB=mysql + - php: '7.0' + env: DB=mysql - php: '5.4' env: DB=postgresql - php: '5.5' From 5bab9d59b29f4f7bcd5a580064fe137cd0c6b562 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Sep 2018 14:19:23 +0200 Subject: [PATCH 08/11] Fix var_dump --- test/phpunit/MarginsLibTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test/phpunit/MarginsLibTest.php b/test/phpunit/MarginsLibTest.php index ae06128925c1f..21c07f7c04a3d 100644 --- a/test/phpunit/MarginsLibTest.php +++ b/test/phpunit/MarginsLibTest.php @@ -140,7 +140,6 @@ public function testGetMarginInfos() $this->assertEquals(20,$result[2]); $result=getMarginInfos(10, 10, 19.6, 0, 0, 0, 8); - var_dump($result); print __METHOD__." result[0]=".$result[0]."\n"; $this->assertEquals(8,$result[0]); print __METHOD__." result[1]=".$result[1]."\n"; From 42cb2b07db9bfe53947fc088327e467def77b8f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Sep 2018 15:22:49 +0200 Subject: [PATCH 09/11] Only min and max version --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 996f3c898b6c3..5550550b905f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,6 @@ php: - '7.0' - '7.1' - '7.2' -#- hhvm only with dist: trusty - nightly env: @@ -60,7 +59,6 @@ env: matrix: fast_finish: true allow_failures: - - php: hhvm - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: @@ -72,6 +70,8 @@ matrix: env: DB=mysql - php: '7.0' env: DB=mysql + - php: '7.1' + env: DB=mysql - php: '5.4' env: DB=postgresql - php: '5.5' @@ -82,8 +82,6 @@ matrix: env: DB=postgresql - php: '7.1' env: DB=postgresql - - php: hhvm - env: DB=postgresql - php: nightly env: DB=postgresql From ebba0b9e675a9ee98fc9b5f7c71bef8468258443 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Sep 2018 15:24:29 +0200 Subject: [PATCH 10/11] phpunit 6.1 compatibility --- test/phpunit/AccountingAccountTest.php | 2 ++ test/phpunit/GetUrlLibTest.php | 2 ++ test/phpunit/SupplierProposalTest.php | 2 ++ test/phpunit/UtilsTest.php | 2 ++ 4 files changed, 8 insertions(+) diff --git a/test/phpunit/AccountingAccountTest.php b/test/phpunit/AccountingAccountTest.php index ba7f567b4a0f9..1ada894485435 100644 --- a/test/phpunit/AccountingAccountTest.php +++ b/test/phpunit/AccountingAccountTest.php @@ -59,6 +59,8 @@ class AccountingAccountTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/GetUrlLibTest.php b/test/phpunit/GetUrlLibTest.php index 21dacd5a0f196..2a6d218dc9375 100644 --- a/test/phpunit/GetUrlLibTest.php +++ b/test/phpunit/GetUrlLibTest.php @@ -61,6 +61,8 @@ class GetUrlLibTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index ee4729ed47f87..2428bd6d44167 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -63,6 +63,8 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; diff --git a/test/phpunit/UtilsTest.php b/test/phpunit/UtilsTest.php index b80ce84f62477..e9c3ede729b28 100644 --- a/test/phpunit/UtilsTest.php +++ b/test/phpunit/UtilsTest.php @@ -59,6 +59,8 @@ class UtilsTest extends PHPUnit_Framework_TestCase */ function __construct() { + parent::__construct(); + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; From e0b272941fcfa5f4941b60a5a421193d8502b081 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Sep 2018 15:25:27 +0200 Subject: [PATCH 11/11] Fix mariadb --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4c7a714eba1ca..22593b1eb085d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,13 +64,13 @@ matrix: # We exclude some combinations not usefull to save Travis CPU exclude: - php: '5.4' - env: DB=mysql + env: DB=mariadb - php: '5.5' - env: DB=mysql + env: DB=mariadb - php: '5.6' - env: DB=mysql + env: DB=mariadb - php: '7.0' - env: DB=mysql + env: DB=mariadb - php: '5.4' env: DB=postgresql - php: '5.5'