Fix phpunit

This commit is contained in:
Laurent Destailleur 2017-11-17 16:06:55 +01:00
parent 2705030006
commit 0be11e5e45
2 changed files with 47 additions and 45 deletions

View File

@ -56,11 +56,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
protected $savlangs; protected $savlangs;
protected $savdb; protected $savdb;
protected $soapclient; protected $soapclient;
private static $socid; private static $socid;
protected $ns = 'http://www.dolibarr.org/ns/'; protected $ns = 'http://www.dolibarr.org/ns/';
/** /**
* Constructor * Constructor
* We save global variables into local variables * We save global variables into local variables
@ -75,7 +75,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$this->savuser=$user; $this->savuser=$user;
$this->savlangs=$langs; $this->savlangs=$langs;
$this->savdb=$db; $this->savdb=$db;
// Set the WebService URL // Set the WebService URL
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php'; $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
@ -85,7 +85,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$this->soapclient->soap_defencoding='UTF-8'; $this->soapclient->soap_defencoding='UTF-8';
$this->soapclient->decodeUTF8(false); $this->soapclient->decodeUTF8(false);
} }
print __METHOD__." db->type=".$db->type." user->id=".$user->id; print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//print " - db ".$db->db; //print " - db ".$db->db;
print "\n"; print "\n";
@ -114,11 +114,13 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$societe->ref_ext='ref-phpunit'; $societe->ref_ext='ref-phpunit';
$societe->status=1; $societe->status=1;
$societe->client=1; $societe->client=1;
$societe->code_client='CU0901-1234';
$societe->code_fournisseur='SU0901-1234';
$societe->fournisseur=0; $societe->fournisseur=0;
$societe->date_creation=$now; $societe->date_creation=$now;
$societe->tva_assuj=0; $societe->tva_assuj=0;
$societe->particulier=0; $societe->particulier=0;
$societe->create($user); $societe->create($user);
self::$socid = $societe->id; self::$socid = $societe->id;
@ -259,13 +261,13 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
return $result; return $result;
} }
/** /**
* testWSInvoicesGetInvoiceByRefExt * testWSInvoicesGetInvoiceByRefExt
* *
* Retrieve an invoice using ref_ext * Retrieve an invoice using ref_ext
* @depends testWSInvoicesCreateInvoice * @depends testWSInvoicesCreateInvoice
* *
* @param array $result Invoice created by create method * @param array $result Invoice created by create method
* @return array Invoice * @return array Invoice
*/ */
@ -315,13 +317,13 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
return $result; return $result;
} }
/** /**
* testWSInvoicesUpdateInvoiceByRefExt * testWSInvoicesUpdateInvoiceByRefExt
* *
* Update an invoice using ref_ext * Update an invoice using ref_ext
* @depends testWSInvoicesCreateInvoice * @depends testWSInvoicesCreateInvoice
* *
* @param array $result invoice created by create method * @param array $result invoice created by create method
* @return array Invoice * @return array Invoice
*/ */

View File

