diff --git a/lib/behat/classes/util.php b/lib/behat/classes/util.php index ae33d94f07f..3ebe647917b 100644 --- a/lib/behat/classes/util.php +++ b/lib/behat/classes/util.php @@ -151,9 +151,10 @@ class behat_util extends testing_util { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); + $statuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 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 ' . '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. - $result = json_decode($result, true); $clienv = self::get_environment(); if ($result != $clienv) { $output = 'Differences detected between cli and webserver...'.PHP_EOL;