mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-15 14:01:22 +01:00
Fix travis
This commit is contained in:
@@ -190,7 +190,7 @@ if (GETPOST('target') == 'remote') {
|
||||
$xmlarray = getURLContent($xmlremote, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only. Same is used into api_setup.class.php.
|
||||
|
||||
// Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
|
||||
if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') {
|
||||
if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != 400 && $xmlarray['http_code'] != 404) {
|
||||
$xmlfile = $xmlarray['content'];
|
||||
//print "xmlfilestart".$xmlfile."xmlfileend";
|
||||
if (LIBXML_VERSION < 20900) {
|
||||
|
||||
@@ -339,7 +339,7 @@ class Ai
|
||||
'error' => true,
|
||||
'message' => $errormessage,
|
||||
'code' => (empty($response['http_code']) ? 0 : $response['http_code']),
|
||||
'curl_error_no' => (!empty($response['curl_error_no']) ? $response['curl_error_no'] : ''),
|
||||
'curl_error_no' => (empty($response['curl_error_no']) ? 0 : $response['curl_error_no']),
|
||||
'format' => $format,
|
||||
'service' => $this->apiService,
|
||||
'function' => $function
|
||||
|
||||
@@ -2555,7 +2555,7 @@ class Setup extends DolibarrApi
|
||||
$xmlarray = getURLContent($xmlremote, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only. Same is used into filecheck.php.
|
||||
|
||||
// Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
|
||||
if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') {
|
||||
if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != 400 && $xmlarray['http_code'] != 404) {
|
||||
$xmlfile = $xmlarray['content'];
|
||||
//print "xmlfilestart".$xmlfile."endxmlfile";
|
||||
$xml = simplexml_load_string($xmlfile, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NONET);
|
||||
|
||||
@@ -540,10 +540,10 @@ class PartnershipUtils
|
||||
|
||||
// $website = 'https://nextgestion.com/'; // For Test
|
||||
$tmpgeturl = getURLContent($website, 'GET', '', 1, array(), array('http', 'https'), 0);
|
||||
if ($tmpgeturl['curl_error_no']) {
|
||||
if (!empty($tmpgeturl['curl_error_no'])) {
|
||||
$error++;
|
||||
dol_syslog('Error getting '.$website.': '.$tmpgeturl['curl_error_msg']);
|
||||
} elseif ($tmpgeturl['http_code'] != '200') {
|
||||
} elseif ($tmpgeturl['http_code'] != 200) {
|
||||
$error++;
|
||||
dol_syslog('Error getting '.$website.': '.$tmpgeturl['curl_error_msg']);
|
||||
} else {
|
||||
|
||||
@@ -865,11 +865,11 @@ if ($action == 'addcontainer' && $usercanedit) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($tmp['curl_error_no']) {
|
||||
if (!empty($tmp['curl_error_no'])) {
|
||||
$error++;
|
||||
setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors');
|
||||
$action = 'createcontainer';
|
||||
} elseif ($tmp['http_code'] != '200') {
|
||||
} elseif ($tmp['http_code'] != 200) {
|
||||
$error++;
|
||||
setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors');
|
||||
$action = 'createcontainer';
|
||||
@@ -989,14 +989,14 @@ if ($action == 'addcontainer' && $usercanedit) {
|
||||
|
||||
/*
|
||||
$tmpgeturl = getURLContent($urltograbbis, 'GET', '', 1, array(), array('http', 'https'), 0);
|
||||
if ($tmpgeturl['curl_error_no'])
|
||||
if (!empty($tmpgeturl['curl_error_no']))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Error getting script url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
|
||||
$errorforsubresource++;
|
||||
$action='createcontainer';
|
||||
}
|
||||
elseif ($tmpgeturl['http_code'] != '200')
|
||||
elseif ($tmpgeturl['http_code'] != 200)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Error getting script url '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
|
||||
@@ -1053,12 +1053,12 @@ if ($action == 'addcontainer' && $usercanedit) {
|
||||
}
|
||||
|
||||
$tmpgeturl = getURLContent($urltograbbis, 'GET', '', 1, array(), array('http', 'https'), 0);
|
||||
if ($tmpgeturl['curl_error_no']) {
|
||||
if (!empty($tmpgeturl['curl_error_no'])) {
|
||||
$errorforsubresource++;
|
||||
setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
|
||||
dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']);
|
||||
$action = 'createcontainer';
|
||||
} elseif ($tmpgeturl['http_code'] != '200') {
|
||||
} elseif ($tmpgeturl['http_code'] != 200) {
|
||||
$errorforsubresource++;
|
||||
setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
|
||||
dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']);
|
||||
|
||||
@@ -94,7 +94,7 @@ abstract class AbstractRestAPITest extends CommonClassTest
|
||||
$result = getURLContent($url, 'GET', '', 1, $addheaders, array('http', 'https'), 2);
|
||||
print "$method result = ".var_export($result, true)."\n";
|
||||
print "$method curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$this->assertEquals(0, $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
|
||||
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
|
||||
@@ -55,7 +55,7 @@ class RestAPIContactTest extends AbstractRestAPITest
|
||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
print __METHOD__." result for get on unexisting contact: ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$this->assertEquals(0, $result['curl_error_no']);
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "Parsing of json result must not be null");
|
||||
$this->assertEquals(404, $object['error']['code'], 'Error code is not 404');
|
||||
@@ -67,7 +67,7 @@ class RestAPIContactTest extends AbstractRestAPITest
|
||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
print __METHOD__." result for get on an existing contact: ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$this->assertEquals(0, $result['curl_error_no']);
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "Parsing of json result must not be null");
|
||||
$this->assertEquals(1, $object['statut']);
|
||||
@@ -98,7 +98,7 @@ class RestAPIContactTest extends AbstractRestAPITest
|
||||
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
//print __METHOD__." Result for creating incomplete contact".var_export($result, true)."\n";
|
||||
//print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$this->assertEquals(0, $result['curl_error_no']);
|
||||
$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->assertEquals(400, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||
@@ -119,7 +119,7 @@ class RestAPIContactTest extends AbstractRestAPITest
|
||||
|
||||
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$this->assertEquals(0, $result['curl_error_no']);
|
||||
|
||||
$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");
|
||||
|
||||
@@ -80,7 +80,7 @@ class RestAPIDocumentTest extends AbstractRestAPITest
|
||||
echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n";
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, 'Parsing of json result must not be null');
|
||||
$this->assertEquals('400', $result['http_code'], 'Test to push a document on a non existing dir does not return 400');
|
||||
$this->assertEquals(400, $result['http_code'], 'Test to push a document on a non existing dir does not return 400');
|
||||
$this->assertEquals('400', (empty($object['error']['code']) ? '' : $object['error']['code']), 'Test to push a document on a non existing dir does not return 400');
|
||||
|
||||
|
||||
|
||||
@@ -73,18 +73,18 @@ class RestAPIMosTest extends AbstractRestAPITest
|
||||
|
||||
$result = getURLContent($url, $method, $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
|
||||
$this->assertEquals('', $result['curl_error_no'], "{$test_title}Should not have a curl error");
|
||||
$this->assertEquals(0, $result['curl_error_no'], $test_title." Should not have a curl error");
|
||||
|
||||
$object = json_decode($result['content'], true);
|
||||
|
||||
$dbg_info = PHP_EOL.json_encode($result, JSON_PRETTY_PRINT);
|
||||
|
||||
$this->assertNotNull($object, "{$test_title}Parsing of JSON result must not be null$dbg_info");
|
||||
$this->assertNotNull($object, $test_title." Parsing of JSON result must not be null ".$dbg_info);
|
||||
|
||||
$result['content'] = $object;
|
||||
$dbg_info = PHP_EOL.json_encode($result, JSON_PRETTY_PRINT);
|
||||
|
||||
$this->assertEquals($expected_error, (empty($object['error']['code']) ? 0 : $object['error']['code']), "{$test_title}Error code is not $expected_error$dbg_info");
|
||||
$this->assertEquals($expected_error, (empty($object['error']['code']) ? 0 : $object['error']['code']), $test_title." Error code is not ".$expected_error.$dbg_info);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
/* Copyright (C) 2010-2025 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -46,8 +46,6 @@ class RestAPIUserTest extends AbstractRestAPITest
|
||||
*/
|
||||
public function testRestGetUser()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
$test = "Invalid User -";
|
||||
$url = $this->api_url.'/users/123456789?api_key='.$this->api_key;
|
||||
//$addheaders=array('Content-Type: application/json');
|
||||
@@ -56,7 +54,7 @@ class RestAPIUserTest extends AbstractRestAPITest
|
||||
$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__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$this->assertEquals(0, $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
$this->assertEquals(404, (empty($object['error']['code']) ? 0 : $object['error']['code']), "$test Error code is not 404");
|
||||
@@ -68,7 +66,7 @@ class RestAPIUserTest extends AbstractRestAPITest
|
||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
print __METHOD__." $test result for get: ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test should have no error");
|
||||
$this->assertEquals(0, $result['curl_error_no'], "$test should have no error");
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
$this->assertEquals(1, $object['statut']);
|
||||
@@ -102,7 +100,7 @@ class RestAPIUserTest extends AbstractRestAPITest
|
||||
$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__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$this->assertEquals(0, $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), "$test Error".(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||
@@ -121,7 +119,7 @@ class RestAPIUserTest extends AbstractRestAPITest
|
||||
$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__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$this->assertEquals(0, $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
|
||||
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
@@ -134,7 +132,7 @@ class RestAPIUserTest extends AbstractRestAPITest
|
||||
$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__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$this->assertEquals(0, $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
$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