Skip to content

Commit

Permalink
MDL-54553 behat: check statuscode of http request
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed May 18, 2016
1 parent f38e287 commit 114c691
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/behat/classes/util.php
Expand Up @@ -151,17 +151,17 @@ public static function check_server_status() {
$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 ' .
behat_command::DOCS_URL . '#Running_tests' . PHP_EOL); behat_command::DOCS_URL . '#Running_tests' . PHP_EOL);
} }


// 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;
Expand Down

0 comments on commit 114c691

Please sign in to comment.