diff --git a/admin/tool/behat/lang/en/tool_behat.php b/admin/tool/behat/lang/en/tool_behat.php index d890976b99d..e5693d7f5e9 100644 --- a/admin/tool/behat/lang/en/tool_behat.php +++ b/admin/tool/behat/lang/en/tool_behat.php @@ -25,7 +25,7 @@ $string['allavailablesteps'] = 'All the available steps definitions'; $string['giveninfo'] = 'Given. Processes to set up the environment'; $string['installinfo'] = 'Read {$a} for installation and tests execution info'; -$string['moreinfoin'] = 'More info in'; +$string['moreinfoin'] = 'More info in {$a}'; $string['newstepsinfo'] = 'Read {$a} for info about how to add new steps definitions'; $string['newtestsinfo'] = 'Read {$a} for info about how to write new tests'; $string['nostepsdefinitions'] = 'There aren\'t steps definitions matching this filters'; diff --git a/lib/behat/classes/behat_command.php b/lib/behat/classes/behat_command.php index 5ef219936ec..39e8c259957 100644 --- a/lib/behat/classes/behat_command.php +++ b/lib/behat/classes/behat_command.php @@ -122,7 +122,7 @@ class behat_command { if (!CLI_SCRIPT) { $docslink = html_writer::tag('a', $docslink, array('href' => $docslink, 'target' => '_blank')); } - $msg .= '. ' . get_string('moreinfoin', 'tool_behat') . ' ' . $docslink; + $msg .= '. ' . get_string('moreinfoin', 'tool_behat', $docslink); notice($msg); } diff --git a/lib/behat/classes/util.php b/lib/behat/classes/util.php index 828f452c91a..5fe4aa3ff38 100644 --- a/lib/behat/classes/util.php +++ b/lib/behat/classes/util.php @@ -120,7 +120,11 @@ class behat_util extends testing_util { $request = new curl(); $request->get($CFG->behat_wwwroot); - return (true && !$request->get_errno()); + + if ($request->get_errno() === 0) { + return true; + } + return false; } /** diff --git a/lib/setup.php b/lib/setup.php index 9ceabedfa5f..ef0c38a5559 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -108,12 +108,17 @@ if (isset($CFG->behat_switchcompletely)) { // * User has previously enabled through admin/tool/behat/cli/util.php --enable. // Both are required to switch to test mode if (isset($CFG->behat_dataroot) && isset($CFG->behat_prefix) && file_exists($CFG->behat_dataroot)) { + $CFG->behat_dataroot = realpath($CFG->behat_dataroot); - $testenvironmentrequested = (isset($CFG->behat_switchcompletely) && php_sapi_name() !== 'cli') || - php_sapi_name() === 'cli-server' || - defined('BEHAT_RUNNING'); + + $switchcompletely = isset($CFG->behat_switchcompletely) && php_sapi_name() !== 'cli'; + $builtinserver = php_sapi_name() === 'cli-server'; + $behatrunning = defined('BEHAT_RUNNING'); + $testenvironmentrequested = $switchcompletely || $builtinserver || $behatrunning; + // Only switch to test environment if it has been enabled. $testenvironmentenabled = file_exists($CFG->behat_dataroot . '/behat/test_environment_enabled.txt'); + if ($testenvironmentenabled && $testenvironmentrequested) { $CFG->wwwroot = $CFG->behat_wwwroot; $CFG->passwordsaltmain = 'moodle';