tests: Use $this->getServiceContainer()

Use
	$this->getServiceContainer()
instead of
	MediaWikiServices::getInstance()
in tests.

Change-Id: I5e56524b85ba6e34cecffba2f24fb44b3f66ec8f
This commit is contained in:
Fomafix 2023-10-26 19:55:00 +00:00 committed by Jforrester
parent bac8c8af79
commit 96fad3ea99
3 changed files with 4 additions and 7 deletions

View file

@ -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' )
);
}

View file

@ -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();

View file

@ -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 = [];