Made setupGlobals() return the created context and use it instead of either global...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Thu, 10 Nov 2011 12:49:10 +0000 (12:49 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Thu, 10 Nov 2011 12:49:10 +0000 (12:49 +0000)
tests/parser/parserTest.inc
tests/phpunit/includes/parser/NewParserTest.php

index 694b7e2..af0d4bf 100644 (file)
@@ -435,10 +435,10 @@ class ParserTest {
                }
 
                $opts = $this->parseOptions( $opts );
-               $this->setupGlobals( $opts, $config );
+               $context = $this->setupGlobals( $opts, $config );
 
-               $user = new User();
-               $options = ParserOptions::newFromUser( $user );
+               $user = $context->getUser();
+               $options = ParserOptions::newFromContext( $context );
 
                if ( isset( $opts['title'] ) ) {
                        $titleText = $opts['title'];
@@ -482,10 +482,9 @@ class ParserTest {
                        if ( isset( $opts['ill'] ) ) {
                                $out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) );
                        } elseif ( isset( $opts['cat'] ) ) {
-                               global $wgOut;
-
-                               $wgOut->addCategoryLinks( $output->getCategories() );
-                               $cats = $wgOut->getCategoryLinks();
+                               $outputPage = $context->getOutput();
+                               $outputPage->addCategoryLinks( $output->getCategories() );
+                               $cats = $outputPage->getCategoryLinks();
 
                                if ( isset( $cats['normal'] ) ) {
                                        $out = $this->tidy( implode( ' ', $cats['normal'] ) );
@@ -704,6 +703,8 @@ class ParserTest {
                $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
 
                MagicWord::clearCache();
+
+               return $context;
        }
 
        /**
index e23bad7..b255bf0 100644 (file)
@@ -313,6 +313,7 @@ class NewParserTest extends MediaWikiTestCase {
 
                $GLOBALS['wgMemc'] = new EmptyBagOStuff;
                $GLOBALS['wgOut'] = $context->getOutput();
+               $GLOBALS['wgUser'] = $context->getUser();
 
                global $wgHooks;
 
@@ -328,8 +329,7 @@ class NewParserTest extends MediaWikiTestCase {
                RepoGroup::destroySingleton();
                MessageCache::singleton()->destroyInstance();
 
-               global $wgUser;
-               $wgUser = new User();
+               return $context;
        }
 
        /**
@@ -471,10 +471,10 @@ class NewParserTest extends MediaWikiTestCase {
                wfDebug( "Running parser test: $desc\n" );
 
                $opts = $this->parseOptions( $opts );
-               $this->setupGlobals( $opts, $config );
+               $context = $this->setupGlobals( $opts, $config );
 
-               $user = new User();
-               $options = ParserOptions::newFromUser( $user );
+               $user = $context->getUser();
+               $options = ParserOptions::newFromContext( $context );
 
                if ( isset( $opts['title'] ) ) {
                        $titleText = $opts['title'];
@@ -519,10 +519,9 @@ class NewParserTest extends MediaWikiTestCase {
                        if ( isset( $opts['ill'] ) ) {
                                $out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) );
                        } elseif ( isset( $opts['cat'] ) ) {
-                               global $wgOut;
-
-                               $wgOut->addCategoryLinks( $output->getCategories() );
-                               $cats = $wgOut->getCategoryLinks();
+                               $outputPage = $context->getOutput();
+                               $outputPage->addCategoryLinks( $output->getCategories() );
+                               $cats = $outputPage->getCategoryLinks();
 
                                if ( isset( $cats['normal'] ) ) {
                                        $out = $this->tidy( implode( ' ', $cats['normal'] ) );