From: daniel Date: Wed, 29 Aug 2012 18:00:28 +0000 (+0200) Subject: make *ContentTest more robust against leaked state X-Git-Tag: 1.31.0-rc.0~22097^2^2~34^2 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=289f18919c415ac7ca387bde76fadc170670efb6;p=lhc%2Fweb%2Fwiklou.git make *ContentTest more robust against leaked state Change-Id: I10ac795443ca6b4c432d5fbd1836a7d80445516c --- 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 );