From 73fb7b2615cbfe2833d49b8752c652b7c70e13e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 21 Jun 2016 01:07:44 +0200 Subject: [PATCH] Fix phpunit regression. phpunit test on ws invoice is cleaner. --- htdocs/compta/facture/class/facture.class.php | 2 +- test/phpunit/WebservicesInvoicesTest.php | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4b5da68f8a2..b0e0c431502 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -263,7 +263,7 @@ class Facture extends CommonInvoice $result=$soc->fetch($this->socid); if ($result < 0) { - $this->error="Failed to fetch company"; + $this->error="Failed to fetch company: ".$soc->error; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -2; } diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index bbfde0a66e5..ce3275bb58e 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -84,11 +84,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase $this->soapclient->decodeUTF8(false); } - // create a third_party, needed to create an invoice + // create third_parties, needed to test an invoice $societe=new Societe($db); $societe->ref=''; $societe->name='name'; - $societe->ref_ext='209'; + $societe->ref_ext='ref-phpunit'; $societe->status=1; $societe->client=1; $societe->fournisseur=0; @@ -167,16 +167,16 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase $WS_METHOD = 'createInvoice'; // load societe first - $societe=new Societe($db); - $societe->fetch('', '', '209'); + /*$societe=new Societe($db); + $societe->fetch('', '', 'ref-phpunit'); print __METHOD__." societe loaded id=".$societe->id."\n"; - + */ $body = array ( "id" => NULL, "ref" => NULL, - "ref_ext" => "165", - "thirdparty_id" => $societe->id, + "ref_ext" => "ref-phpunit-2", + "thirdparty_id" => $this->socid, "fk_user_author" => NULL, "fk_user_valid" => NULL, "date" => "2015-04-19 20:16:53", @@ -247,7 +247,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result['result']['result_code']."\n"; $this->assertEquals('OK',$result['result']['result_code']); - $this->assertEquals('165', $result['ref_ext']); + $this->assertEquals('ref-phpunit-2', $result['ref_ext']); return $result; @@ -282,7 +282,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase // Test URL $result=''; - $parameters = array('authentication'=>$authentication,'id'=>NULL,'ref'=>NULL,'ref_ext'=>165); + $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,''); @@ -303,7 +303,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase } print __METHOD__." result=".$result['result']['result_code']."\n"; $this->assertEquals('OK',$result['result']['result_code']); - $this->assertEquals('165', $result['invoice']['ref_ext']); + $this->assertEquals('ref-phpunit-2', $result['invoice']['ref_ext']); return $result; @@ -332,8 +332,8 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase $body = array ( "id" => NULL, "ref" => NULL, - "ref_ext" => "165", - "thirdparty_id" => "209", + "ref_ext" => "ref-phpunit-2", + "thirdparty_id" => $this->socid, "fk_user_author" => NULL, "fk_user_valid" => NULL, "date" => "2015-04-19 20:16:53", @@ -404,7 +404,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('165', $result['ref_ext']); + $this->assertEquals('ref-phpunit-2', $result['ref_ext']); return $result; -- GitLab