From 8b904e9f5c666d1e52638221ad59a6da1cf58bc2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Sep 2013 11:46:45 +0200 Subject: [PATCH] Better phpunit test for web services --- test/phpunit/WebservicesInvoicesTest.php | 14 +++--- test/phpunit/WebservicesOrdersTest.php | 53 +++++++++++----------- test/phpunit/WebservicesOtherTest.php | 12 ++--- test/phpunit/WebservicesThirdpartyTest.php | 14 +++--- 4 files changed, 46 insertions(+), 47 deletions(-) diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index 6f04f5320e2..70b9612734d 100755 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -131,11 +131,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php'; - $WS_METHOD = 'xxx'; + $WS_METHOD = ''; $ns='http://www.dolibarr.org/ns/'; // 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); if ($soapclient) { @@ -152,10 +152,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase 'entity'=>''); // Test URL + $result=''; if ($WS_METHOD) { $parameters = array('authentication'=>$authentication); - print __METHOD__."Call method ".$WS_METHOD."\n"; + print __METHOD__." call method ".$WS_METHOD."\n"; $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); if (! $result) { @@ -165,12 +166,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase print $soapclient->request; print "
\n\n"; print $soapclient->response; - exit; } - } - print __METHOD__." result=".$result."\n"; - //$this->assertEquals('OK',$result['result']['result_code']); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('OK',$result['result']['result_code']); + } return $result; } diff --git a/test/phpunit/WebservicesOrdersTest.php b/test/phpunit/WebservicesOrdersTest.php index 750c33fa30a..c3e382a85e7 100755 --- a/test/phpunit/WebservicesOrdersTest.php +++ b/test/phpunit/WebservicesOrdersTest.php @@ -131,11 +131,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_order.php'; - $WS_METHOD = 'xxx'; + $WS_METHOD = ''; $ns='http://www.dolibarr.org/ns/'; // 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); if ($soapclient) { @@ -155,7 +155,7 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase if ($WS_METHOD) { $parameters = array('authentication'=>$authentication); - print __METHOD__."Call method ".$WS_METHOD."\n"; + print __METHOD__." call method ".$WS_METHOD."\n"; $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); if (! $result) { @@ -165,12 +165,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase print $soapclient->request; print "
\n\n"; print $soapclient->response; - exit; } - } - print __METHOD__." result=".$result."\n"; - //$this->assertEquals('OK',$result['result']['result_code']); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('OK',$result['result']['result_code']); + } return $result; } @@ -195,7 +194,7 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase $ns='http://www.dolibarr.org/ns/'; // 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); if ($soapclient) { @@ -212,10 +211,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase 'entity'=>''); // Test URL + $result=''; if ($WS_METHOD) { $parameters = array('authentication'=>$authentication); - print __METHOD__."Call method ".$WS_METHOD."\n"; + print __METHOD__." call method ".$WS_METHOD."\n"; $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); if (! $result) { @@ -225,12 +225,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase print $soapclient->request; print "
\n\n"; print $soapclient->response; - exit; } - } - print __METHOD__." result=".$result."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('OK',$result['result']['result_code']); + } return $result; } @@ -250,11 +249,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php'; - $WS_METHOD = 'xxx'; + $WS_METHOD = ''; $ns='http://www.dolibarr.org/ns/'; // 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); if ($soapclient) { @@ -271,10 +270,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase 'entity'=>''); // Test URL + $result=''; if ($WS_METHOD) { $parameters = array('authentication'=>$authentication); - print __METHOD__."Call method ".$WS_METHOD."\n"; + print __METHOD__." call method ".$WS_METHOD."\n"; $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); if (! $result) { @@ -284,12 +284,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase print $soapclient->request; print "
\n\n"; print $soapclient->response; - exit; } - } - print __METHOD__." result=".$result."\n"; - //$this->assertEquals('OK',$result['result']['result_code']); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('OK',$result['result']['result_code']); + } return $result; } @@ -309,11 +308,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_user.php'; - $WS_METHOD = 'xxx'; + $WS_METHOD = ''; $ns='http://www.dolibarr.org/ns/'; // 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); if ($soapclient) { @@ -330,10 +329,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase 'entity'=>''); // Test URL + $result=''; if ($WS_METHOD) { $parameters = array('authentication'=>$authentication); - print __METHOD__."Call method ".$WS_METHOD."\n"; + print __METHOD__." call method ".$WS_METHOD."\n"; $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); if (! $result) { @@ -343,12 +343,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase print $soapclient->request; print "
\n\n"; print $soapclient->response; - exit; } - } - print __METHOD__." result=".$result."\n"; - //$this->assertEquals('OK',$result['result']['result_code']); + print __METHOD__." result=".$result."\n"; + //$this->assertEquals('OK',$result['result']['result_code']); + } return $result; } diff --git a/test/phpunit/WebservicesOtherTest.php b/test/phpunit/WebservicesOtherTest.php index e8a8a6bd19c..6d666118079 100755 --- a/test/phpunit/WebservicesOtherTest.php +++ b/test/phpunit/WebservicesOtherTest.php @@ -135,7 +135,7 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase $ns='http://www.dolibarr.org/ns/'; // 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); if ($soapclient) { @@ -152,10 +152,11 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase 'entity'=>''); // Test URL + $result=''; if ($WS_METHOD) { $parameters = array('authentication'=>$authentication); - print __METHOD__."Call method ".$WS_METHOD."\n"; + print __METHOD__." call method ".$WS_METHOD."\n"; $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); if (! $result) { @@ -165,12 +166,11 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase print $soapclient->request; print "
\n\n"; print $soapclient->response; - exit; } - } - print __METHOD__." result=".$result."\n"; - $this->assertEquals('OK',$result['result']['result_code']); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('OK',$result['result']['result_code']); + } return $result; } diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index 83c7c0ce14d..ed594735499 100755 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -131,11 +131,11 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php'; - $WS_METHOD = 'xxx'; + $WS_METHOD = ''; $ns='http://www.dolibarr.org/ns/'; // 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); if ($soapclient) { @@ -152,10 +152,11 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase 'entity'=>''); // Test URL + $result=''; if ($WS_METHOD) { $parameters = array('authentication'=>$authentication); - print __METHOD__."Call method ".$WS_METHOD."\n"; + print __METHOD__." call method ".$WS_METHOD."\n"; $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); if (! $result) { @@ -165,12 +166,11 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase print $soapclient->request; print "
\n\n"; print $soapclient->response; - exit; } - } - print __METHOD__." result=".$result."\n"; - //$this->assertEquals('OK',$result['result']['result_code']); + print __METHOD__." result=".$result."\n"; + //$this->assertEquals('OK',$result['result']['result_code']); + } return $result; }