4 * @group ContentHandler
6 class TextContentHandlerTest
extends MediaWikiLangTestCase
{
7 public function testSupportsDirectEditing() {
8 $handler = new TextContentHandler();
9 $this->assertTrue( $handler->supportsDirectEditing(), 'direct editing is supported' );
13 * @covers SearchEngine::makeSearchFieldMapping
14 * @covers ContentHandler::getFieldsForSearchIndex
16 public function testFieldsForIndex() {
17 $handler = new TextContentHandler();
19 $mockEngine = $this->getMock( 'SearchEngine' );
21 $mockEngine->expects( $this->atLeastOnce() )
22 ->method( 'makeSearchFieldMapping' )
23 ->willReturnCallback( function ( $name, $type ) {
25 $this->getMockBuilder( 'SearchIndexFieldDefinition' )
26 ->setConstructorArgs( [ $name, $type ] )
28 $mockField->expects( $this->atLeastOnce() )->method( 'getMapping' )->willReturn( [
37 * @var $mockEngine SearchEngine
39 $fields = $handler->getFieldsForSearchIndex( $mockEngine );
41 foreach ( $fields as $name => $field ) {
42 $this->assertInstanceOf( 'SearchIndexField', $field );
44 * @var $field SearchIndexField
46 $mappedFields[$name] = $field->getMapping( $mockEngine );
48 $this->assertArrayHasKey( 'language', $mappedFields );
49 $this->assertEquals( 'test', $mappedFields['language']['testData'] );
50 $this->assertEquals( 'language', $mappedFields['language']['name'] );