$_SESSION['USER']->mnethostid = 1;
}
- if (PHPUNIT_TEST) {
- // Phpunit tests use reversed reference.
+ if (PHPUNIT_TEST or defined('BEHAT_TEST')) {
+ // Phpunit tests and behat init use reversed reference,
+ // the reason is we can not point global to $_SESSION outside of global scope.
global $USER, $SESSION;
$USER = $_SESSION['USER'];
$SESSION = $_SESSION['SESSION'];
}
sesskey(); // Init session key.
- if (PHPUNIT_TEST) {
- // Phpunit tests use reversed reference.
+ if (PHPUNIT_TEST or defined('BEHAT_TEST')) {
+ // Phpunit tests and behat init use reversed reference,
+ // the reason is we can not point global to $_SESSION outside of global scope.
global $USER;
$USER = $_SESSION['USER'];
$_SESSION['USER'] =& $USER;
$CFG->sessiontimeout = 7200;
}
\core\session\manager::start();
-$SESSION = &$_SESSION['SESSION'];
-$USER = &$_SESSION['USER'];
+if (!PHPUNIT_TEST and !defined('BEHAT_TEST')) {
+ $SESSION =& $_SESSION['SESSION'];
+ $USER =& $_SESSION['USER'];
+}
// Late profiling, only happening if early one wasn't started
if (!empty($CFG->profilingenabled)) {
behat_selectors::register_moodle_selectors($session);
}
- // Avoid some notices / warnings.
+ // Reset $SESSION.
+ $_SESSION = array();
$SESSION = new stdClass();
+ $_SESSION['SESSION'] =& $SESSION;
behat_util::reset_database();
behat_util::reset_dataroot();
// Reset the nasty strings list used during the last test.
nasty_strings::reset_used_strings();
- // Assing valid data to admin user (some generator-related code needs a valid user).
+ // Assign valid data to admin user (some generator-related code needs a valid user).
$user = $DB->get_record('user', array('username' => 'admin'));
\core\session\manager::set_user($user);