Addshore has uploaded a new change for review. https://gerrit.wikimedia.org/r/286432
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(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/32/286432/1 diff --git a/tests/phpunit/tests/MediaWikiTestCaseTest.php b/tests/phpunit/tests/MediaWikiTestCaseTest.php index 152c2eb..d3171ba 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; /** * @covers MediaWikiTestCase @@ -98,6 +99,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: newchange Gerrit-Change-Id: If689d85f42ae26e786d599f59e76d3ebdfa22212 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Addshore <addshorew...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits