update test

This commit is contained in:
Arnaud Aujon 2015-05-27 15:42:46 +02:00
parent 278d447e45
commit 336b8c49b3

View File

@ -53,7 +53,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
protected $savuser; protected $savuser;
protected $savlangs; protected $savlangs;
protected $savdb; protected $savdb;
/** /**
* Constructor * Constructor
* We save global variables into local variables * We save global variables into local variables
@ -79,6 +79,23 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
// create a third_party, needed to create an invoice
$societe=new Societe($db);
$societe->ref='';
$societe->name='name';
$societe->ref_ext='209';
$societe->status=1;
$societe->client=1;
$societe->fournisseur=0;
$societe->date_creation=$now;
$societe->tva_assuj=0;
$societe->particulier=0;
$societe->create($user);
print __METHOD__." societe created id=".$societe->id."\n";
print __METHOD__."\n"; print __METHOD__."\n";
} }
@ -102,10 +119,9 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$user=$this->savuser; $user=$this->savuser;
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
// create a third_party, needed to create an invoice
print __METHOD__."\n"; print __METHOD__."\n";
} }
/** /**
@ -136,6 +152,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$WS_METHOD = 'createInvoice'; $WS_METHOD = 'createInvoice';
$ns='http://www.dolibarr.org/ns/'; $ns='http://www.dolibarr.org/ns/';
// load societe first
$societe=new Societe($db);
$societe->fetch('', '', '209');
print __METHOD__." societe loaded id=".$societe->id."\n";
// Set the WebService URL // Set the WebService URL
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
$soapclient = new nusoap_client($WS_DOL_URL); $soapclient = new nusoap_client($WS_DOL_URL);
@ -144,48 +165,49 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$soapclient->soap_defencoding='UTF-8'; $soapclient->soap_defencoding='UTF-8';
$soapclient->decodeUTF8(false); $soapclient->decodeUTF8(false);
} }
$body = array ( $body = array (
["id"] => NULL, "id" => NULL,
["ref"]=> NULL, "ref" => NULL,
["ref_ext"]=> "165", "ref_ext" => "165",
["thirdparty_id"]=> "209", "thirdparty_id" => $societe->id,
["fk_user_author"] => NULL, "fk_user_author" => NULL,
["fk_user_valid"] => NULL, "fk_user_valid" => NULL,
["date"]=> "2015-04-19 20:16:53", "date" => "2015-04-19 20:16:53",
["date_due"]=> "", "date_due" => "",
["date_creation"]=> "", "date_creation" => "",
["date_validation"]=> "", "date_validation" => "",
["date_modification"]=> "", "date_modification" => "",
["type"]=> "", "type" => "",
["total_net"]=> "36.30", "total_net" => "36.30",
["total_vat"]=> "6.00", "total_vat" => "6.00",
["total"]=> "42.30", "total" => "42.30",
["payment_mode_id"]=> 50, "payment_mode_id" => 50,
["note_private"]=> "Synchronised from Prestashop", "note_private" => "Synchronised from Prestashop",
["note_public"]=> "", "note_public" => "",
["status"]=> "1", "status" => "1",
["close_code"]=> NULL , "close_code" => NULL ,
["close_note"]=> NULL, "close_note" => NULL,
["project_id"]=> NULL, "project_id" => NULL,
["lines"] => array( "lines" => array(
["id"] => NULL, "id" => NULL,
["type"]=> 0, "type" => 0,
["desc"]=> "Horloge Vinyle Serge", "desc" => "Horloge Vinyle Serge",
["vat_rate"]=> 20, "vat_rate" => 20,
["qty"]=> "1", "qty" => "1",
["unitprice"]=> "30.000000", "unitprice" => "30.000000",
["total_net"]=> "30.000000", "total_net" => "30.000000",
["total_vat"]=> "6.00", "total_vat" => "6.00",
["total"]=> "36.000000", "total" => "36.000000",
["date_start"]=> "", "date_start" => "",
["date_end"]=> "", "date_end" => "",
["payment_mode_id"]=> "", "payment_mode_id" => "",
["product_id"]=> "", "product_id" => "",
["product_ref"]=> "", "product_ref" => "",
["product_label"]=> "", "product_label" => "",
["product_desc"]=> "" ) "product_desc" => "" )
); );
// Call the WebService method and store its result in $result. // Call the WebService method and store its result in $result.
$authentication=array( $authentication=array(
@ -218,7 +240,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
print "\n"; print "\n";
} }
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result['result']['result_label']."\n";
$this->assertEquals('OK',$result['result']['result_code']); $this->assertEquals('OK',$result['result']['result_code']);
$this->assertEquals('165', $result['ref_ext']); $this->assertEquals('165', $result['ref_ext']);
@ -319,45 +341,45 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
// update status to 2 // update status to 2
$body = array ( $body = array (
["id"] => NULL, "id" => NULL,
["ref"]=> NULL, "ref" => NULL,
["ref_ext"]=> "165", "ref_ext" => "165",
["thirdparty_id"]=> "209", "thirdparty_id" => "209",
["fk_user_author"] => NULL, "fk_user_author" => NULL,
["fk_user_valid"] => NULL, "fk_user_valid" => NULL,
["date"]=> "2015-04-19 20:16:53", "date" => "2015-04-19 20:16:53",
["date_due"]=> "", "date_due" => "",
["date_creation"]=> "", "date_creation" => "",
["date_validation"]=> "", "date_validation" => "",
["date_modification"]=> "", "date_modification" => "",
["type"]=> "", "type" => "",
["total_net"]=> "36.30", "total_net" => "36.30",
["total_vat"]=> "6.00", "total_vat" => "6.00",
["total"]=> "42.30", "total" => "42.30",
["payment_mode_id"]=> 50, "payment_mode_id" => 50,
["note_private"]=> "Synchronised from Prestashop", "note_private" => "Synchronised from Prestashop",
["note_public"]=> "", "note_public" => "",
["status"]=> "2", "status" => "2",
["close_code"]=> NULL , "close_code" => NULL ,
["close_note"]=> NULL, "close_note" => NULL,
["project_id"]=> NULL, "project_id" => NULL,
["lines"] => array( "lines" => array(
["id"] => NULL, "id" => NULL,
["type"]=> 0, "type" => 0,
["desc"]=> "Horloge Vinyle Serge", "desc" => "Horloge Vinyle Serge",
["vat_rate"]=> 20, "vat_rate" => 20,
["qty"]=> "1", "qty" => "1",
["unitprice"]=> "30.000000", "unitprice" => "30.000000",
["total_net"]=> "30.000000", "total_net" => "30.000000",
["total_vat"]=> "6.00", "total_vat" => "6.00",
["total"]=> "36.000000", "total" => "36.000000",
["date_start"]=> "", "date_start" => "",
["date_end"]=> "", "date_end" => "",
["payment_mode_id"]=> "", "payment_mode_id" => "",
["product_id"]=> "", "product_id" => "",
["product_ref"]=> "", "product_ref" => "",
["product_label"]=> "", "product_label" => "",
["product_desc"]=> "" ) "product_desc" => "" )
); );
// Call the WebService method and store its result in $result. // Call the WebService method and store its result in $result.