Permalink
Browse files

Merge branch 'MDL-39441_master' of git://github.com/dmonllao/moodle

  • Loading branch information...
danpoltawski committed Jul 22, 2013
2 parents 7bdae09 + 401f60d commit 51425cc045664b71fbaeb21b2ed75535c98b5fee
Showing with 44 additions and 0 deletions.
  1. +3 −0 admin/tool/behat/cli/util.php
  2. +5 −0 config-dist.php
  3. +32 −0 lib/behat/lib.php
  4. +4 −0 lib/setup.php
@@ -143,6 +143,9 @@
$CFG->{$var} = $CFG->{'behat_' . $var};
}
// Clean $CFG extra values before performing any action.
behat_clean_init_config();
$CFG->noemailever = true;
$CFG->passwordsaltmain = 'moodle';
View
@@ -631,6 +631,11 @@
// Example:
// $CFG->behat_restart_browser_after = 7200; // Restarts the browser session after 2 hours
//
// All this page's extra Moodle settings are compared against a white list of allowed settings
// (the basic and behat_* ones) to avoid problems with production environments. This setting can be
// used to expand the default white list with an array of extra settings.
// Example:
// $CFG->behat_extraallowedsettings = array('logsql', 'dblogerror');
//=========================================================================
// ALL DONE! To continue installation, visit your main page with a browser
View
@@ -141,3 +141,35 @@ function behat_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
// Also use the internal error handler so we keep the usual behaviour.
return false;
}
/**
* Restrict the config.php settings allowed.
*
* When running the behat features the config.php
* settings should not affect the results.
*
* @return void
*/
function behat_clean_init_config() {
global $CFG;
$allowed = array_flip(array(
'wwwroot', 'dataroot', 'dirroot', 'admin', 'directorypermissions', 'filepermissions',
'dbtype', 'dblibrary', 'dbhost', 'dbname', 'dbuser', 'dbpass', 'prefix', 'dboptions',
'proxyhost', 'proxyport', 'proxytype', 'proxyuser', 'proxypassword', 'proxybypass',
'theme'
));
// Add extra allowed settings.
if (!empty($CFG->behat_extraallowedsettings)) {
$allowed = array_merge($allowed, array_flip($CFG->behat_extraallowedsettings));
}
// Also allowing behat_ prefixed attributes.
foreach ($CFG as $key => $value) {
if (!isset($allowed[$key]) && strpos($key, 'behat_') !== 0) {
unset($CFG->{$key});
}
}
}
View
@@ -131,6 +131,10 @@
// actions like reset the site or use data generators.
define('BEHAT_SITE_RUNNING', true);
// Clean extra config.php settings.
require_once(__DIR__ . '/../lib/behat/lib.php');
behat_clean_init_config();
$CFG->wwwroot = $CFG->behat_wwwroot;
$CFG->passwordsaltmain = 'moodle';
$CFG->prefix = $CFG->behat_prefix;

0 comments on commit 51425cc

Please sign in to comment.