jenkins-bot has submitted this change and it was merged.

Change subject: Don't use wgLang to override the request language
......................................................................


Don't use wgLang to override the request language

Instead use MediaWikiTestCase::setUserLang or
MediaWikiLangTestCase as appropriate.

Bug: T129185
Change-Id: I097f973235a22befa1ad41a266817d6802600011
---
M client/tests/phpunit/includes/Api/PageTermsTest.php
M client/tests/phpunit/includes/Hooks/DeletePageNoticeCreatorTest.php
M client/tests/phpunit/includes/Hooks/MovePageNoticeTest.php
M client/tests/phpunit/includes/RecentChanges/ChangeLineFormatterTest.php
M repo/tests/phpunit/includes/Actions/ActionTestCase.php
M repo/tests/phpunit/includes/Actions/ViewEntityActionTest.php
M repo/tests/phpunit/includes/ItemDisambiguationTest.php
M view/tests/phpunit/EntityTermsViewTest.php
M view/tests/phpunit/SiteLinksViewTest.php
M view/tests/phpunit/StatementSectionsViewTest.php
10 files changed, 13 insertions(+), 38 deletions(-)

Approvals:
  Krinkle: Looks good to me, but someone else must approve
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/client/tests/phpunit/includes/Api/PageTermsTest.php 
b/client/tests/phpunit/includes/Api/PageTermsTest.php
index 575f7fe..ecddfce 100644
--- a/client/tests/phpunit/includes/Api/PageTermsTest.php
+++ b/client/tests/phpunit/includes/Api/PageTermsTest.php
@@ -6,7 +6,7 @@
 use ApiPageSet;
 use ApiQuery;
 use FauxRequest;
-use Language;
+use MediaWikiLangTestCase;
 use RequestContext;
 use Title;
 use Wikibase\Client\Api\PageTerms;
@@ -28,14 +28,7 @@
  * @license GPL-2.0+
  * @author Daniel Kinzler
  */
