From 7e3f5e79d0108fe8e3444524a003bc75e6626d04 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Wed, 29 Jan 2014 14:28:37 +0800 Subject: [PATCH] MDL-43450 behat: Checking the ->behat_* vars contents before showing the steps list --- admin/tool/behat/lang/en/tool_behat.php | 1 + admin/tool/behat/version.php | 2 +- lib/behat/classes/behat_command.php | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/admin/tool/behat/lang/en/tool_behat.php b/admin/tool/behat/lang/en/tool_behat.php index 04e034c1b43..b07e92f69c6 100644 --- a/admin/tool/behat/lang/en/tool_behat.php +++ b/admin/tool/behat/lang/en/tool_behat.php @@ -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'; diff --git a/admin/tool/behat/version.php b/admin/tool/behat/version.php index 12b96cd0a88..223011a13be 100644 --- a/admin/tool/behat/version.php +++ b/admin/tool/behat/version.php @@ -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'; diff --git a/lib/behat/classes/behat_command.php b/lib/behat/classes/behat_command.php index 5013e39e7c8..a7060bd70d4 100644 --- a/lib/behat/classes/behat_command.php +++ b/lib/behat/classes/behat_command.php @@ -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. -- 2.43.0