r102648 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102647‎ | r102648 | r102649 >
Date:12:49, 10 November 2011
Author:ialex
Status:ok
Tags:
Comment:
Made setupGlobals() return the created context and use it instead of either global variables or recreating more instance of those classes
Modified paths:
  • /trunk/phase3/tests/parser/parserTest.inc (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
@@ -313,6 +313,7 @@
314314
315315 $GLOBALS['wgMemc'] = new EmptyBagOStuff;
316316 $GLOBALS['wgOut'] = $context->getOutput();
 317+ $GLOBALS['wgUser'] = $context->getUser();
317318
318319 global $wgHooks;
319320
@@ -328,8 +329,7 @@
329330 RepoGroup::destroySingleton();
330331 MessageCache::singleton()->destroyInstance();
331332
332 - global $wgUser;
333 - $wgUser = new User();
 333+ return $context;
334334 }
335335
336336 /**
@@ -471,10 +471,10 @@
472472 wfDebug( "Running parser test: $desc\n" );
473473
474474 $opts = $this->parseOptions( $opts );
475 - $this->setupGlobals( $opts, $config );
 475+ $context = $this->setupGlobals( $opts, $config );
476476
477 - $user = new User();
478 - $options = ParserOptions::newFromUser( $user );
 477+ $user = $context->getUser();
 478+ $options = ParserOptions::newFromContext( $context );
479479
480480 if ( isset( $opts['title'] ) ) {
481481 $titleText = $opts['title'];
@@ -519,11 +519,10 @@
520520 if ( isset( $opts['ill'] ) ) {
521521 $out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) );
522522 } elseif ( isset( $opts['cat'] ) ) {
523 - global $wgOut;
 523+ $outputPage = $context->getOutput();
 524+ $outputPage->addCategoryLinks( $output->getCategories() );
 525+ $cats = $outputPage->getCategoryLinks();
524526
525 - $wgOut->addCategoryLinks( $output->getCategories() );
526 - $cats = $wgOut->getCategoryLinks();
527 -
528527 if ( isset( $cats['normal'] ) ) {
529528 $out = $this->tidy( implode( ' ', $cats['normal'] ) );
530529 } else {
Index: trunk/phase3/tests/parser/parserTest.inc
@@ -435,10 +435,10 @@
436436 }
437437
438438 $opts = $this->parseOptions( $opts );
439 - $this->setupGlobals( $opts, $config );
 439+ $context = $this->setupGlobals( $opts, $config );
440440
441 - $user = new User();
442 - $options = ParserOptions::newFromUser( $user );
 441+ $user = $context->getUser();
 442+ $options = ParserOptions::newFromContext( $context );
443443
444444 if ( isset( $opts['title'] ) ) {
445445 $titleText = $opts['title'];
@@ -482,11 +482,10 @@
483483 if ( isset( $opts['ill'] ) ) {
484484 $out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) );
485485 } elseif ( isset( $opts['cat'] ) ) {
486 - global $wgOut;
 486+ $outputPage = $context->getOutput();
 487+ $outputPage->addCategoryLinks( $output->getCategories() );
 488+ $cats = $outputPage->getCategoryLinks();
487489
488 - $wgOut->addCategoryLinks( $output->getCategories() );
489 - $cats = $wgOut->getCategoryLinks();
490 -
491490 if ( isset( $cats['normal'] ) ) {
492491 $out = $this->tidy( implode( ' ', $cats['normal'] ) );
493492 } else {
@@ -704,6 +703,8 @@
705704 $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
706705
707706 MagicWord::clearCache();
 707+
 708+ return $context;
708709 }
709710
710711 /**

Status & tagging log