-class PageTermsTest extends \MediaWikiTestCase {
-
-       protected function setUp() {
-               parent::setUp();
-
-               $this->setMwGlobals( 'wgLang', Language::factory( 'en' ) );
-               $this->setMwGlobals( 'wgContLang', Language::factory( 'en' ) );
-       }
+class PageTermsTest extends MediaWikiLangTestCase {
 
        /**
         * @param array $params
diff --git 
a/client/tests/phpunit/includes/Hooks/DeletePageNoticeCreatorTest.php 
b/client/tests/phpunit/includes/Hooks/DeletePageNoticeCreatorTest.php
index c6c9d25..5db2f56 100644
--- a/client/tests/phpunit/includes/Hooks/DeletePageNoticeCreatorTest.php
+++ b/client/tests/phpunit/includes/Hooks/DeletePageNoticeCreatorTest.php
@@ -24,9 +24,7 @@
        protected function setUp() {
                parent::setUp();
 
-               $this->setMwGlobals( array(
-                       'wgLang' => Language::factory( 'de' )
-               ) );
+               $this->setUserLang( 'de' );
        }
 
        protected function getRepoLinker() {
diff --git a/client/tests/phpunit/includes/Hooks/MovePageNoticeTest.php 
b/client/tests/phpunit/includes/Hooks/MovePageNoticeTest.php
index 7baea7a..772066a 100644
--- a/client/tests/phpunit/includes/Hooks/MovePageNoticeTest.php
+++ b/client/tests/phpunit/includes/Hooks/MovePageNoticeTest.php
@@ -28,9 +28,7 @@
        protected function setUp() {
                parent::setUp();
 
-               $this->setMwGlobals( array(
-                       'wgLang' => Language::factory( 'de' )
-               ) );
+               $this->setUserLang( 'de' );
        }
 
        protected function getRepoLinker() {
diff --git 
a/client/tests/phpunit/includes/RecentChanges/ChangeLineFormatterTest.php 
b/client/tests/phpunit/includes/RecentChanges/ChangeLineFormatterTest.php
index 12cf257..0c959e9 100644
--- a/client/tests/phpunit/includes/RecentChanges/ChangeLineFormatterTest.php
+++ b/client/tests/phpunit/includes/RecentChanges/ChangeLineFormatterTest.php
@@ -37,7 +37,6 @@
                // these are required because Linker is used in 
ChangeLineFormatter
                // @todo eliminate Linker or at least use of Linker in Wikibase 
:)
                $this->setMwGlobals( array(
-                       'wgLang' => Language::factory( 'en' ),
                        'wgScriptPath' => '',
                        'wgScript' => '/index.php',
                        'wgArticlePath' => '/wiki/$1'
diff --git a/repo/tests/phpunit/includes/Actions/ActionTestCase.php 
b/repo/tests/phpunit/includes/Actions/ActionTestCase.php
index ca9180e..6d4e945 100644
--- a/repo/tests/phpunit/includes/Actions/ActionTestCase.php
+++ b/repo/tests/phpunit/includes/Actions/ActionTestCase.php
@@ -33,14 +33,6 @@
 
        private $permissionsChanged = false;
 
-       /**
-        * The language to set as the user language.
-        * 'qqx' is used per default to allow matching against message keys in 
the output.
-        *
-        * @var string
-        */
-       protected $languageCode = 'qqx';
-
        protected function setUp() {
                parent::setUp();
 
@@ -50,11 +42,12 @@
 
                $this->setMwGlobals( array(
                        'wgUser' => $user,
-                       'wgLang' => Language::factory( $this->languageCode ),
                        'wgRequest' => new FauxRequest(),
                        'wgGroupPermissions' => array( '*' => array( 'edit' => 
true, 'read' => true ) )
                ) );
 
+               $this->setUserLang( 'qqx' );
+
                ApiQueryInfo::resetTokenCache();
        }
 
diff --git a/repo/tests/phpunit/includes/Actions/ViewEntityActionTest.php 
b/repo/tests/phpunit/includes/Actions/ViewEntityActionTest.php
index d356210..2797c44 100644
--- a/repo/tests/phpunit/includes/Actions/ViewEntityActionTest.php
+++ b/repo/tests/phpunit/includes/Actions/ViewEntityActionTest.php
@@ -23,13 +23,13 @@
 class ViewEntityActionTest extends ActionTestCase {
 
        protected function setUp() {
+               parent::setUp();
+
                // NOTE: use a language here for which we actually have labels 
etc
-               $this->languageCode = 'de';
+               $this->setUserLang( 'de' );
 
                // Remove handlers for the "OutputPageParserOutput" hook
                $this->mergeMwGlobalArrayValue( 'wgHooks', array( 
'OutputPageParserOutput' => array() ) );
-
-               parent::setUp();
        }
 
        public function testActionForPage() {
diff --git a/repo/tests/phpunit/includes/ItemDisambiguationTest.php 
b/repo/tests/phpunit/includes/ItemDisambiguationTest.php
index 01d9f09..befa0b6 100644
--- a/repo/tests/phpunit/includes/ItemDisambiguationTest.php
+++ b/repo/tests/phpunit/includes/ItemDisambiguationTest.php
@@ -26,9 +26,7 @@
        protected function setUp() {
                parent::setUp();
 
-               $this->setMwGlobals( array(
-                       'wgLang' => Language::factory( 'qqx' ),
-               ) );
+               $this->setUserLang( 'qqx' );
        }
 
        /**
diff --git a/view/tests/phpunit/EntityTermsViewTest.php 
b/view/tests/phpunit/EntityTermsViewTest.php
index f3f6b2a..fb619b4 100644
--- a/view/tests/phpunit/EntityTermsViewTest.php
+++ b/view/tests/phpunit/EntityTermsViewTest.php
@@ -244,7 +244,7 @@
 
        public function testGetEntityTermsForLanguageListView_isEscaped() {
                MessageCache::singleton()->enable();
-               $this->setMwGlobals( 'wgLang', Language::factory( 'en' ) );
+               $this->setUserLang( 'en' );
                $this->insertPage( 
'MediaWiki:wikibase-entitytermsforlanguagelistview-language', "''RAW''" );
 
                $view = $this->getEntityTermsView();
diff --git a/view/tests/phpunit/SiteLinksViewTest.php 
b/view/tests/phpunit/SiteLinksViewTest.php
index b531651..00966de 100644
--- a/view/tests/phpunit/SiteLinksViewTest.php
+++ b/view/tests/phpunit/SiteLinksViewTest.php
@@ -36,9 +36,7 @@
        protected function setUp() {
                parent::setUp();
 
-               $this->setMwGlobals( array(
-                       'wgLang' => Language::factory( 'qqx' ),
-               ) );
+               $this->setUserLang( 'qqx' );
        }
 
        public function testNoGroups() {
diff --git a/view/tests/phpunit/StatementSectionsViewTest.php 
b/view/tests/phpunit/StatementSectionsViewTest.php
index 0e9f70c..973ae79 100644
--- a/view/tests/phpunit/StatementSectionsViewTest.php
+++ b/view/tests/phpunit/StatementSectionsViewTest.php
@@ -30,9 +30,7 @@
        protected function setUp() {
                parent::setUp();
 
-               $this->setMwGlobals( array(
-                       'wgLang' => Language::factory( 'qqx' ),
-               ) );
+               $this->setUserLang( 'qqx' );
        }
 
        private function newInstance( array $statementLists = array() ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/276757
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I097f973235a22befa1ad41a266817d6802600011
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to