Merge "phpunit: Avoid use of deprecated getMock for PHPUnit 5 compat"
[lhc/web/wiklou.git] / tests / phpunit / includes / content / WikitextContentHandlerTest.php
index 9d4abe8..290b11a 100644 (file)
@@ -245,15 +245,24 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
        */
 
        public function testDataIndexFieldsFile() {
-               $mockEngine = $this->getMock( 'SearchEngine' );
+               $mockEngine = $this->createMock( 'SearchEngine' );
                $title = Title::newFromText( 'Somefile.jpg', NS_FILE );
                $page = new WikiPage( $title );
 
+               $fileHandler = $this->getMockBuilder( FileContentHandler::class )
+                       ->disableOriginalConstructor()
+                       ->setMethods( [ 'getDataForSearchIndex' ] )
+                       ->getMock();
+
                $handler = $this->getMockBuilder( WikitextContentHandler::class )
                        ->disableOriginalConstructor()
-                       ->setMethods( [ 'getFileText' ] )
+                       ->setMethods( [ 'getFileHandler' ] )
                        ->getMock();
-               $handler->method( 'getFileText' )->will( $this->returnValue( 'This is file content' ) );
+
+               $handler->method( 'getFileHandler' )->will( $this->returnValue( $fileHandler ) );
+               $fileHandler->expects( $this->once() )
+                       ->method( 'getDataForSearchIndex' )
+                       ->will( $this->returnValue( [ 'file_text' => 'This is file content' ] ) );
 
                $data = $handler->getDataForSearchIndex( $page, new ParserOutput(), $mockEngine );
                $this->assertArrayHasKey( 'file_text', $data );