@ -55,12 +55,12 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
protected $savlangs; protected $savlangs;
protected $savdb; protected $savdb;
protected $soapclient; protected $soapclient;
private $_WS_DOL_URL; private $_WS_DOL_URL;
private $_ns='http://www.dolibarr.org/ns/'; private $_ns='http://www.dolibarr.org/ns/';
/** /**
* Constructor * Constructor
@ -76,9 +76,9 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$this->savuser=$user; $this->savuser=$user;
$this->savlangs=$langs; $this->savlangs=$langs;
$this->savdb=$db; $this->savdb=$db;
$this->_WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php'; $this->_WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
// Set the WebService URL // Set the WebService URL
print __METHOD__." create nusoap_client for URL=".$this->_WS_DOL_URL."\n"; print __METHOD__." create nusoap_client for URL=".$this->_WS_DOL_URL."\n";
$this->soapclient = new nusoap_client($this->_WS_DOL_URL); $this->soapclient = new nusoap_client($this->_WS_DOL_URL);
@ -148,10 +148,10 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$user=$this->savuser; $user=$this->savuser;
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$WS_METHOD = 'createThirdParty'; $WS_METHOD = 'createThirdParty';
// Call the WebService method and store its result in $result. // Call the WebService method and store its result in $result.
$authentication=array( $authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
@ -159,7 +159,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
'login'=>'admin', 'login'=>'admin',
'password'=>'admin', 'password'=>'admin',
'entity'=>''); 'entity'=>'');
$body = array ( $body = array (
"id" => NULL, "id" => NULL,
"ref" => "name", "ref" => "name",
@ -168,8 +168,8 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
"status" => NULL, "status" => NULL,
"client" => 1, "client" => 1,
"supplier" => 0, "supplier" => 0,
"customer_code" => "", "customer_code" => "CU0901-5678",
"supplier_code" => "", "supplier_code" => "SU0901-5678",
"customer_code_accountancy" => "", "customer_code_accountancy" => "",
"supplier_code_accountancy" => "", "supplier_code_accountancy" => "",
"date_creation" => "", // dateTime "date_creation" => "", // dateTime
@ -197,7 +197,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
"vat_used" => "", "vat_used" => "",
"vat_number" => "" "vat_number" => ""
); );
// Test URL // Test URL
$result=''; $result='';
$parameters = array('authentication'=>$authentication, 'thirdparty'=>$body); $parameters = array('authentication'=>$authentication, 'thirdparty'=>$body);
@ -217,20 +217,20 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
print $this->soapclient->response; print $this->soapclient->response;
print "\n"; print "\n";
} }
print __METHOD__." result=".$result['result']['result_code']."\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('name',$result['ref']); $this->assertEquals('name',$result['ref']);
return $result; return $result;
} }
/** /**
* testWSThirdpartygetThirdPartyById * testWSThirdpartygetThirdPartyById
* *
* Use id to retrieve thirdparty * Use id to retrieve thirdparty
* @depends testWSThirdpartycreateThirdParty * @depends testWSThirdpartycreateThirdParty
* *
* @param array $result thirdparty created by create method * @param array $result thirdparty created by create method
* @return array thirpdarty updated * @return array thirpdarty updated
*/ */
@ -280,18 +280,18 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$this->assertEquals('0', $result['thirdparty']['status']); $this->assertEquals('0', $result['thirdparty']['status']);
$this->assertEquals('1', $result['thirdparty']['client']); $this->assertEquals('1', $result['thirdparty']['client']);
$this->assertEquals('0', $result['thirdparty']['supplier']); $this->assertEquals('0', $result['thirdparty']['supplier']);
return $result; return $result;
} }
/** /**
* testWSThirdpartygetThirdPartyByRefExt * testWSThirdpartygetThirdPartyByRefExt
* *
* Use ref_ext to retrieve thirdparty * Use ref_ext to retrieve thirdparty
* *
* @depends testWSThirdpartycreateThirdParty * @depends testWSThirdpartycreateThirdParty
* *
* @param array $result thirdparty created by create method * @param array $result thirdparty created by create method
* @return array thirdparty * @return array thirdparty
*/ */
@ -303,9 +303,9 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$id = $result['id']; $id = $result['id'];
$WS_METHOD = 'getThirdParty'; $WS_METHOD = 'getThirdParty';
// Call the WebService method and store its result in $result. // Call the WebService method and store its result in $result.
$authentication=array( $authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
@ -313,7 +313,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
'login'=>'admin', 'login'=>'admin',
'password'=>'admin', 'password'=>'admin',
'entity'=>''); 'entity'=>'');
// Test URL // Test URL
$result=''; $result='';
$parameters = array('authentication'=>$authentication, 'id'=>'', 'ref'=>'', 'ref_ext'=>'12'); $parameters = array('authentication'=>$authentication, 'id'=>'', 'ref'=>'', 'ref_ext'=>'12');
@ -334,7 +334,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
print $this->soapclient->response; print $this->soapclient->response;
print "\n"; print "\n";
} }
print __METHOD__." result=".$result['result']['result_code']."\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($id, $result['thirdparty']['id']); $this->assertEquals($id, $result['thirdparty']['id']);
@ -343,11 +343,11 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$this->assertEquals('0', $result['thirdparty']['status']); $this->assertEquals('0', $result['thirdparty']['status']);
$this->assertEquals('1', $result['thirdparty']['client']); $this->assertEquals('1', $result['thirdparty']['client']);
$this->assertEquals('0', $result['thirdparty']['supplier']); $this->assertEquals('0', $result['thirdparty']['supplier']);
return $result; return $result;
} }
/** /**
* testWSThirdpartydeleteThirdParty * testWSThirdpartydeleteThirdParty
* *
@ -364,9 +364,9 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$id = $result['id']; $id = $result['id'];
$WS_METHOD = 'deleteThirdParty'; $WS_METHOD = 'deleteThirdParty';
// Call the WebService method and store its result in $result. // Call the WebService method and store its result in $result.
$authentication=array( $authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
@ -374,7 +374,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
'login'=>'admin', 'login'=>'admin',
'password'=>'admin', 'password'=>'admin',
'entity'=>''); 'entity'=>'');
$result=''; $result='';
$parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'', 'ref_ext'=>''); $parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'', 'ref_ext'=>'');
print __METHOD__." call method ".$WS_METHOD."\n"; print __METHOD__." call method ".$WS_METHOD."\n";
@ -395,7 +395,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
print __METHOD__." result=".$result['result']['result_code']."\n"; print __METHOD__." result=".$result['result']['result_code']."\n";
$this->assertEquals('OK',$result['result']['result_code']); $this->assertEquals('OK',$result['result']['result_code']);
return $result; return $result;
} }