mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
Merge branch 'MDL-46778-master' of git://github.com/odeialba/moodle
This commit is contained in:
commit
c467ce725e
7 changed files with 51 additions and 12 deletions
|
@ -203,13 +203,19 @@ class behat_command {
|
|||
// We only need to check this when the behat site is not running as
|
||||
// at this point, when it is running, all $CFG->behat_* vars have
|
||||
// already been copied to $CFG->dataroot, $CFG->prefix and $CFG->wwwroot.
|
||||
if (!defined('BEHAT_SITE_RUNNING') &&
|
||||
($CFG->behat_prefix == $CFG->prefix ||
|
||||
$CFG->behat_dataroot == $CFG->dataroot ||
|
||||
$CFG->behat_wwwroot == $CFG->wwwroot ||
|
||||
(!empty($CFG->phpunit_prefix) && $CFG->phpunit_prefix == $CFG->behat_prefix) ||
|
||||
(!empty($CFG->phpunit_dataroot) && $CFG->phpunit_dataroot == $CFG->behat_dataroot)
|
||||
)) {
|
||||
$phpunitprefix = empty($CFG->phpunit_prefix) ? '' : $CFG->phpunit_prefix;
|
||||
$behatdbname = empty($CFG->behat_dbname) ? $CFG->dbname : $CFG->behat_dbname;
|
||||
$phpunitdbname = empty($CFG->phpunit_dbname) ? $CFG->dbname : $CFG->phpunit_dbname;
|
||||
$behatdbhost = empty($CFG->behat_dbhost) ? $CFG->dbhost : $CFG->behat_dbhost;
|
||||
$phpunitdbhost = empty($CFG->phpunit_dbhost) ? $CFG->dbhost : $CFG->phpunit_dbhost;
|
||||
|
||||
$samedataroot = $CFG->behat_dataroot == $CFG->dataroot;
|
||||
$samedataroot = $samedataroot || (!empty($CFG->phpunit_dataroot) && $CFG->phpunit_dataroot == $CFG->behat_dataroot);
|
||||
$samewwwroot = $CFG->behat_wwwroot == $CFG->wwwroot;
|
||||
$sameprefix = ($CFG->behat_prefix == $CFG->prefix && $behatdbname == $CFG->dbname && $behatdbhost == $CFG->dbhost);
|
||||
$sameprefix = $sameprefix || ($CFG->behat_prefix == $phpunitprefix && $behatdbname == $phpunitdbname &&
|
||||
$behatdbhost == $phpunitdbhost);
|
||||
if (!defined('BEHAT_SITE_RUNNING') && ($samedataroot || $samewwwroot || $sameprefix)) {
|
||||
self::output_msg(get_string('erroruniqueconfig', 'tool_behat'));
|
||||
return BEHAT_EXITCODE_CONFIG;
|
||||
}
|
||||
|
|
|
@ -243,18 +243,31 @@ function behat_clean_init_config() {
|
|||
function behat_check_config_vars() {
|
||||
global $CFG;
|
||||
|
||||
$moodleprefix = empty($CFG->prefix) ? '' : $CFG->prefix;
|
||||
$behatprefix = empty($CFG->behat_prefix) ? '' : $CFG->behat_prefix;
|
||||
$phpunitprefix = empty($CFG->phpunit_prefix) ? '' : $CFG->phpunit_prefix;
|
||||
$behatdbname = empty($CFG->behat_dbname) ? $CFG->dbname : $CFG->behat_dbname;
|
||||
$phpunitdbname = empty($CFG->phpunit_dbname) ? $CFG->dbname : $CFG->phpunit_dbname;
|
||||
$behatdbhost = empty($CFG->behat_dbhost) ? $CFG->dbhost : $CFG->behat_dbhost;
|
||||
$phpunitdbhost = empty($CFG->phpunit_dbhost) ? $CFG->dbhost : $CFG->phpunit_dbhost;
|
||||
|
||||
// Verify prefix value.
|
||||
if (empty($CFG->behat_prefix)) {
|
||||
behat_error(BEHAT_EXITCODE_CONFIG,
|
||||
'Define $CFG->behat_prefix in config.php');
|
||||
}
|
||||
if (!empty($CFG->prefix) and $CFG->behat_prefix == $CFG->prefix) {
|
||||
if ($behatprefix == $moodleprefix && $behatdbname == $CFG->dbname && $behatdbhost == $CFG->dbhost) {
|
||||
behat_error(BEHAT_EXITCODE_CONFIG,
|
||||
'$CFG->behat_prefix in config.php must be different from $CFG->prefix');
|
||||
'$CFG->behat_prefix in config.php must be different from $CFG->prefix' .
|
||||
' when $CFG->behat_dbname and $CFG->behat_host are not set or when $CFG->behat_dbname equals $CFG->dbname' .
|
||||
' and $CFG->behat_dbhost equals $CFG->dbhost');
|
||||
}
|
||||
if (!empty($CFG->phpunit_prefix) and $CFG->behat_prefix == $CFG->phpunit_prefix) {
|
||||
if ($phpunitprefix !== '' && $behatprefix == $phpunitprefix && $behatdbname == $phpunitdbname &&
|
||||
$behatdbhost == $phpunitdbhost) {
|
||||
behat_error(BEHAT_EXITCODE_CONFIG,
|
||||
'$CFG->behat_prefix in config.php must be different from $CFG->phpunit_prefix');
|
||||
'$CFG->behat_prefix in config.php must be different from $CFG->phpunit_prefix' .
|
||||
' when $CFG->behat_dbname equals $CFG->phpunit_dbname' .
|
||||
' and $CFG->behat_dbhost equals $CFG->phpunit_dbhost');
|
||||
}
|
||||
|
||||
// Verify behat wwwroot value.
|
||||
|
|
|
@ -141,6 +141,16 @@ if (defined('BEHAT_SITE_RUNNING')) {
|
|||
$CFG->wwwroot = $CFG->behat_wwwroot;
|
||||
$CFG->prefix = $CFG->behat_prefix;
|
||||
$CFG->dataroot = $CFG->behat_dataroot;
|
||||
|
||||
// And we do the same with the optional ones.
|
||||
$allowedconfigoverride = ['dbname', 'dbuser', 'dbpass', 'dbhost'];
|
||||
foreach ($allowedconfigoverride as $config) {
|
||||
$behatconfig = 'behat_' . $config;
|
||||
if (!isset($CFG->$behatconfig)) {
|
||||
continue;
|
||||
}
|
||||
$CFG->$config = $CFG->$behatconfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue