4 * @group ContentHandler
6 class FileContentHandlerTest
extends MediaWikiLangTestCase
{
8 * @var FileContentHandler
12 protected function setUp() {
15 $this->handler
= new FileContentHandler();
18 public function testIndexMapping() {
19 $mockEngine = $this->getMock( 'SearchEngine' );
21 $mockEngine->expects( $this->atLeastOnce() )
22 ->method( 'makeSearchFieldMapping' )
23 ->willReturnCallback( function ( $name, $type ) {
25 $this->getMockBuilder( 'SearchIndexFieldDefinition' )
26 ->setMethods( [ 'getMapping' ] )
27 ->setConstructorArgs( [ $name, $type ] )
32 $map = $this->handler
->getFieldsForSearchIndex( $mockEngine );
34 'file_media_type' => 1,
40 'file_resolution' => 1,
43 foreach ( $map as $name => $field ) {
44 $this->assertInstanceOf( 'SearchIndexField', $field );
45 $this->assertEquals( $name, $field->getName() );
46 unset( $expect[$name] );
48 $this->assertEmpty( $expect );