From b831d47925e1c7c761bac010e79a6a54bb09fdc4 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Thu, 31 Jan 2013 16:47:41 +0800 Subject: [PATCH] MDL-37768 behat: Checking test site version before running tests --- lib/testing/classes/util.php | 2 +- lib/tests/behat/behat_hooks.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/testing/classes/util.php b/lib/testing/classes/util.php index 9cce441df13..bbd9e1726a4 100644 --- a/lib/testing/classes/util.php +++ b/lib/testing/classes/util.php @@ -123,7 +123,7 @@ abstract class testing_util { * * @return bool */ - protected static function is_test_data_updated() { + public static function is_test_data_updated() { global $CFG; $framework = self::get_framework(); diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index c92e13847f3..e91b9e07d03 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -74,6 +74,7 @@ class behat_hooks extends behat_base { define('BEHAT_RUNNING', 1); define('CLI_SCRIPT', 1); + // With BEHAT_RUNNING we will be using $CFG->behat_* instead of $CFG->dataroot, $CFG->prefix and $CFG->wwwroot. require_once(__DIR__ . '/../../../config.php'); // Now that we are MOODLE_INTERNAL. @@ -93,6 +94,11 @@ class behat_hooks extends behat_base { throw new Exception($CFG->behat_wwwroot . ' is not available, ensure you started your PHP built-in server. More info in ' . behat_command::DOCS_URL . '#Running_tests'); } + // Prevents using outdated data, upgrade script would start and tests would fail. + if (!behat_util::is_test_data_updated()) { + $commandpath = 'php admin/tool/behat/cli/util.php'; + throw new Exception('Your behat test site is outdated, please run ' . $commandpath . ' from your moodle dirroot to drop and install the behat test site again.'); + } // Avoid parallel tests execution, it continues when the previous lock is released. test_lock::acquire('behat'); }