MDL-52502 behat: Ensure php web and cli version is same

This commit is contained in:
Rajesh Taneja
2016-04-05 11:47:32 +08:00
parent dfb103a7c1
commit f7e66c022e
5 changed files with 113 additions and 26 deletions
+46 -13
View File
@@ -778,34 +778,28 @@ abstract class testing_util {
* @return string The site info
*/
public static function get_site_info() {
global $CFG, $DB;
global $CFG;
$output = '';
// All developers have to understand English, do not localise!
$env = self::get_environment();
$release = null;
require("$CFG->dirroot/version.php");
$output .= "Moodle $release";
$output .= "Moodle ".$env['moodleversion'];
if ($hash = self::get_git_hash()) {
$output .= ", $hash";
}
$output .= "\n";
// Add php version.
$phpversion = phpversion();
$output .= "Php: ". $phpversion;
require_once($CFG->libdir.'/environmentlib.php');
$output .= "Php: ". normalize_version($env['phpversion']);
// Add database type and version.
$dbtype = $DB->get_dbvendor();
$dbinfo = $DB->get_server_info();
$dbversion = $dbinfo['version'];
$output .= ", " . ucfirst($dbtype) . ": " . $dbversion;
$output .= ", " . $env['dbtype'] . ": " . $env['dbversion'];
// OS details.
$osdetails = php_uname('s') . " " . php_uname('r') . " " . php_uname('m');
$output .= ", OS: " . $osdetails . "\n";
$output .= ", OS: " . $env['os'] . "\n";
return $output;
}
@@ -989,4 +983,43 @@ abstract class testing_util {
fclose($fp);
}
}
/**
* Return list of environment versions on which tests will run.
* Environment includes:
* - moodleversion
* - phpversion
* - dbtype
* - dbversion
* - os
*
* @return array
*/
public static function get_environment() {
global $CFG, $DB;
$env = array();
// Add moodle version.
$release = null;
require("$CFG->dirroot/version.php");
$env['moodleversion'] = $release;
// Add php version.
$phpversion = phpversion();
$env['phpversion'] = $phpversion;
// Add database type and version.
$dbtype = $DB->get_dbvendor();
$dbinfo = $DB->get_server_info();
$dbversion = $dbinfo['version'];
$env['dbtype'] = ucfirst($dbtype);
$env['dbversion'] = $dbversion;
// OS details.
$osdetails = php_uname('s') . " " . php_uname('r') . " " . php_uname('m');
$env['os'] = $osdetails;
return $env;
}
}