From a2a9843819fc4689e5e9407f5dc44e2e5e9e150d Mon Sep 17 00:00:00 2001 From: David Monllao Date: Tue, 11 Dec 2012 13:31:42 +0800 Subject: [PATCH] MDL-37046 behat: Checking PHP version --- admin/tool/behat/lang/en/tool_behat.php | 1 + admin/tool/behat/locallib.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/admin/tool/behat/lang/en/tool_behat.php b/admin/tool/behat/lang/en/tool_behat.php index 3d732f9c6d5..a584a2573b4 100644 --- a/admin/tool/behat/lang/en/tool_behat.php +++ b/admin/tool/behat/lang/en/tool_behat.php @@ -40,4 +40,5 @@ $string['stepsdefinitionstype'] = 'Type'; $string['theninfo'] = 'Then. Checkings to ensure the outcomes are the expected ones'; $string['viewsteps'] = 'Filter'; $string['wheninfo'] = 'When. Actions that provokes an event'; +$string['wrongphpversion'] = 'PHP 5.4.0 or higher is required to run acceptance tests'; $string['wrongbehatsetup'] = 'Something is wrong with the setup, ensure you ran the composer installer and /lib/behat/bin/behat file has execution permissions'; diff --git a/admin/tool/behat/locallib.php b/admin/tool/behat/locallib.php index f784b3b44a3..2a91297a8d6 100644 --- a/admin/tool/behat/locallib.php +++ b/admin/tool/behat/locallib.php @@ -130,8 +130,8 @@ class tool_behat { public static function runtests($withjavascript = false, $tags = false, $extra = '') { global $CFG; - // Checks that the behat reference is properly set up. - self::check_behat_setup(); + // Checks the behat set up and the PHP version. + self::check_behat_setup(true); // Check that PHPUnit test environment is correctly set up. self::test_environment_problem(); @@ -323,10 +323,15 @@ class tool_behat { * * It checks behat dependencies have been installed and runs * the behat help command to ensure it works as expected + * @param boolean $checkphp Extra check for the PHP version */ - private static function check_behat_setup() { + private static function check_behat_setup($checkphp = false) { global $CFG; + if ($checkphp && version_compare(PHP_VERSION, '5.4.0', '<')) { + throw new Exception(get_string('wrongphpversion', 'tool_behat')); + } + // Moodle setting. if (!is_dir($vendor = __DIR__ . '/../../../vendor/behat')) {