Skip to content

Commit

Permalink
MDL-52981 Unit tests: Reset global after test
Browse files Browse the repository at this point in the history
  • Loading branch information
sammarshallou committed Feb 3, 2016
1 parent c9d91bb commit 6bd871d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/phpunit/classes/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static function initialise_cfg() {
* @return void
*/
public static function reset_all_data($detectchanges = false) {
global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION;
global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION, $FULLME;

// Stop any message redirection.
self::stop_message_redirection();
Expand Down Expand Up @@ -164,6 +164,10 @@ public static function reset_all_data($detectchanges = false) {
$warnings[] = 'Warning: unexpected change of $COURSE';
}

if ($FULLME !== self::get_global_backup('FULLME')) {
$warnings[] = 'Warning: unexpected change of $FULLME';
}

if (setlocale(LC_TIME, 0) !== $localename) {
$warnings[] = 'Warning: unexpected change of locale';
}
Expand All @@ -184,6 +188,7 @@ public static function reset_all_data($detectchanges = false) {
$_SERVER = self::get_global_backup('_SERVER');
$CFG = self::get_global_backup('CFG');
$SITE = self::get_global_backup('SITE');
$FULLME = self::get_global_backup('FULLME');
$_GET = array();
$_POST = array();
$_FILES = array();
Expand Down Expand Up @@ -299,13 +304,14 @@ public static function reset_database() {
* @return void
*/
public static function bootstrap_init() {
global $CFG, $SITE, $DB;
global $CFG, $SITE, $DB, $FULLME;

// backup the globals
self::$globals['_SERVER'] = $_SERVER;
self::$globals['CFG'] = clone($CFG);
self::$globals['SITE'] = clone($SITE);
self::$globals['DB'] = $DB;
self::$globals['FULLME'] = $FULLME;

// refresh data in all tables, clear caches, etc.
self::reset_all_data();
Expand Down

0 comments on commit 6bd871d

Please sign in to comment.