aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/api')
-rw-r--r--tests/phpunit/includes/api/ApiBaseTest.php8
-rw-r--r--tests/phpunit/includes/api/ApiBlockInfoTraitTest.php3
-rw-r--r--tests/phpunit/includes/api/ApiBlockTest.php5
-rw-r--r--tests/phpunit/includes/api/ApiClearHasMsgTest.php4
-rw-r--r--tests/phpunit/includes/api/ApiComparePagesTest.php3
-rw-r--r--tests/phpunit/includes/api/ApiEditPageTest.php11
-rw-r--r--tests/phpunit/includes/api/ApiErrorFormatterTest.php11
-rw-r--r--tests/phpunit/includes/api/ApiLoginTest.php3
-rw-r--r--tests/phpunit/includes/api/ApiMoveTest.php7
-rw-r--r--tests/phpunit/includes/api/ApiPageSetTest.php3
-rw-r--r--tests/phpunit/includes/api/ApiResultTest.php4
-rw-r--r--tests/phpunit/includes/api/ApiRevisionDeleteTest.php3
-rw-r--r--tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php4
-rw-r--r--tests/phpunit/includes/api/ApiStashEditTest.php21
-rw-r--r--tests/phpunit/includes/api/ApiUnblockTest.php7
-rw-r--r--tests/phpunit/includes/api/ApiUploadTestCase.php8
-rw-r--r--tests/phpunit/includes/api/ApiUserrightsTest.php5
-rw-r--r--tests/phpunit/includes/api/ApiWatchTest.php3
-rw-r--r--tests/phpunit/includes/api/Validator/ApiParamValidatorTest.php3
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryBlocksTest.php7
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryInfoTest.php3
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryRecentChangesIntegrationTest.php5
-rw-r--r--tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php35
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryWatchlistIntegrationTest.php11
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryWatchlistRawIntegrationTest.php4
25 files changed, 76 insertions, 105 deletions
diff --git a/tests/phpunit/includes/api/ApiBaseTest.php b/tests/phpunit/includes/api/ApiBaseTest.php
index e7cf45c88f99..c334fcfea288 100644
--- a/tests/phpunit/includes/api/ApiBaseTest.php
+++ b/tests/phpunit/includes/api/ApiBaseTest.php
@@ -1341,10 +1341,10 @@ class ApiBaseTest extends ApiTestCase {
'reason' => __METHOD__,
'expiry' => time() + 100500,
] );
- MediaWikiServices::getInstance()->getDatabaseBlockStore()->insertBlock( $block );
+ $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block );
$mockTrait = $this->getMockForTrait( ApiBlockInfoTrait::class );
- $language = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );
+ $language = $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'en' );
$mockTrait->method( 'getLanguage' )->willReturn( $language );
$userInfoTrait = TestingAccessWrapper::newFromObject( $mockTrait );
$blockinfo = [ 'blockinfo' => $userInfoTrait->getBlockDetails( $block ) ];
@@ -1401,10 +1401,10 @@ class ApiBaseTest extends ApiTestCase {
'reason' => __METHOD__,
'expiry' => time() + 100500,
] );
- MediaWikiServices::getInstance()->getDatabaseBlockStore()->insertBlock( $block );
+ $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block );
$mockTrait = $this->getMockForTrait( ApiBlockInfoTrait::class );
- $language = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );
+ $language = $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'en' );
$mockTrait->method( 'getLanguage' )->willReturn( $language );
$userInfoTrait = TestingAccessWrapper::newFromObject( $mockTrait );
$blockinfo = [ 'blockinfo' => $userInfoTrait->getBlockDetails( $block ) ];
diff --git a/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php b/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php
index 70c4e9a196ab..d2e573683051 100644
--- a/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php
+++ b/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php
@@ -2,7 +2,6 @@
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Block\SystemBlock;
-use MediaWiki\MediaWikiServices;
use Wikimedia\TestingAccessWrapper;
/**
@@ -13,7 +12,7 @@ class ApiBlockInfoTraitTest extends MediaWikiIntegrationTestCase {
* @dataProvider provideGetBlockDetails
*/
public function testGetBlockDetails( $block, $expectedInfo ) {
- $language = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );
+ $language = $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'en' );
$mock = $this->getMockForTrait( ApiBlockInfoTrait::class );
$mock->method( 'getLanguage' )->willReturn( $language );
$info = TestingAccessWrapper::newFromObject( $mock )->getBlockDetails( $block );
diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php
index 5f5fb3c3fdc4..a63ea5e85117 100644
--- a/tests/phpunit/includes/api/ApiBlockTest.php
+++ b/tests/phpunit/includes/api/ApiBlockTest.php
@@ -4,7 +4,6 @@ use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Block\Restriction\ActionRestriction;
use MediaWiki\Block\Restriction\NamespaceRestriction;
use MediaWiki\Block\Restriction\PageRestriction;
-use MediaWiki\MediaWikiServices;
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
/**
@@ -93,7 +92,7 @@ class ApiBlockTest extends ApiTestCase {
'timestamp' => '19370101000000',
'expiry' => 'infinity',
] );
- MediaWikiServices::getInstance()->getDatabaseBlockStore()->insertBlock( $block );
+ $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block );
$this->doBlock( [], $blocked );
}
@@ -282,7 +281,7 @@ class ApiBlockTest extends ApiTestCase {
'wgEnablePartialActionBlocks' => true,
] );
- $blockActionInfo = MediaWikiServices::getInstance()->getBlockActionInfo();
+ $blockActionInfo = $this->getServiceContainer()->getBlockActionInfo();
$action = 'upload';
$this->doBlock( [
diff --git a/tests/phpunit/includes/api/ApiClearHasMsgTest.php b/tests/phpunit/includes/api/ApiClearHasMsgTest.php
index 0a45a397fb74..a345dd69ba20 100644
--- a/tests/phpunit/includes/api/ApiClearHasMsgTest.php
+++ b/tests/phpunit/includes/api/ApiClearHasMsgTest.php
@@ -1,7 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
-
/**
* @group API
* @group medium
@@ -14,7 +12,7 @@ class ApiClearHasMsgTest extends ApiTestCase {
*/
public function testClearFlag() {
$user = self::$users['sysop']->getUser();
- $talkPageNotificationManager = MediaWikiServices::getInstance()
+ $talkPageNotificationManager = $this->getServiceContainer()
->getTalkPageNotificationManager();
$talkPageNotificationManager->setUserHasNewMessages( $user );
$this->assertTrue( $talkPageNotificationManager->userHasNewMessages( $user ) );
diff --git a/tests/phpunit/includes/api/ApiComparePagesTest.php b/tests/phpunit/includes/api/ApiComparePagesTest.php
index 6fef787d3e4f..12663bad45f8 100644
--- a/tests/phpunit/includes/api/ApiComparePagesTest.php
+++ b/tests/phpunit/includes/api/ApiComparePagesTest.php
@@ -1,6 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
/**
@@ -83,7 +82,7 @@ class ApiComparePagesTest extends ApiTestCase {
self::$repl['revG1'] = $this->addPage( 'G', "== Section 1 ==\nG 1.1", CONTENT_MODEL_TEXT );
self::$repl['pageG'] = Title::newFromText( 'ApiComparePagesTest G' )->getArticleID();
- $page = MediaWikiServices::getInstance()->getWikiPageFactory()
+ $page = $this->getServiceContainer()->getWikiPageFactory()
->newFromTitle( Title::newFromText( 'ApiComparePagesTest C' ) );
$this->deletePage( $page, 'Test for ApiComparePagesTest', $user );
diff --git a/tests/phpunit/includes/api/ApiEditPageTest.php b/tests/phpunit/includes/api/ApiEditPageTest.php
index 989d71fabe55..62274d68e9e7 100644
--- a/tests/phpunit/includes/api/ApiEditPageTest.php
+++ b/tests/phpunit/includes/api/ApiEditPageTest.php
@@ -1,7 +1,6 @@
<?php
use MediaWiki\Block\DatabaseBlock;
-use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
/**
@@ -1365,7 +1364,7 @@ class ApiEditPageTest extends ApiTestCase {
$this->editPage( $name, 'Some text' );
- $pageObj = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( Title::newFromText( $name ) );
+ $pageObj = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( Title::newFromText( $name ) );
$this->deletePage( $pageObj );
$this->assertFalse( $pageObj->exists() );
@@ -1394,7 +1393,7 @@ class ApiEditPageTest extends ApiTestCase {
'minor' => '',
] );
- $revisionStore = \MediaWiki\MediaWikiServices::getInstance()->getRevisionStore();
+ $revisionStore = $this->getServiceContainer()->getRevisionStore();
$revision = $revisionStore->getRevisionByTitle( Title::newFromText( $name ) );
$this->assertTrue( $revision->isMinor() );
}
@@ -1406,7 +1405,7 @@ class ApiEditPageTest extends ApiTestCase {
$this->editPage( $name, 'Some text' );
- $pageObj = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( Title::newFromText( $name ) );
+ $pageObj = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( Title::newFromText( $name ) );
$this->deletePage( $pageObj );
$this->assertFalse( $pageObj->exists() );
@@ -1570,7 +1569,7 @@ class ApiEditPageTest extends ApiTestCase {
'expiry' => 'infinity',
'enableAutoblock' => true,
] );
- $blockStore = MediaWikiServices::getInstance()->getDatabaseBlockStore();
+ $blockStore = $this->getServiceContainer()->getDatabaseBlockStore();
$blockStore->insertBlock( $block );
try {
@@ -1595,7 +1594,7 @@ class ApiEditPageTest extends ApiTestCase {
$this->expectException( ApiUsageException::class );
$this->expectExceptionMessage( 'The wiki is currently in read-only mode.' );
- $svc = \MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode();
+ $svc = $this->getServiceContainer()->getReadOnlyMode();
$svc->setReason( "Read-only for testing" );
try {
diff --git a/tests/phpunit/includes/api/ApiErrorFormatterTest.php b/tests/phpunit/includes/api/ApiErrorFormatterTest.php
index cb71f77e8f73..47c132c34456 100644
--- a/tests/phpunit/includes/api/ApiErrorFormatterTest.php
+++ b/tests/phpunit/includes/api/ApiErrorFormatterTest.php
@@ -1,6 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
use Wikimedia\TestingAccessWrapper;
/**
@@ -14,7 +13,7 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase {
public function testErrorFormatterBasics() {
$result = new ApiResult( 8388608 );
$formatter = new ApiErrorFormatter( $result,
- MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'de' ), 'wikitext',
+ $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'de' ), 'wikitext',
false );
$this->assertSame( 'de', $formatter->getLanguage()->getCode() );
$this->assertSame( 'wikitext', $formatter->getFormat() );
@@ -42,7 +41,7 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase {
public function testNewWithFormat() {
$result = new ApiResult( 8388608 );
$formatter = new ApiErrorFormatter( $result,
- MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'de' ), 'wikitext',
+ $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'de' ), 'wikitext',
false );
$formatter2 = $formatter->newWithFormat( 'html' );
@@ -65,7 +64,7 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase {
) {
$result = new ApiResult( 8388608 );
$formatter = new ApiErrorFormatter( $result,
- MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $lang ), $format,
+ $this->getServiceContainer()->getLanguageFactory()->getLanguage( $lang ), $format,
$useDB );
// Add default type
@@ -603,7 +602,7 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase {
public function testGetMessageFromException( $exception, $options, $expect ) {
$result = new ApiResult( 8388608 );
$formatter = new ApiErrorFormatter( $result,
- MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' ), 'html',
+ $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'en' ), 'html',
false );
$msg = $formatter->getMessageFromException( $exception, $options );
@@ -698,7 +697,7 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase {
public function testAddMessagesFromStatus_filter() {
$result = new ApiResult( 8388608 );
$formatter = new ApiErrorFormatter( $result,
- MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'qqx' ),
+ $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'qqx' ),
'plaintext', false );
$status = Status::newGood();
diff --git a/tests/phpunit/includes/api/ApiLoginTest.php b/tests/phpunit/includes/api/ApiLoginTest.php
index 4477cba8a503..1634e7a22561 100644
--- a/tests/phpunit/includes/api/ApiLoginTest.php
+++ b/tests/phpunit/includes/api/ApiLoginTest.php
@@ -1,6 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
use MediaWiki\Session\BotPasswordSessionProvider;
use MediaWiki\Session\SessionManager;
use Wikimedia\TestingAccessWrapper;
@@ -296,7 +295,7 @@ class ApiLoginTest extends ApiTestCase {
$this->assertNotSame( 0, $centralId );
$password = 'ngfhmjm64hv0854493hsj5nncjud2clk';
- $passwordFactory = MediaWikiServices::getInstance()->getPasswordFactory();
+ $passwordFactory = $this->getServiceContainer()->getPasswordFactory();
// A is unsalted MD5 (thus fast) ... we don't care about security here, this is test only
$passwordHash = $passwordFactory->newFromPlaintext( $password );
diff --git a/tests/phpunit/includes/api/ApiMoveTest.php b/tests/phpunit/includes/api/ApiMoveTest.php
index d26bb47a030a..02e85fa9c4e7 100644
--- a/tests/phpunit/includes/api/ApiMoveTest.php
+++ b/tests/phpunit/includes/api/ApiMoveTest.php
@@ -1,7 +1,6 @@
<?php
use MediaWiki\Block\DatabaseBlock;
-use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\SlotRecord;
/**
@@ -51,7 +50,7 @@ class ApiMoveTest extends ApiTestCase {
$this->assertTrue( $fromTitle->isRedirect(),
"Source {$fromTitle->getPrefixedText()} is not a redirect" );
- $target = MediaWikiServices::getInstance()
+ $target = $this->getServiceContainer()
->getRevisionLookup()
->getRevisionByTitle( $fromTitle )
->getContent( SlotRecord::MAIN )
@@ -149,7 +148,7 @@ class ApiMoveTest extends ApiTestCase {
] );
// Fetched stored expiry (maximum duration may override '99990123000000').
- $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $store = $this->getServiceContainer()->getWatchedItemStore();
$expiry = $store->getWatchedItem( $user, $title )->getExpiry();
// Move to new location, without changing the watched state.
@@ -207,7 +206,7 @@ class ApiMoveTest extends ApiTestCase {
public function testMoveWhileBlocked() {
$this->assertNull( DatabaseBlock::newFromTarget( '127.0.0.1' ) );
- $blockStore = MediaWikiServices::getInstance()->getDatabaseBlockStore();
+ $blockStore = $this->getServiceContainer()->getDatabaseBlockStore();
$block = new DatabaseBlock( [
'address' => self::$users['sysop']->getUser()->getName(),
'by' => self::$users['sysop']->getUser(),
diff --git a/tests/phpunit/includes/api/ApiPageSetTest.php b/tests/phpunit/includes/api/ApiPageSetTest.php
index e757e3a8a6b5..0f6848f2f190 100644
--- a/tests/phpunit/includes/api/ApiPageSetTest.php
+++ b/tests/phpunit/includes/api/ApiPageSetTest.php
@@ -1,7 +1,6 @@
<?php
use MediaWiki\Linker\LinkTarget;
-use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Page\PageReference;
use MediaWiki\Tests\Unit\DummyServicesTrait;
@@ -242,7 +241,7 @@ class ApiPageSetTest extends ApiTestCase {
// Prepare the gender cache for testing - this is a fresh instance due to service override
$genderCache = TestingAccessWrapper::newFromObject(
- MediaWikiServices::getInstance()->getGenderCache()
+ $this->getServiceContainer()->getGenderCache()
);
$genderCache->missLimit = 0;
diff --git a/tests/phpunit/includes/api/ApiResultTest.php b/tests/phpunit/includes/api/ApiResultTest.php
index 54efaa4afb72..03b2121a46b8 100644
--- a/tests/phpunit/includes/api/ApiResultTest.php
+++ b/tests/phpunit/includes/api/ApiResultTest.php
@@ -1,7 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
-
/**
* @covers ApiResult
* @group API
@@ -478,7 +476,7 @@ class ApiResultTest extends MediaWikiIntegrationTestCase {
$result = new ApiResult( 10 );
$formatter = new ApiErrorFormatter( $result,
- MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' ),
+ $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'en' ),
'none', false );
$result->setErrorFormatter( $formatter );
$this->assertFalse( $result->addValue( null, 'foo', '12345678901' ) );
diff --git a/tests/phpunit/includes/api/ApiRevisionDeleteTest.php b/tests/phpunit/includes/api/ApiRevisionDeleteTest.php
index a1c5d5d50118..0e4a7d893940 100644
--- a/tests/phpunit/includes/api/ApiRevisionDeleteTest.php
+++ b/tests/phpunit/includes/api/ApiRevisionDeleteTest.php
@@ -2,7 +2,6 @@
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Block\Restriction\PageRestriction;
-use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
@@ -131,7 +130,7 @@ class ApiRevisionDeleteTest extends ApiTestCase {
$block->setRestrictions( [
new PageRestriction( 0, Title::newFromText( self::$page )->getArticleID() )
] );
- MediaWikiServices::getInstance()->getDatabaseBlockStore()->insertBlock( $block );
+ $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block );
$revid = array_shift( $this->revs );
diff --git a/tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php b/tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php
index 867d178a5476..2b3c8f9f9829 100644
--- a/tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php
+++ b/tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php
@@ -1,7 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
-
/**
* @author Addshore
* @covers ApiSetNotificationTimestamp
@@ -47,7 +45,7 @@ class ApiSetNotificationTimestampIntegrationTest extends ApiTestCase {
$result[0]
);
- $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $watchedItemStore = $this->getServiceContainer()->getWatchedItemStore();
$this->assertEquals(
$watchedItemStore->getNotificationTimestampsBatch( $user, [ $page->getTitle() ] ),
[ [ 'UTPage' => '20160101020202' ] ]
diff --git a/tests/phpunit/includes/api/ApiStashEditTest.php b/tests/phpunit/includes/api/ApiStashEditTest.php
index defad488b99c..745a5ecd8460 100644
--- a/tests/phpunit/includes/api/ApiStashEditTest.php
+++ b/tests/phpunit/includes/api/ApiStashEditTest.php
@@ -1,6 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
use MediaWiki\Storage\PageEditStash;
use MediaWiki\User\UserIdentity;
use Psr\Log\NullLogger;
@@ -24,13 +23,13 @@ class ApiStashEditTest extends ApiTestCase {
->getUserEditTracker() );
$this->setService( 'PageEditStash', new PageEditStash(
new HashBagOStuff( [] ),
- MediaWikiServices::getInstance()->getDBLoadBalancer(),
+ $this->getServiceContainer()->getDBLoadBalancer(),
new NullLogger(),
new NullStatsdDataFactory(),
- MediaWikiServices::getInstance()->getUserEditTracker(),
- MediaWikiServices::getInstance()->getUserFactory(),
- MediaWikiServices::getInstance()->getWikiPageFactory(),
- MediaWikiServices::getInstance()->getHookContainer(),
+ $this->getServiceContainer()->getUserEditTracker(),
+ $this->getServiceContainer()->getUserFactory(),
+ $this->getServiceContainer()->getWikiPageFactory(),
+ $this->getServiceContainer()->getHookContainer(),
PageEditStash::INITIATOR_USER
) );
// Clear rate-limiting cache between tests
@@ -109,7 +108,7 @@ class ApiStashEditTest extends ApiTestCase {
* @return string
*/
protected function getStashedText( $hash ) {
- return MediaWikiServices::getInstance()->getPageEditStash()->fetchInputText( $hash );
+ return $this->getServiceContainer()->getPageEditStash()->fetchInputText( $hash );
}
/**
@@ -127,7 +126,7 @@ class ApiStashEditTest extends ApiTestCase {
$user = $this->getTestSysop()->getUser();
}
$editStash = TestingAccessWrapper::newFromObject(
- MediaWikiServices::getInstance()->getPageEditStash() );
+ $this->getServiceContainer()->getPageEditStash() );
return $editStash->getStashKey( $titleObj, $editStash->getContentHash( $content ), $user );
}
@@ -311,7 +310,7 @@ class ApiStashEditTest extends ApiTestCase {
* @return stdClass|bool Return value of PageStashEdit::checkCache(), false if not in cache
*/
protected function doCheckCache( UserIdentity $user, $text = 'Content' ) {
- return MediaWikiServices::getInstance()->getPageEditStash()->checkCache(
+ return $this->getServiceContainer()->getPageEditStash()->checkCache(
Title::newFromText( __CLASS__ ),
new WikitextContent( $text ),
$user
@@ -373,7 +372,7 @@ class ApiStashEditTest extends ApiTestCase {
$key = $this->getStashKey( __CLASS__, $text, $user );
$editStash = TestingAccessWrapper::newFromObject(
- MediaWikiServices::getInstance()->getPageEditStash() );
+ $this->getServiceContainer()->getPageEditStash() );
$cache = $editStash->cache;
$editInfo = $cache->get( $key );
@@ -424,7 +423,7 @@ class ApiStashEditTest extends ApiTestCase {
$this->doStash( [ 'text' => $text ] );
$editStash = TestingAccessWrapper::newFromObject(
- MediaWikiServices::getInstance()->getPageEditStash() );
+ $this->getServiceContainer()->getPageEditStash() );
$cache = $editStash->cache;
$key = $this->getStashKey( __CLASS__, $text );
diff --git a/tests/phpunit/includes/api/ApiUnblockTest.php b/tests/phpunit/includes/api/ApiUnblockTest.php
index 062024a9f231..67dc3030efb2 100644
--- a/tests/phpunit/includes/api/ApiUnblockTest.php
+++ b/tests/phpunit/includes/api/ApiUnblockTest.php
@@ -1,7 +1,6 @@
<?php
use MediaWiki\Block\DatabaseBlock;
-use MediaWiki\MediaWikiServices;
/**
* @group API
@@ -33,7 +32,7 @@ class ApiUnblockTest extends ApiTestCase {
'address' => $this->blockee->getName(),
'by' => $this->blocker,
] );
- $result = MediaWikiServices::getInstance()->getDatabaseBlockStore()->insertBlock( $block );
+ $result = $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block );
$this->assertNotFalse( $result, 'Could not insert block' );
$blockFromDB = DatabaseBlock::newFromID( $result['id'] );
$this->assertTrue( $blockFromDB !== null, 'Could not retrieve block' );
@@ -99,7 +98,7 @@ class ApiUnblockTest extends ApiTestCase {
'address' => $this->blocker->getName(),
'by' => $this->getTestUser( 'sysop' )->getUser(),
] );
- MediaWikiServices::getInstance()->getDatabaseBlockStore()->insertBlock( $block );
+ $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block );
$this->doUnblock();
}
@@ -109,7 +108,7 @@ class ApiUnblockTest extends ApiTestCase {
'address' => $this->blocker->getName(),
'by' => $this->getTestUser( 'sysop' )->getUser(),
] );
- $result = MediaWikiServices::getInstance()->getDatabaseBlockStore()->insertBlock( $block );
+ $result = $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block );
$this->assertNotFalse( $result, 'Could not insert block' );
$this->doUnblock( [ 'user' => $this->blocker->getName() ] );
diff --git a/tests/phpunit/includes/api/ApiUploadTestCase.php b/tests/phpunit/includes/api/ApiUploadTestCase.php
index ee79b855d897..190f6f465d49 100644
--- a/tests/phpunit/includes/api/ApiUploadTestCase.php
+++ b/tests/phpunit/includes/api/ApiUploadTestCase.php
@@ -1,7 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
-
/**
* Abstract class to support upload tests
*/
@@ -35,7 +33,7 @@ abstract class ApiUploadTestCase extends ApiTestCase {
*/
public function deleteFileByTitle( $title ) {
if ( $title->exists() ) {
- $file = MediaWikiServices::getInstance()->getRepoGroup()
+ $file = $this->getServiceContainer()->getRepoGroup()
->findFile( $title, [ 'ignoreRedirect' => true ] );
$noOldArchive = ""; // yes this really needs to be set this way
$comment = "removing for test";
@@ -54,7 +52,7 @@ abstract class ApiUploadTestCase extends ApiTestCase {
return false;
}
- $page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $title );
+ $page = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
$this->deletePage( $page, "removing for test" );
// see if it now doesn't exist; reload
@@ -85,7 +83,7 @@ abstract class ApiUploadTestCase extends ApiTestCase {
*/
public function deleteFileByContent( $filePath ) {
$hash = FSFile::getSha1Base36FromPath( $filePath );
- $dupes = MediaWikiServices::getInstance()->getRepoGroup()->findBySha1( $hash );
+ $dupes = $this->getServiceContainer()->getRepoGroup()->findBySha1( $hash );
$success = true;
foreach ( $dupes as $dupe ) {
$success &= $this->deleteFileByTitle( $dupe->getTitle() );
diff --git a/tests/phpunit/includes/api/ApiUserrightsTest.php b/tests/phpunit/includes/api/ApiUserrightsTest.php
index 6bcb4cda272b..f485d5bfe0f7 100644
--- a/tests/phpunit/includes/api/ApiUserrightsTest.php
+++ b/tests/phpunit/includes/api/ApiUserrightsTest.php
@@ -1,7 +1,6 @@
<?php
use MediaWiki\Block\DatabaseBlock;
-use MediaWiki\MediaWikiServices;
/**
* @group API
@@ -141,7 +140,7 @@ class ApiUserrightsTest extends ApiTestCase {
$user = $this->getTestSysop()->getUser();
$block = new DatabaseBlock( [ 'address' => $user, 'by' => $user, ] );
- $blockStore = MediaWikiServices::getInstance()->getDatabaseBlockStore();
+ $blockStore = $this->getServiceContainer()->getDatabaseBlockStore();
$blockStore->insertBlock( $block );
try {
@@ -158,7 +157,7 @@ class ApiUserrightsTest extends ApiTestCase {
$this->setPermissions( true, true );
$block = new DatabaseBlock( [ 'address' => $user, 'by' => $user ] );
- $blockStore = MediaWikiServices::getInstance()->getDatabaseBlockStore();
+ $blockStore = $this->getServiceContainer()->getDatabaseBlockStore();
$blockStore->insertBlock( $block );
try {
diff --git a/tests/phpunit/includes/api/ApiWatchTest.php b/tests/phpunit/includes/api/ApiWatchTest.php
index dec59c14c0e5..102d4d428f65 100644
--- a/tests/phpunit/includes/api/ApiWatchTest.php
+++ b/tests/phpunit/includes/api/ApiWatchTest.php
@@ -1,6 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
use Wikimedia\Timestamp\ConvertibleTimestamp;
/**
@@ -55,7 +54,7 @@ class ApiWatchTest extends ApiTestCase {
}
public function testWatchWithExpiry() {
- $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $store = $this->getServiceContainer()->getWatchedItemStore();
$user = $this->getTestUser()->getUser();
// First watch without expiry (indefinite).
diff --git a/tests/phpunit/includes/api/Validator/ApiParamValidatorTest.php b/tests/phpunit/includes/api/Validator/ApiParamValidatorTest.php
index 58877807ebd6..58531ff1b0cf 100644
--- a/tests/phpunit/includes/api/Validator/ApiParamValidatorTest.php
+++ b/tests/phpunit/includes/api/Validator/ApiParamValidatorTest.php
@@ -8,7 +8,6 @@ use ApiMessage;
use ApiTestCase;
use ApiUsageException;
use FauxRequest;
-use MediaWiki\MediaWikiServices;
use Message;
use Wikimedia\Message\DataMessageValue;
use Wikimedia\Message\MessageValue;
@@ -28,7 +27,7 @@ class ApiParamValidatorTest extends ApiTestCase {
$context = $this->apiContext->newTestContext( $request, $this->getTestUser()->getUser() );
$main = new ApiMain( $context );
return [
- new ApiParamValidator( $main, MediaWikiServices::getInstance()->getObjectFactory() ),
+ new ApiParamValidator( $main, $this->getServiceContainer()->getObjectFactory() ),
$main
];
}
diff --git a/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php b/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php
index d210c56ce9c3..96048ef3c8f0 100644
--- a/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php
@@ -3,7 +3,6 @@
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Block\Restriction\NamespaceRestriction;
use MediaWiki\Block\Restriction\PageRestriction;
-use MediaWiki\MediaWikiServices;
/**
* @group API
@@ -38,7 +37,7 @@ class ApiQueryBlocksTest extends ApiTestCase {
'expiry' => 'infinity',
] );
- MediaWikiServices::getInstance()->getDatabaseBlockStore()->insertBlock( $block );
+ $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block );
list( $data ) = $this->doApiRequest( [
'action' => 'query',
@@ -67,7 +66,7 @@ class ApiQueryBlocksTest extends ApiTestCase {
'ipb_sitewide' => 1,
] );
- MediaWikiServices::getInstance()->getDatabaseBlockStore()->insertBlock( $block );
+ $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block );
list( $data ) = $this->doApiRequest( [
'action' => 'query',
@@ -100,7 +99,7 @@ class ApiQueryBlocksTest extends ApiTestCase {
'sitewide' => 0,
] );
- MediaWikiServices::getInstance()->getDatabaseBlockStore()->insertBlock( $block );
+ $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block );
$subset = [
'id' => $block->getId(),
diff --git a/tests/phpunit/includes/api/query/ApiQueryInfoTest.php b/tests/phpunit/includes/api/query/ApiQueryInfoTest.php
index ebbc47752fe1..62c22c3d5c4b 100644
--- a/tests/phpunit/includes/api/query/ApiQueryInfoTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryInfoTest.php
@@ -1,7 +1,6 @@
<?php
use MediaWiki\Block\DatabaseBlock;
-use MediaWiki\MediaWikiServices;
use Wikimedia\Timestamp\ConvertibleTimestamp;
/**
@@ -169,7 +168,7 @@ class ApiQueryInfoTest extends ApiTestCase {
'enableAutoblock' => true,
] );
- $blockStore = MediaWikiServices::getInstance()->getDatabaseBlockStore();
+ $blockStore = $this->getServiceContainer()->getDatabaseBlockStore();
$blockStore->insertBlock( $block );
$page = $this->getExistingTestPage( 'Pluto' );
diff --git a/tests/phpunit/includes/api/query/ApiQueryRecentChangesIntegrationTest.php b/tests/phpunit/includes/api/query/ApiQueryRecentChangesIntegrationTest.php
index cedd58904122..4264ab612617 100644
--- a/tests/phpunit/includes/api/query/ApiQueryRecentChangesIntegrationTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryRecentChangesIntegrationTest.php
@@ -1,7 +1,6 @@
<?php
use MediaWiki\Linker\LinkTarget;
-use MediaWiki\MediaWikiServices;
/**
* @group API
@@ -397,7 +396,7 @@ class ApiQueryRecentChangesIntegrationTest extends ApiTestCase {
$target,
'Create the page that will be deleted'
);
- $wikiPage = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromLinkTarget( $target );
+ $wikiPage = $this->getServiceContainer()->getWikiPageFactory()->newFromLinkTarget( $target );
$this->deletePage( $wikiPage, 'Important Reason' );
}
@@ -648,7 +647,7 @@ class ApiQueryRecentChangesIntegrationTest extends ApiTestCase {
]
);
$title = Title::newFromLinkTarget( $subjectTarget );
- $revision = MediaWikiServices::getInstance()
+ $revision = $this->getServiceContainer()
->getRevisionLookup()
->getRevisionByTitle( $title );
diff --git a/tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php b/tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php
index 668ae9ceee4b..209d9a7a9343 100644
--- a/tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php
+++ b/tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php
@@ -1,6 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
use Wikimedia\TestingAccessWrapper;
/**
@@ -53,7 +52,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
}
public function testLinkPrefixCharset() {
- $contLang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'ar' );
+ $contLang = $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'ar' );
$this->setContentLang( $contLang );
$this->assertTrue( $contLang->linkPrefixExtension() );
@@ -63,7 +62,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
}
public function testVariants() {
- $contLang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'zh' );
+ $contLang = $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'zh' );
$this->setContentLang( $contLang );
$this->assertTrue( $contLang->hasVariants() );
@@ -80,7 +79,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
}
public function testReadOnly() {
- $svc = MediaWikiServices::getInstance()->getReadOnlyMode();
+ $svc = $this->getServiceContainer()->getReadOnlyMode();
$svc->setReason( 'Need more donations' );
try {
$data = $this->doQuery();
@@ -94,7 +93,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
public function testNamespacesBasic() {
$this->assertSame(
- array_keys( MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces() ),
+ array_keys( $this->getServiceContainer()->getContentLanguage()->getFormattedNamespaces() ),
array_keys( $this->doQuery( 'namespaces' ) )
);
}
@@ -102,7 +101,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
public function testNamespacesExtraNS() {
$this->setMwGlobals( 'wgExtraNamespaces', [ '138' => 'Testing' ] );
$this->assertSame(
- array_keys( MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces() ),
+ array_keys( $this->getServiceContainer()->getContentLanguage()->getFormattedNamespaces() ),
array_keys( $this->doQuery( 'namespaces' ) )
);
}
@@ -133,7 +132,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
}
public function testNamespaceAliases() {
- $expected = MediaWikiServices::getInstance()->getContentLanguage()->getNamespaceAliases();
+ $expected = $this->getServiceContainer()->getContentLanguage()->getNamespaceAliases();
$expected = array_map(
static function ( $key, $val ) {
return [ 'id' => $val, 'alias' => strtr( $key, '_', ' ' ) ];
@@ -147,14 +146,14 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
public function testSpecialPageAliases() {
$this->assertCount(
- count( MediaWikiServices::getInstance()->getSpecialPageFactory()->getNames() ),
+ count( $this->getServiceContainer()->getSpecialPageFactory()->getNames() ),
$this->doQuery( 'specialpagealiases' )
);
}
public function testMagicWords() {
$this->assertCount(
- count( MediaWikiServices::getInstance()->getContentLanguage()->getMagicWords() ),
+ count( $this->getServiceContainer()->getContentLanguage()->getMagicWords() ),
$this->doQuery( 'magicwords' )
);
}
@@ -201,7 +200,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
] );
$this->resetServices();
- MediaWikiServices::getInstance()->getMessageCache()->enable();
+ $this->getServiceContainer()->getMessageCache()->enable();
$this->editPage( 'MediaWiki:Interlanguage-link-self', 'Self!' );
$this->editPage( 'MediaWiki:Interlanguage-link-sitename-self', 'Circular logic' );
@@ -533,7 +532,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
* @dataProvider languagesProvider
*/
public function testLanguages( $langCode ) {
- $expected = MediaWikiServices::getInstance()
+ $expected = $this->getServiceContainer()
->getLanguageNameUtils()
->getLanguageNames( (string)$langCode );
@@ -561,10 +560,10 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
public function testLanguageVariants() {
$expectedKeys = array_filter( LanguageConverter::$languagesWithVariants,
- static function ( $langCode ) {
- $lang = MediaWikiServices::getInstance()->getLanguageFactory()
+ function ( $langCode ) {
+ $lang = $this->getServiceContainer()->getLanguageFactory()
->getLanguage( $langCode );
- $converter = MediaWikiServices::getInstance()->getLanguageConverterFactory()
+ $converter = $this->getServiceContainer()->getLanguageConverterFactory()
->getLanguageConverter( $lang );
return $converter->hasVariants();
}
@@ -590,7 +589,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
*/
public function testSkins( $code ) {
$data = $this->doQuery( 'skins', $code !== null ? [ 'siinlanguagecode' => $code ] : [] );
- $services = MediaWikiServices::getInstance();
+ $services = $this->getServiceContainer();
$skinFactory = $services->getSkinFactory();
$skinNames = $skinFactory->getInstalledSkins();
$expectedAllowed = $skinFactory->getAllowedSkins();
@@ -635,20 +634,20 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
static function ( $tag ) {
return "<$tag>";
},
- MediaWikiServices::getInstance()->getParser()->getTags()
+ $this->getServiceContainer()->getParser()->getTags()
);
$this->assertSame( $expected, $this->doQuery( 'extensiontags' ) );
}
public function testFunctionHooks() {
- $this->assertSame( MediaWikiServices::getInstance()->getParser()->getFunctionHooks(),
+ $this->assertSame( $this->getServiceContainer()->getParser()->getFunctionHooks(),
$this->doQuery( 'functionhooks' ) );
}
public function testVariables() {
$this->assertSame(
- MediaWikiServices::getInstance()->getMagicWordFactory()->getVariableIDs(),
+ $this->getServiceContainer()->getMagicWordFactory()->getVariableIDs(),
$this->doQuery( 'variables' )
);
}
diff --git a/tests/phpunit/includes/api/query/ApiQueryWatchlistIntegrationTest.php b/tests/phpunit/includes/api/query/ApiQueryWatchlistIntegrationTest.php
index ccb758bd6947..222b76ba2f71 100644
--- a/tests/phpunit/includes/api/query/ApiQueryWatchlistIntegrationTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryWatchlistIntegrationTest.php
@@ -1,7 +1,6 @@
<?php
use MediaWiki\Linker\LinkTarget;
-use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\SlotRecord;
/**
@@ -87,7 +86,7 @@ class ApiQueryWatchlistIntegrationTest extends ApiTestCase {
$updater->setContent( SlotRecord::MAIN, ContentHandler::makeContent( $content, $title ) );
$rev = $updater->saveRevision( $summary );
- $rc = MediaWikiServices::getInstance()->getRevisionStore()->getRecentChange( $rev );
+ $rc = $this->getServiceContainer()->getRevisionStore()->getRecentChange( $rev );
$rc->doMarkPatrolled( $patrollingUser, false, [] );
}
@@ -131,7 +130,7 @@ class ApiQueryWatchlistIntegrationTest extends ApiTestCase {
}
private function getWatchedItemStore() {
- return MediaWikiServices::getInstance()->getWatchedItemStore();
+ return $this->getServiceContainer()->getWatchedItemStore();
}
/**
@@ -214,7 +213,7 @@ class ApiQueryWatchlistIntegrationTest extends ApiTestCase {
}
private function getPrefixedText( LinkTarget $target ) {
- return MediaWikiServices::getInstance()->getTitleFormatter()->getPrefixedText( $target );
+ return $this->getServiceContainer()->getTitleFormatter()->getPrefixedText( $target );
}
private function cleanTestUsersWatchlist() {
@@ -622,7 +621,7 @@ class ApiQueryWatchlistIntegrationTest extends ApiTestCase {
'Some Content',
'Create the page that will be deleted'
);
- $wikiPage = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromLinkTarget( $target );
+ $wikiPage = $this->getServiceContainer()->getWikiPageFactory()->newFromLinkTarget( $target );
$this->deletePage( $wikiPage, 'Important Reason' );
}
@@ -1140,7 +1139,7 @@ class ApiQueryWatchlistIntegrationTest extends ApiTestCase {
]
);
$title = Title::newFromLinkTarget( $subjectTarget );
- $revision = MediaWikiServices::getInstance()
+ $revision = $this->getServiceContainer()
->getRevisionLookup()
->getRevisionByTitle( $title );
diff --git a/tests/phpunit/includes/api/query/ApiQueryWatchlistRawIntegrationTest.php b/tests/phpunit/includes/api/query/ApiQueryWatchlistRawIntegrationTest.php
index 501456c55d8a..b41cbb736147 100644
--- a/tests/phpunit/includes/api/query/ApiQueryWatchlistRawIntegrationTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryWatchlistRawIntegrationTest.php
@@ -1,7 +1,5 @@
<?php
-use MediaWiki\MediaWikiServices;
-
/**
* @group API
* @group Database
@@ -34,7 +32,7 @@ class ApiQueryWatchlistRawIntegrationTest extends ApiTestCase {
}
private function getWatchedItemStore() {
- return MediaWikiServices::getInstance()->getWatchedItemStore();
+ return $this->getServiceContainer()->getWatchedItemStore();
}
private function doListWatchlistRawRequest( array $params = [] ) {