Call parent::getFieldsForSearchIndex in ContentHandlers
authoraude <aude.wiki@gmail.com>
Mon, 15 Aug 2016 16:37:00 +0000 (12:37 -0400)
committeraude <aude.wiki@gmail.com>
Mon, 15 Aug 2016 23:33:09 +0000 (19:33 -0400)
ContentHandler implementations were not including fields
defined by their parent ContentHandler classes.

merge method is added to the SearchIndexFieldDefinition
mock in SearchEngineTest, to allow merges of fields
in the way that SearchIndexFieldDefition implementation does.

Change-Id: Id04a51528f566da2666bad0394a2f61c949c69b4

includes/content/CodeContentHandler.php
includes/content/TextContentHandler.php
includes/content/WikitextContentHandler.php
tests/phpunit/includes/search/SearchEngineTest.php

index 2bbf6ca..20893bb 100644 (file)
@@ -64,11 +64,4 @@ abstract class CodeContentHandler extends TextContentHandler {
                throw new MWException( 'Subclass must override' );
        }
 
-       /**
-        * @param SearchEngine $engine
-        * @return array
-        */
-       public function getFieldsForSearchIndex( SearchEngine $engine ) {
-               return [];
-       }
 }
index 74cbd16..09cdcee 100644 (file)
@@ -143,9 +143,10 @@ class TextContentHandler extends ContentHandler {
        }
 
        public function getFieldsForSearchIndex( SearchEngine $engine ) {
-               $fields = [];
+               $fields = parent::getFieldsForSearchIndex( $engine );
                $fields['language'] =
                        $engine->makeSearchFieldMapping( 'language', SearchIndexField::INDEX_TYPE_KEYWORD );
+
                return $fields;
        }
 
index d9f1e86..9baf643 100644 (file)
@@ -109,7 +109,7 @@ class WikitextContentHandler extends TextContentHandler {
        }
 
        public function getFieldsForSearchIndex( SearchEngine $engine ) {
-               $fields = [];
+               $fields = parent::getFieldsForSearchIndex( $engine );
 
                $fields['category'] =
                        $engine->makeSearchFieldMapping( 'category', SearchIndexField::INDEX_TYPE_TEXT );
index 081cb38..0b34b6f 100644 (file)
@@ -172,11 +172,17 @@ class SearchEngineTest extends MediaWikiLangTestCase {
                                        $name,
                                        $type
                                ] )->getMock();
+
                        $mockField->expects( $this->any() )->method( 'getMapping' )->willReturn( [
                                'testData' => 'test',
                                'name' => $name,
                                'type' => $type,
                        ] );
+
+                       $mockField->expects( $this->any() )
+                               ->method( 'merge' )
+                               ->willReturn( $mockField );
+
                        return $mockField;
                };