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

View File

@ -55,12 +55,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
@ -76,9 +76,9 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$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);
@ -148,10 +148,10 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$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,
@ -159,7 +159,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
'login'=>'admin',
'password'=>'admin',
'entity'=>'');
$body = array (
"id" => NULL,
"ref" => "name",
@ -168,8 +168,8 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
"status" => NULL,
"client" => 1,
"supplier" => 0,
"customer_code" => "",
"supplier_code" => "",
"customer_code" => "CU0901-5678",
"supplier_code" => "SU0901-5678",
"customer_code_accountancy" => "",
"supplier_code_accountancy" => "",
"date_creation" => "", // dateTime
@ -197,7 +197,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
"vat_used" => "",
"vat_number" => ""
);
// Test URL
$result='';
$parameters = array('authentication'=>$authentication, 'thirdparty'=>$body);
@ -217,20 +217,20 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
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
*/
@ -280,18 +280,18 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$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
*/
@ -303,9 +303,9 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$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,
@ -313,7 +313,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
'login'=>'admin',
'password'=>'admin',
'entity'=>'');
// Test URL
$result='';
$parameters = array('authentication'=>$authentication, 'id'=>'', 'ref'=>'', 'ref_ext'=>'12');
@ -334,7 +334,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
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']);
@ -343,11 +343,11 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$this->assertEquals('0', $result['thirdparty']['status']);
$this->assertEquals('1', $result['thirdparty']['client']);
$this->assertEquals('0', $result['thirdparty']['supplier']);
return $result;
}
/**
* testWSThirdpartydeleteThirdParty
*
@ -364,9 +364,9 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$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,
@ -374,7 +374,7 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
'login'=>'admin',
'password'=>'admin',
'entity'=>'');
$result='';
$parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'', 'ref_ext'=>'');
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";
$this->assertEquals('OK',$result['result']['result_code']);
return $result;
}