Add @covers tags to ContentHandler tests
[lhc/web/wiklou.git] / tests / phpunit / includes / content / TextContentHandlerTest.php
1 <?php
2
3 /**
4 * @group ContentHandler
5 */
6 class TextContentHandlerTest extends MediaWikiLangTestCase {
7 /**
8 * @covers TextContentHandler::supportsDirectEditing
9 */
10 public function testSupportsDirectEditing() {
11 $handler = new TextContentHandler();
12 $this->assertTrue( $handler->supportsDirectEditing(), 'direct editing is supported' );
13 }
14
15 /**
16 * @covers SearchEngine::makeSearchFieldMapping
17 * @covers ContentHandler::getFieldsForSearchIndex
18 */
19 public function testFieldsForIndex() {
20 $handler = new TextContentHandler();
21
22 $mockEngine = $this->createMock( 'SearchEngine' );
23
24 $mockEngine->expects( $this->atLeastOnce() )
25 ->method( 'makeSearchFieldMapping' )
26 ->willReturnCallback( function ( $name, $type ) {
27 $mockField =
28 $this->getMockBuilder( 'SearchIndexFieldDefinition' )
29 ->setConstructorArgs( [ $name, $type ] )
30 ->getMock();
31 $mockField->expects( $this->atLeastOnce() )->method( 'getMapping' )->willReturn( [
32 'testData' => 'test',
33 'name' => $name,
34 'type' => $type,
35 ] );
36 return $mockField;
37 } );
38
39 /**
40 * @var $mockEngine SearchEngine
41 */
42 $fields = $handler->getFieldsForSearchIndex( $mockEngine );
43 $mappedFields = [];
44 foreach ( $fields as $name => $field ) {
45 $this->assertInstanceOf( 'SearchIndexField', $field );
46 /**
47 * @var $field SearchIndexField
48 */
49 $mappedFields[$name] = $field->getMapping( $mockEngine );
50 }
51 $this->assertArrayHasKey( 'language', $mappedFields );
52 $this->assertEquals( 'test', $mappedFields['language']['testData'] );
53 $this->assertEquals( 'language', $mappedFields['language']['name'] );
54 }
55 }