diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/tests/phpunit/includes/content/FileContentHandlerTest.php |
first commit
Diffstat (limited to 'www/wiki/tests/phpunit/includes/content/FileContentHandlerTest.php')
-rw-r--r-- | www/wiki/tests/phpunit/includes/content/FileContentHandlerTest.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/www/wiki/tests/phpunit/includes/content/FileContentHandlerTest.php b/www/wiki/tests/phpunit/includes/content/FileContentHandlerTest.php new file mode 100644 index 00000000..9149fc4f --- /dev/null +++ b/www/wiki/tests/phpunit/includes/content/FileContentHandlerTest.php @@ -0,0 +1,52 @@ +<?php + +/** + * @group ContentHandler + * + * @covers FileContentHandler + */ +class FileContentHandlerTest extends MediaWikiLangTestCase { + /** + * @var FileContentHandler + */ + private $handler; + + protected function setUp() { + parent::setUp(); + + $this->handler = new FileContentHandler(); + } + + public function testIndexMapping() { + $mockEngine = $this->createMock( SearchEngine::class ); + + $mockEngine->expects( $this->atLeastOnce() ) + ->method( 'makeSearchFieldMapping' ) + ->willReturnCallback( function ( $name, $type ) { + $mockField = + $this->getMockBuilder( SearchIndexFieldDefinition::class ) + ->setMethods( [ 'getMapping' ] ) + ->setConstructorArgs( [ $name, $type ] ) + ->getMock(); + return $mockField; + } ); + + $map = $this->handler->getFieldsForSearchIndex( $mockEngine ); + $expect = [ + 'file_media_type' => 1, + 'file_mime' => 1, + 'file_size' => 1, + 'file_width' => 1, + 'file_height' => 1, + 'file_bits' => 1, + 'file_resolution' => 1, + 'file_text' => 1, + ]; + foreach ( $map as $name => $field ) { + $this->assertInstanceOf( SearchIndexField::class, $field ); + $this->assertEquals( $name, $field->getName() ); + unset( $expect[$name] ); + } + $this->assertEmpty( $expect ); + } +} |