Merge "Added release notes for 'ContentHandler::runLegacyHooks' removal"
[mediawiki.git] / tests / phpunit / includes / content / FileContentHandlerTest.php
blob276a86ee5e0c70eca1dd2f2eec8fbe01542133d2
1 <?php
3 /**
4 * @group ContentHandler
5 */
6 class FileContentHandlerTest extends MediaWikiLangTestCase {
7 /**
8 * @var FileContentHandler
9 */
10 private $handler;
12 protected function setUp() {
13 parent::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 ) {
24 $mockField =
25 $this->getMockBuilder( 'SearchIndexFieldDefinition' )
26 ->setMethods( [ 'getMapping' ] )
27 ->setConstructorArgs( [ $name, $type ] )
28 ->getMock();
29 return $mockField;
30 } );
32 $map = $this->handler->getFieldsForSearchIndex( $mockEngine );
33 $expect = [
34 'file_media_type' => 1,
35 'file_mime' => 1,
36 'file_size' => 1,
37 'file_width' => 1,
38 'file_height' => 1,
39 'file_bits' => 1,
40 'file_resolution' => 1,
41 'file_text' => 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 );