From 289f18919c415ac7ca387bde76fadc170670efb6 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 29 Aug 2012 20:00:28 +0200 Subject: [PATCH] make *ContentTest more robust against leaked state Change-Id: I10ac795443ca6b4c432d5fbd1836a7d80445516c --- tests/phpunit/includes/WikitextContentTest.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/includes/WikitextContentTest.php b/tests/phpunit/includes/WikitextContentTest.php index 449423b114..fd1f886ff7 100644 --- a/tests/phpunit/includes/WikitextContentTest.php +++ b/tests/phpunit/includes/WikitextContentTest.php @@ -6,8 +6,15 @@ class WikitextContentTest extends MediaWikiTestCase { public function setup() { + global $wgUser; + + // anon user + $wgUser = new User(); + $wgUser->setName( '127.0.0.1' ); + $this->context = new RequestContext( new FauxRequest() ); $this->context->setTitle( Title::newFromText( "Test" ) ); + $this->context->setUser( $wgUser ); } public function newContent( $text ) { @@ -191,8 +198,9 @@ just a test" * @dataProvider dataPreSaveTransform */ public function testPreSaveTransform( $text, $expected ) { - global $wgUser, $wgContLang; - $options = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang ); + global $wgContLang; + + $options = ParserOptions::newFromUserAndLang( $this->context->getUser(), $wgContLang ); $content = $this->newContent( $text ); $content = $content->preSaveTransform( $this->context->getTitle(), $this->context->getUser(), $options ); @@ -215,8 +223,8 @@ just a test" * @dataProvider dataPreloadTransform */ public function testPreloadTransform( $text, $expected ) { - global $wgUser, $wgContLang; - $options = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang ); + global $wgContLang; + $options = ParserOptions::newFromUserAndLang( $this->context->getUser(), $wgContLang ); $content = $this->newContent( $text ); $content = $content->preloadTransform( $this->context->getTitle(), $options ); -- 2.20.1