MDL-43450 behat: Checking the ->behat_* vars contents before showing the steps list

This commit is contained in:
David Monllao
2014-01-29 14:28:37 +08:00
parent 7c4044a54f
commit 7e3f5e79d0
3 changed files with 19 additions and 1 deletions
+1
View File
@@ -28,6 +28,7 @@ $string['errorbehatcommand'] = 'Error running behat CLI command. Try running "{$
$string['errorcomposer'] = 'Composer dependencies are not installed.';
$string['errordataroot'] = '$CFG->behat_dataroot is not set or is invalid.';
$string['errorsetconfig'] = '$CFG->behat_dataroot, $CFG->behat_prefix and $CFG->behat_wwwroot need to be set in config.php.';
$string['erroruniqueconfig'] = '$CFG->behat_dataroot, $CFG->behat_prefix and $CFG->behat_wwwroot values need to be different than $CFG->dataroot, $CFG->prefix, $CFG->wwwroot, $CFG->phpunit_dataroot and $CFG->phpunit_prefix values.';
$string['giveninfo'] = 'Given. Processes to set up the environment';
$string['infoheading'] = 'Info';
$string['installinfo'] = 'Read {$a} for installation and tests execution info';
+1 -1
View File
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2013110501;
$plugin->version = 2014012900;
$plugin->requires = 2013110500; // Requires Moodle 2.5.
$plugin->component = 'tool_behat';
+17
View File
@@ -142,9 +142,26 @@ class behat_command {
return BEHAT_EXITCODE_COMPOSER;
}
// No empty values.
if (empty($CFG->behat_dataroot) || empty($CFG->behat_prefix) || empty($CFG->behat_wwwroot)) {
self::output_msg(get_string('errorsetconfig', 'tool_behat'));
return BEHAT_EXITCODE_CONFIG;
}
// Not repeated values.
// We only need to check this when the behat site is not running as
// at this point, when it is running, all $CFG->behat_* vars have
// already been copied to $CFG->dataroot, $CFG->prefix and $CFG->wwwroot.
if (!defined('BEHAT_SITE_RUNNING') &&
($CFG->behat_prefix == $CFG->prefix ||
$CFG->behat_dataroot == $CFG->dataroot ||
$CFG->behat_wwwroot == $CFG->wwwroot ||
(!empty($CFG->phpunit_prefix) && $CFG->phpunit_prefix == $CFG->behat_prefix) ||
(!empty($CFG->phpunit_dataroot) && $CFG->phpunit_dataroot == $CFG->behat_dataroot)
)) {
self::output_msg(get_string('erroruniqueconfig', 'tool_behat'));
return BEHAT_EXITCODE_CONFIG;
}
// Checking behat dataroot existence otherwise echo about admin/tool/behat/cli/init.php.