forked from Wavyzz/dolibarr
Qual: Improve test messages to help locate errors + php-cs-fixer on tests (#28272)
* Qual: Apply php-cs-fixer before changes # Qual: Apply php-cs-fixer before changes Apply php-cs-fixer before changes to make real changes stand out in next commit. * Qual: Improve test messages to help locate errors. # Qual: Improve test messages to help locate errors. Included a description of the test in the failing assertions to help locate the error. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: Update spelling exception # Qual: Update spelling exception Formatting the code requires an update in the spelling exception list. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out.
This commit is contained in:
@@ -152,8 +152,8 @@
|
|||||||
$sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee";
|
$sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee";
|
||||||
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".$this->db->prefix()."links";
|
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".$this->db->prefix()."links";
|
||||||
$sql = 'SELECT c.rowid, date_creation as datec, tms as datem, date_valid as date_validation, date_approve as datea, date_approve2 as datea2,';
|
$sql = 'SELECT c.rowid, date_creation as datec, tms as datem, date_valid as date_validation, date_approve as datea, date_approve2 as datea2,';
|
||||||
$test = '/javas:cript/google.com';
|
|
||||||
$test = "<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same
|
$test = "<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same
|
||||||
|
$test = '/javas:cript/google.com';
|
||||||
$this->periode = $this->date_creation + 3600 * 24 * 30;
|
$this->periode = $this->date_creation + 3600 * 24 * 30;
|
||||||
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Referers');
|
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Referers');
|
||||||
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Referers');
|
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Referers');
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ class CMailFileTest extends CommonClassTest
|
|||||||
$this->assertEquals($result, 2);
|
$this->assertEquals($result, 2);
|
||||||
|
|
||||||
|
|
||||||
foreach ($localobject->html_images as $i => $val)
|
foreach ($localobject->html_images as $i => $val) {
|
||||||
if ($localobject->html_images[$i]) {
|
if ($localobject->html_images[$i]) {
|
||||||
if (preg_match('/img250x20\.png/i', $localobject->html_images[$i]['fullpath'])) {
|
if (preg_match('/img250x20\.png/i', $localobject->html_images[$i]['fullpath'])) {
|
||||||
print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n";
|
print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n";
|
||||||
@@ -187,6 +187,7 @@ class CMailFileTest extends CommonClassTest
|
|||||||
$this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize);
|
$this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
|
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
|
||||||
|
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -86,6 +87,7 @@ class RestAPIUserTest extends CommonClassTest
|
|||||||
|
|
||||||
$this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php';
|
$this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php';
|
||||||
|
|
||||||
|
$test = "API Test Setup - ";
|
||||||
$login = 'admin';
|
$login = 'admin';
|
||||||
$password = 'admin';
|
$password = 'admin';
|
||||||
$url = $this->api_url.'/login?login='.$login.'&password='.$password;
|
$url = $this->api_url.'/login?login='.$login.'&password='.$password;
|
||||||
@@ -94,11 +96,11 @@ class RestAPIUserTest extends CommonClassTest
|
|||||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||||
print __METHOD__." result = ".var_export($result, true)."\n";
|
print __METHOD__." result = ".var_export($result, true)."\n";
|
||||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||||
$this->assertEquals($result['curl_error_no'], '');
|
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||||
$object = json_decode($result['content'], true); // If success content is just an id, if not an array
|
$object = json_decode($result['content'], true); // If success content is just an id, if not an array
|
||||||
|
|
||||||
$this->assertNotNull($object, "Parsing of json result must not be null");
|
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||||
$this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
$this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), "$test Error".(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||||
$this->assertEquals('200', $object['success']['code']);
|
$this->assertEquals('200', $object['success']['code']);
|
||||||
|
|
||||||
$this->api_key = $object['success']['token'];
|
$this->api_key = $object['success']['token'];
|
||||||
@@ -116,6 +118,7 @@ class RestAPIUserTest extends CommonClassTest
|
|||||||
{
|
{
|
||||||
global $conf,$user,$langs,$db;
|
global $conf,$user,$langs,$db;
|
||||||
|
|
||||||
|
$test = "Invalid User -";
|
||||||
$url = $this->api_url.'/users/123456789?api_key='.$this->api_key;
|
$url = $this->api_url.'/users/123456789?api_key='.$this->api_key;
|
||||||
//$addheaders=array('Content-Type: application/json');
|
//$addheaders=array('Content-Type: application/json');
|
||||||
|
|
||||||
@@ -123,20 +126,21 @@ class RestAPIUserTest extends CommonClassTest
|
|||||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||||
//print __METHOD__." result for get on unexisting user: ".var_export($result, true)."\n";
|
//print __METHOD__." result for get on unexisting user: ".var_export($result, true)."\n";
|
||||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||||
$this->assertEquals($result['curl_error_no'], '');
|
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||||
$object = json_decode($result['content'], true);
|
$object = json_decode($result['content'], true);
|
||||||
$this->assertNotNull($object, "Parsing of json result must not be null");
|
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||||
$this->assertEquals(404, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error code is not 404');
|
$this->assertEquals(404, (empty($object['error']['code']) ? 0 : $object['error']['code']), "$test Error code is not 404");
|
||||||
|
|
||||||
|
$test = "Existing User -";
|
||||||
$url = $this->api_url.'/users/1?api_key='.$this->api_key;
|
$url = $this->api_url.'/users/1?api_key='.$this->api_key;
|
||||||
|
|
||||||
print __METHOD__." Request GET url=".$url."\n";
|
print __METHOD__." Request GET url=".$url."\n";
|
||||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||||
print __METHOD__." result for get on an existing user: ".var_export($result, true)."\n";
|
print __METHOD__." $test result for get: ".var_export($result, true)."\n";
|
||||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||||
$this->assertEquals($result['curl_error_no'], '');
|
$this->assertEquals('', $result['curl_error_no'], "$test should have no error");
|
||||||
$object = json_decode($result['content'], true);
|
$object = json_decode($result['content'], true);
|
||||||
$this->assertNotNull($object, "Parsing of json result must not be null");
|
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||||
$this->assertEquals(1, $object['statut']);
|
$this->assertEquals(1, $object['statut']);
|
||||||
|
|
||||||
return $object['id'];
|
return $object['id'];
|
||||||
@@ -153,6 +157,7 @@ class RestAPIUserTest extends CommonClassTest
|
|||||||
public function testRestCreateUser()
|
public function testRestCreateUser()
|
||||||
{
|
{
|
||||||
// attempt to create without mandatory fields :
|
// attempt to create without mandatory fields :
|
||||||
|
$test = "Create User Missing Fields -";
|
||||||
$url = $this->api_url.'/users?api_key='.$this->api_key;
|
$url = $this->api_url.'/users?api_key='.$this->api_key;
|
||||||
$addheaders = array('Content-Type: application/json');
|
$addheaders = array('Content-Type: application/json');
|
||||||
|
|
||||||
@@ -167,12 +172,13 @@ class RestAPIUserTest extends CommonClassTest
|
|||||||
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||||
//print __METHOD__." Result for creating incomplete user".var_export($result, true)."\n";
|
//print __METHOD__." Result for creating incomplete user".var_export($result, true)."\n";
|
||||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||||
$this->assertEquals($result['curl_error_no'], '');
|
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||||
$object = json_decode($result['content'], true);
|
$object = json_decode($result['content'], true);
|
||||||
$this->assertNotNull($object, "Parsing of json result must no be null");
|
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||||
$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), "$test Error".(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||||
|
|
||||||
// create regular user
|
// create regular user
|
||||||
|
$test = "Create Regular User -";
|
||||||
unset($result);
|
unset($result);
|
||||||
$bodyobj = array(
|
$bodyobj = array(
|
||||||
"login" => "testRestLogin".mt_rand(),
|
"login" => "testRestLogin".mt_rand(),
|
||||||
@@ -185,21 +191,22 @@ class RestAPIUserTest extends CommonClassTest
|
|||||||
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||||
print __METHOD__." result code for creating non existing user = ".var_export($result, true)."\n";
|
print __METHOD__." result code for creating non existing user = ".var_export($result, true)."\n";
|
||||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||||
$this->assertEquals($result['curl_error_no'], '');
|
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||||
$object = json_decode($result['content'], true); // If success content is just an id, if not an array
|
$object = json_decode($result['content'], true); // If success content is just an id, if not an array
|
||||||
|
|
||||||
$this->assertNotNull($object, "Parsing of json result must no be null");
|
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||||
$this->assertNotEquals(500, ((is_scalar($object) || empty($object['error']) || empty($object['error']['code'])) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
$this->assertNotEquals(500, ((is_scalar($object) || empty($object['error']) || empty($object['error']['code'])) ? 0 : $object['error']['code']), "$test Error".(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||||
$this->assertGreaterThan(0, $object, 'ID returned is no > 0');
|
$this->assertGreaterThan(0, $object, 'ID returned is no > 0');
|
||||||
|
|
||||||
// attempt to create duplicated user
|
// attempt to create duplicated user
|
||||||
|
$test = "Create Duplicate User -";
|
||||||
print __METHOD__." Request POST url=".$url."\n";
|
print __METHOD__." Request POST url=".$url."\n";
|
||||||
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||||
//print __METHOD__." Result for creating duplicate user".var_export($result, true)."\n";
|
//print __METHOD__." Result for creating duplicate user".var_export($result, true)."\n";
|
||||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||||
$this->assertEquals($result['curl_error_no'], '');
|
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||||
$object = json_decode($result['content'], true);
|
$object = json_decode($result['content'], true);
|
||||||
$this->assertNotNull($object, "Parsing of json result must no be null");
|
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||||
$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), "$test Error".(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user