From 2a29335af94cb3d4fa4d4e342867ccf1625c7278 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 8 Feb 2013 18:57:16 +0100 Subject: [PATCH] apitests leaks wgUser 1) ParserTests::testParserTest with data set #468 ('pre-save transform: Signature expansion', '* ~~~ * ~~~ * ~~~ * ~~~', '* [[Special:Contributions/127.0.0.1|127.0.0.1]] * [[Special:Contributions/127.0.0.1|127.0.0.1]] * [[Special:Contributions/127.0.0.1|127.0.0.1]] * [[Special:Contributions/127.0.0.1|127.0.0.1]]', 'pst', '') pre-save transform: Signature expansion Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'* [[Special:Contributions/127.0.0.1|127.0.0.1]] -* [[Special:Contributions/127.0.0.1|127.0.0.1]] -* [[Special:Contributions/127.0.0.1|127.0.0.1]] -* [[Special:Contributions/127.0.0.1|127.0.0.1]]' +'* [[User:Apitestsysop|Apitestsysop]] ([[User talk:Apitestsysop|talk]]) +* [[User:Apitestsysop|Apitestsysop]] ([[User talk:Apitestsysop|talk]]) +* [[User:Apitestsysop|Apitestsysop]] ([[User talk:Apitestsysop|talk]]) +* [[User:Apitestsysop|Apitestsysop]] ([[User talk:Apitestsysop|talk]])' Change-Id: Ia72f9242deb5c6109d38b56dd46ef92fa6386278 --- tests/phpunit/includes/api/ApiTestCase.php | 14 +++++++------- tests/phpunit/includes/api/ApiUploadTest.php | 12 +++++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index d152b1b834..4e3f6e5f51 100644 --- a/tests/phpunit/includes/api/ApiTestCase.php +++ b/tests/phpunit/includes/api/ApiTestCase.php @@ -9,14 +9,10 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { protected $apiContext; protected function setUp() { - global $wgContLang, $wgAuth, $wgMemc, $wgRequest, $wgUser, $wgServer; + global $wgServer; parent::setUp(); self::$apiUrl = $wgServer . wfScript( 'api' ); - $wgMemc = new EmptyBagOStuff(); - $wgContLang = Language::factory( 'en' ); - $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' ); - $wgRequest = new FauxRequest( array() ); ApiQueryInfo::resetTokenCache(); // tokens are invalid because we cleared the session @@ -35,10 +31,14 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { ) ); - $wgUser = self::$users['sysop']->user; + $this->setMwGlobals( array( + 'wgMemc' => new EmptyBagOStuff(), + 'wgAuth' => new StubObject( 'wgAuth', 'AuthPlugin' ), + 'wgRequest' => new FauxRequest( array() ), + 'wgUser' => self::$users['sysop']->user, + ) ); $this->apiContext = new ApiTestContext(); - } /** diff --git a/tests/phpunit/includes/api/ApiUploadTest.php b/tests/phpunit/includes/api/ApiUploadTest.php index 642fed05aa..89c0c0038b 100644 --- a/tests/phpunit/includes/api/ApiUploadTest.php +++ b/tests/phpunit/includes/api/ApiUploadTest.php @@ -349,8 +349,9 @@ class ApiUploadTest extends ApiTestCaseUpload { * @depends testLogin */ public function testUploadStash( $session ) { - global $wgUser; - $wgUser = self::$users['uploader']->user; // @todo FIXME: still used somewhere + $this->setMwGlobals( array( + 'wgUser' => self::$users['uploader']->user, // @todo FIXME: still used somewhere + ) ); $extension = 'png'; $mimeType = 'image/png'; @@ -433,9 +434,10 @@ class ApiUploadTest extends ApiTestCaseUpload { * @depends testLogin */ public function testUploadChunks( $session ) { - global $wgUser; - $wgUser = self::$users['uploader']->user; // @todo FIXME: still used somewhere - + $this->setMwGlobals( array( + 'wgUser' => self::$users['uploader']->user, // @todo FIXME: still used somewhere + ) ); + $chunkSize = 1048576; // Download a large image file // ( using RandomImageGenerator for large files is not stable ) -- 2.20.1