Skip to content

Commit

Permalink
MDL-37046 behat: Checking PHP version
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Jan 29, 2013
1 parent a09534f commit a2a9843
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions admin/tool/behat/lang/en/tool_behat.php
Expand Up @@ -40,4 +40,5 @@
$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';
11 changes: 8 additions & 3 deletions admin/tool/behat/locallib.php
Expand Up @@ -130,8 +130,8 @@ public static function switchenvironment($testenvironment = false) {
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();
Expand Down Expand Up @@ -323,10 +323,15 @@ private static function test_environment_problem() {
*
* 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')) {

Expand Down

0 comments on commit a2a9843

Please sign in to comment.