MDL-54553 behat: check statuscode of http request

This commit is contained in:
Dan Poltawski 2016-05-12 13:26:07 +01:00
parent 33892edf18
commit 5c602bf5bb

View file

@ -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;