jenkins-bot has submitted this change and it was merged. Change subject: Add tests for MediawikiTestCase::setService stuff ......................................................................
Add tests for MediawikiTestCase::setService stuff Change-Id: If689d85f42ae26e786d599f59e76d3ebdfa22212 --- M tests/phpunit/tests/MediaWikiTestCaseTest.php 1 file changed, 31 insertions(+), 0 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/phpunit/tests/MediaWikiTestCaseTest.php b/tests/phpunit/tests/MediaWikiTestCaseTest.php index 955dd2f..5d2f37e 100644 --- a/tests/phpunit/tests/MediaWikiTestCaseTest.php +++ b/tests/phpunit/tests/MediaWikiTestCaseTest.php @@ -1,5 +1,6 @@ <?php use MediaWiki\Logger\LoggerFactory; +use MediaWiki\MediaWikiServices; use Psr\Log\LoggerInterface; /** @@ -99,6 +100,36 @@ $this->stashMwGlobals( self::GLOBAL_KEY_NONEXISTING ); } + public function testOverrideMwServices() { + $initialServices = MediaWikiServices::getInstance(); + + $this->overrideMwServices(); + $this->assertNotSame( $initialServices, MediaWikiServices::getInstance() ); + + $this->tearDown(); + $this->assertSame( $initialServices, MediaWikiServices::getInstance() ); + } + + public function testSetService() { + $initialServices = MediaWikiServices::getInstance(); + $initialService = $initialServices->getDBLoadBalancer(); + $mockService = $this->getMockBuilder( LoadBalancer::class ) + ->disableOriginalConstructor()->getMock(); + + $this->setService( 'DBLoadBalancer', $mockService ); + $this->assertNotSame( $initialServices, MediaWikiServices::getInstance() ); + $this->assertNotSame( + $initialService, + MediaWikiServices::getInstance()->getDBLoadBalancer() + ); + $this->assertSame( $mockService, MediaWikiServices::getInstance()->getDBLoadBalancer() ); + + $this->tearDown(); + $this->assertSame( $initialServices, MediaWikiServices::getInstance() ); + $this->assertNotSame( $mockService, MediaWikiServices::getInstance()->getDBLoadBalancer() ); + $this->assertSame( $initialService, MediaWikiServices::getInstance()->getDBLoadBalancer() ); + } + /** * @covers MediaWikiTestCase::setLogger * @covers MediaWikiTestCase::restoreLogger -- To view, visit https://gerrit.wikimedia.org/r/286432 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If689d85f42ae26e786d599f59e76d3ebdfa22212 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits