protected $reuseDB = false;
protected $tablesUsed = array(); // tables with data
+ protected $restoreGlobals = array( // global variables to restore for each test
+ 'wgLang',
+ 'wgContLang',
+ 'wgLanguageCode',
+ 'wgUser',
+ 'wgTitle',
+ );
+
+ private $savedGlobals = array();
+
private static $dbSetup = false;
/**
return $fname;
}
- protected function tearDown() {
+ protected function setup() {
+ parent::setup();
+
+ foreach ( $this->restoreGlobals as $var ) {
+ $v = $GLOBALS[ $var ];
+
+ if ( is_object( $v ) || is_array( $v ) ) {
+ $v = clone $v;
+ }
+
+ $this->savedGlobals[ $var ] = $v;
+ }
+ }
+
+ protected function teardown() {
// Cleaning up temporary files
foreach ( $this->tmpfiles as $fname ) {
if ( is_file( $fname ) || ( is_link( $fname ) ) ) {
}
}
- parent::tearDown();
+ // restore saved globals
+ foreach ( $this->savedGlobals as $k => $v ) {
+ $GLOBALS[ $k ] = $v;
+ }
+
+ parent::teardown();
}
function dbPrefix() {