From: Alexandre Emsenhuber Date: Thu, 10 Nov 2011 12:49:10 +0000 (+0000) Subject: Made setupGlobals() return the created context and use it instead of either global... X-Git-Tag: 1.31.0-rc.0~26594 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=6efba66c0478e8a7b3dc73e6b59a769ca939b8d8;p=lhc%2Fweb%2Fwiklou.git Made setupGlobals() return the created context and use it instead of either global variables or recreating more instance of those classes --- diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index 694b7e20dd..af0d4bf4bd 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -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; } /** diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index e23bad7b2f..b255bf0079 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -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'] ) );