From 19f96604615eae49f9ce050a830c355c245e58b0 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Tue, 5 Feb 2019 04:52:00 +0100 Subject: [PATCH] ApiQuerySiteinfoTest: Conversion of $wgContLang to service Bug: T200246 Change-Id: Ibdf07adc7a4cf28f0f9f48f18985651a379bc10c --- .../includes/api/ApiQuerySiteinfoTest.php | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/phpunit/includes/api/ApiQuerySiteinfoTest.php b/tests/phpunit/includes/api/ApiQuerySiteinfoTest.php index 225c19537b..d3a4ed4406 100644 --- a/tests/phpunit/includes/api/ApiQuerySiteinfoTest.php +++ b/tests/phpunit/includes/api/ApiQuerySiteinfoTest.php @@ -40,36 +40,34 @@ class ApiQuerySiteinfoTest extends ApiTestCase { } public function testLinkPrefixCharset() { - global $wgContLang; - - $this->setContentLang( 'ar' ); - $this->assertTrue( $wgContLang->linkPrefixExtension(), 'Sanity check' ); + $contLang = Language::factory( 'ar' ); + $this->setContentLang( $contLang ); + $this->assertTrue( $contLang->linkPrefixExtension(), 'Sanity check' ); $data = $this->doQuery(); - $this->assertSame( $wgContLang->linkPrefixCharset(), $data['linkprefixcharset'] ); + $this->assertSame( $contLang->linkPrefixCharset(), $data['linkprefixcharset'] ); } public function testVariants() { - global $wgContLang; - - $this->setContentLang( 'zh' ); - $this->assertTrue( $wgContLang->hasVariants(), 'Sanity check' ); + $contLang = Language::factory( 'zh' ); + $this->setContentLang( $contLang ); + $this->assertTrue( $contLang->hasVariants(), 'Sanity check' ); $data = $this->doQuery(); $expected = array_map( - function ( $code ) use ( $wgContLang ) { - return [ 'code' => $code, 'name' => $wgContLang->getVariantname( $code ) ]; + function ( $code ) use ( $contLang ) { + return [ 'code' => $code, 'name' => $contLang->getVariantname( $code ) ]; }, - $wgContLang->getVariants() + $contLang->getVariants() ); $this->assertSame( $expected, $data['variants'] ); } public function testReadOnly() { - $svc = \MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode(); + $svc = MediaWikiServices::getInstance()->getReadOnlyMode(); $svc->setReason( 'Need more donations' ); try { $data = $this->doQuery(); @@ -82,18 +80,21 @@ class ApiQuerySiteinfoTest extends ApiTestCase { } public function testNamespaces() { - global $wgContLang; - $this->setMwGlobals( 'wgExtraNamespaces', [ '138' => 'Testing' ] ); - $this->assertSame( array_keys( $wgContLang->getFormattedNamespaces() ), - array_keys( $this->doQuery( 'namespaces' ) ) ); + $this->assertSame( + array_keys( MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces() ), + array_keys( $this->doQuery( 'namespaces' ) ) + ); } public function testNamespaceAliases() { - global $wgNamespaceAliases, $wgContLang; + global $wgNamespaceAliases; - $expected = array_merge( $wgNamespaceAliases, $wgContLang->getNamespaceAliases() ); + $expected = array_merge( + $wgNamespaceAliases, + MediaWikiServices::getInstance()->getContentLanguage()->getNamespaceAliases() + ); $expected = array_map( function ( $key, $val ) { return [ 'id' => $val, 'alias' => strtr( $key, '_', ' ' ) ]; @@ -116,10 +117,8 @@ class ApiQuerySiteinfoTest extends ApiTestCase { } public function testMagicWords() { - global $wgContLang; - $this->assertCount( - count( $wgContLang->getMagicWords() ), + count( MediaWikiServices::getInstance()->getContentLanguage()->getMagicWords() ), $this->doQuery( 'magicwords' ) ); } -- 2.20.1