mirror of
https://github.com/moodle/moodle.git
synced 2025-08-03 16:13:28 +02:00
MDL-54553 behat: check statuscode of http request
This commit is contained in:
parent
33892edf18
commit
5c602bf5bb
1 changed files with 2 additions and 2 deletions
|
@ -151,9 +151,10 @@ class behat_util extends testing_util {
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
|
$statuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
if (empty($result)) {
|
if ($statuscode !== 200 || empty($result) || (!$result = json_decode($result, true))) {
|
||||||
|
|
||||||
behat_error (BEHAT_EXITCODE_REQUIREMENT, $CFG->behat_wwwroot . ' is not available, ensure you specified ' .
|
behat_error (BEHAT_EXITCODE_REQUIREMENT, $CFG->behat_wwwroot . ' is not available, ensure you specified ' .
|
||||||
'correct url and that the server is set up and started.' . PHP_EOL . ' More info in ' .
|
'correct url and that the server is set up and started.' . PHP_EOL . ' More info in ' .
|
||||||
|
@ -161,7 +162,6 @@ class behat_util extends testing_util {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if cli version is same as web version.
|
// Check if cli version is same as web version.
|
||||||
$result = json_decode($result, true);
|
|
||||||
$clienv = self::get_environment();
|
$clienv = self::get_environment();
|
||||||
if ($result != $clienv) {
|
if ($result != $clienv) {
|
||||||
$output = 'Differences detected between cli and webserver...'.PHP_EOL;
|
$output = 'Differences detected between cli and webserver...'.PHP_EOL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue