From 96fad3ea99d94395cb5e5517d4ebd3d525990ef5 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Thu, 26 Oct 2023 19:55:00 +0000 Subject: [PATCH] tests: Use $this->getServiceContainer() Use $this->getServiceContainer() instead of MediaWikiServices::getInstance() in tests. Change-Id: I5e56524b85ba6e34cecffba2f24fb44b3f66ec8f --- tests/phpunit/CiteCSSFileModuleTest.php | 3 +-- tests/phpunit/CiteDbTest.php | 3 +-- tests/phpunit/CiteHooksTest.php | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/CiteCSSFileModuleTest.php b/tests/phpunit/CiteCSSFileModuleTest.php index e2bd6a2bd..7192fa760 100644 --- a/tests/phpunit/CiteCSSFileModuleTest.php +++ b/tests/phpunit/CiteCSSFileModuleTest.php @@ -3,7 +3,6 @@ namespace Cite\Tests; use Cite\ResourceLoader\CiteCSSFileModule; -use MediaWiki\MediaWikiServices; use MediaWiki\ResourceLoader\Context; /** @@ -18,7 +17,7 @@ class CiteCSSFileModuleTest extends \MediaWikiIntegrationTestCase { $this->setService( 'ContentLanguage', - MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'fa' ) + $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'fa' ) ); } diff --git a/tests/phpunit/CiteDbTest.php b/tests/phpunit/CiteDbTest.php index 8cb93bc56..e15c4c432 100644 --- a/tests/phpunit/CiteDbTest.php +++ b/tests/phpunit/CiteDbTest.php @@ -2,7 +2,6 @@ namespace Cite\Tests; -use MediaWiki\MediaWikiServices; use MediaWiki\Title\Title; use ParserOptions; @@ -23,7 +22,7 @@ class CiteDbTest extends \MediaWikiIntegrationTestCase { public function testReferenceStackError() { $this->insertPage( 'Cite-tracking-category-cite-error', '{{PAGENAME}}', NS_MEDIAWIKI ); - $services = MediaWikiServices::getInstance(); + $services = $this->getServiceContainer(); // Reset the MessageCache in order to force it to clone a new parser. $services->resetServiceForTesting( 'MessageCache' ); $services->getMessageCache()->enable(); diff --git a/tests/phpunit/CiteHooksTest.php b/tests/phpunit/CiteHooksTest.php index 9786b2845..486f4e3f9 100644 --- a/tests/phpunit/CiteHooksTest.php +++ b/tests/phpunit/CiteHooksTest.php @@ -4,7 +4,6 @@ namespace Cite\Tests; use ApiQuerySiteinfo; use Cite\Hooks\CiteHooks; -use MediaWiki\MediaWikiServices; use MediaWiki\User\StaticUserOptionsLookup; /** @@ -20,7 +19,7 @@ class CiteHooksTest extends \MediaWikiIntegrationTestCase { public function testOnResourceLoaderGetConfigVars() { $vars = []; - $config = MediaWikiServices::getInstance()->getMainConfig(); + $config = $this->getServiceContainer()->getMainConfig(); $citeHooks = new CiteHooks( new StaticUserOptionsLookup( [] ) ); $citeHooks->onResourceLoaderGetConfigVars( $vars, 'vector', $config ); @@ -36,7 +35,7 @@ class CiteHooksTest extends \MediaWikiIntegrationTestCase { $api = $this->createMock( ApiQuerySiteinfo::class ); $api->expects( $this->once() ) ->method( 'getConfig' ) - ->willReturn( MediaWikiServices::getInstance()->getMainConfig() ); + ->willReturn( $this->getServiceContainer()->getMainConfig() ); $data = [];