forked from Wavyzz/dolibarr
Merge branch '4.0' of git@github.com:Dolibarr/dolibarr.git into 5.0
Conflicts: test/phpunit/PricesTest.php test/phpunit/RestAPIUserTest.php test/phpunit/WebservicesInvoicesTest.php
This commit is contained in:
@@ -64,7 +64,9 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
parent::__construct();
|
||||
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
@@ -106,7 +108,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
|
||||
$this->api_url=DOL_MAIN_URL_ROOT.'/api/index.php';
|
||||
|
||||
$login='admin';
|
||||
@@ -158,7 +160,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase
|
||||
$object=json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "Parsing of json result must no be null");
|
||||
$this->assertEquals(404, $object['error']['code']);
|
||||
|
||||
|
||||
$url = $this->api_url.'/users/1?api_key='.$this->api_key;
|
||||
|
||||
print __METHOD__." Request GET url=".$url."\n";
|
||||
@@ -172,11 +174,11 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
public function testRestCreateUser() {
|
||||
|
||||
|
||||
// attemp to create without mandatory fields :
|
||||
$url = $this->api_url.'/users?api_key='.$this->api_key;
|
||||
$addheaders=array('Content-Type: application/json');
|
||||
|
||||
|
||||
$bodyobj = array(
|
||||
"lastname"=>"testRestUser",
|
||||
"password"=>"testRestPassword",
|
||||
@@ -210,14 +212,14 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase
|
||||
$resid=json_decode($result['content'], true);
|
||||
$this->assertNotNull($resid, "Parsing of json result must no be null");
|
||||
$this->assertGreaterThan(0, $resid, $object['error']['code'].' '.$object['error']['message']);
|
||||
|
||||
|
||||
// attempt to create duplicated user
|
||||
print __METHOD__." Request POST url=".$url."\n";
|
||||
$result=getURLContent($url, 'POST', $body, 1, $addheaders);
|
||||
//print __METHOD__." Result for creating duplicate user".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'],'');
|
||||
$object=json_decode($result['content'], true);
|
||||
$object=json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "Parsing of json result must no be null");
|
||||
$this->assertEquals(500, $object['error']['code'], $object['error']['code'].' '.$object['error']['message']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user