MDL-37046 behat: Checking PHP version

This commit is contained in:
David Monllao 2012-12-11 13:31:42 +08:00
parent a09534f4fc
commit a2a9843819
2 changed files with 9 additions and 3 deletions

View File

@ -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';

View File

@ -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')) {