Call resetServices() when setting globals in tests
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiQuerySiteinfoTest.php
index 55f4a33..0a2558a 100644 (file)
@@ -210,15 +210,16 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
                        $this->setExpectedApiException( 'apierror-siteinfo-includealldenied' );
                }
 
-               $mockLB = $this->getMockBuilder( LoadBalancer::class )
-                       ->disableOriginalConstructor()
-                       ->setMethods( [ 'getMaxLag', 'getLagTimes', 'getServerName', '__destruct' ] )
-                       ->getMock();
+               $mockLB = $this->createMock( LoadBalancer::class );
                $mockLB->method( 'getMaxLag' )->willReturn( [ null, 7, 1 ] );
                $mockLB->method( 'getLagTimes' )->willReturn( [ 5, 7 ] );
                $mockLB->method( 'getServerName' )->will( $this->returnValueMap( [
                        [ 0, 'apple' ], [ 1, 'carrot' ]
                ] ) );
+               $mockLB->method( 'getLocalDomainID' )->willReturn( 'testdomain' );
+               $mockLB->expects( $this->never() )->method( $this->anythingBut(
+                       'getMaxLag', 'getLagTimes', 'getServerName', 'getLocalDomainID', '__destruct'
+               ) );
                $this->setService( 'DBLoadBalancer', $mockLB );
 
                $this->setMwGlobals( 'wgShowHostnames', $showHostnames );
@@ -571,22 +572,19 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
        }
 
        public function testExtensionTags() {
-               global $wgParser;
-
                $expected = array_map(
                        function ( $tag ) {
                                return "<$tag>";
                        },
-                       $wgParser->getTags()
+                       MediaWikiServices::getInstance()->getParser()->getTags()
                );
 
                $this->assertSame( $expected, $this->doQuery( 'extensiontags' ) );
        }
 
        public function testFunctionHooks() {
-               global $wgParser;
-
-               $this->assertSame( $wgParser->getFunctionHooks(), $this->doQuery( 'functionhooks' ) );
+               $this->assertSame( MediaWikiServices::getInstance()->getParser()->getFunctionHooks(),
+                       $this->doQuery( 'functionhooks' ) );
        }
 
        public function testVariables() {