From: C. Scott Ananian Date: Thu, 27 Sep 2018 21:36:19 +0000 (-0400) Subject: Ensure OutputPageTest works when Translate extension is loaded X-Git-Tag: 1.34.0-rc.0~3890^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=91c81397ccfbe8e52cc39f92a5e5d7379d87021f;p=lhc%2Fweb%2Fwiklou.git Ensure OutputPageTest works when Translate extension is loaded The translate extension registers the LanguageLinks hook which is run by OutputPage::addParserOutputMetadata with a Title as an argument. If our mock doesn't provide a valid Title, then PageTranslationHooks::addLanguageLinks() in Translate will throw a TypeError in OutputPageTest::testParserOutputCategoryLinks(). Change-Id: I495c51731670f841e5ab752a3a1e014c86ef643d --- diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index 283e99fc93..054636ec7c 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -1020,9 +1020,14 @@ class OutputPageTest extends MediaWikiTestCase { $op = $this->getMockBuilder( OutputPage::class ) ->setConstructorArgs( [ new RequestContext() ] ) - ->setMethods( [ 'addCategoryLinksToLBAndGetResult' ] ) + ->setMethods( [ 'addCategoryLinksToLBAndGetResult', 'getTitle' ] ) ->getMock(); + $title = Title::newFromText( 'My test page' ); + $op->expects( $this->any() ) + ->method( 'getTitle' ) + ->will( $this->returnValue( $title ) ); + $op->expects( $this->any() ) ->method( 'addCategoryLinksToLBAndGetResult' ) ->will( $this->returnCallback( function ( array $categories ) use ( $fakeResults ) {