25 $dbType = $this->db->getType();
26 $dbSupported = ( $dbType ===
'mysql' )
27 || ( $dbType ===
'sqlite' && $this->db->getFulltextSearchModule() ==
'FTS3' );
29 if ( !$dbSupported ) {
30 $this->markTestSkipped(
"MySQL or SQLite with FTS3 only" );
33 $searchType = $this->db->getSearchEngine();
35 'wgSearchType' => $searchType
38 $this->search =
new $searchType( $this->db );
42 unset( $this->search );
57 $this->
insertPage(
'Not_Main_Page',
'This is not a main page' );
60 'This is not a talk page to the main page, see [[smithee]]'
62 $this->
insertPage(
'Smithee',
'A smithee is one who smiths. See also [[Alan Smithee]]' );
63 $this->
insertPage(
'Talk:Smithee',
'This article sucks.' );
64 $this->
insertPage(
'Unrelated_page',
'Nothing in this page is about the S word.' );
65 $this->
insertPage(
'Another_page',
'This page also is unrelated.' );
74 $this->
insertPage(
'HalfNumbers',
'1234567890' );
75 $this->
insertPage(
'FullNumbers',
'1234567890' );
76 $this->
insertPage(
'DomainName',
'example.com' );
81 $this->markTestIncomplete( __CLASS__ .
" does no yet support non-wikitext content "
82 .
"in the main namespace" );
84 $this->assertTrue( is_object( $results ) );
87 $row = $results->next();
89 $matches[] = $row->getTitle()->getPrefixedText();
90 $row = $results->next();
93 # Search is not guaranteed to return results in a certain order;
94 # sort them numerically so we will compare simply that we received
95 # the expected matches.
103 [
'FullOneUp',
'FullTwoLow',
'HalfOneUp',
'HalfTwoLow' ],
104 $this->
fetchIds( $this->search->searchText(
'AZ' ) ),
105 "Search for normalized from Half-width Upper" );
107 [
'FullOneUp',
'FullTwoLow',
'HalfOneUp',
'HalfTwoLow' ],
108 $this->
fetchIds( $this->search->searchText(
'az' ) ),
109 "Search for normalized from Half-width Lower" );
111 [
'FullOneUp',
'FullTwoLow',
'HalfOneUp',
'HalfTwoLow' ],
112 $this->
fetchIds( $this->search->searchText(
'AZ' ) ),
113 "Search for normalized from Full-width Upper" );
115 [
'FullOneUp',
'FullTwoLow',
'HalfOneUp',
'HalfTwoLow' ],
116 $this->
fetchIds( $this->search->searchText(
'az' ) ),
117 "Search for normalized from Full-width Lower" );
123 $this->
fetchIds( $this->search->searchText(
'smithee' ) ),
124 "Plain search failed" );
128 $this->search->setNamespaces( [ 0, 1, 4 ] );
132 'Talk:Not Main Page',
134 $this->
fetchIds( $this->search->searchText(
'smithee' ) ),
135 "Power search failed" );
144 $this->
fetchIds( $this->search->searchTitle(
'smithee' ) ),
145 "Title search failed" );
149 $this->search->setNamespaces( [ 0, 1, 4 ] );
156 $this->
fetchIds( $this->search->searchTitle(
'smithee' ) ),
157 "Title power search failed" );
167 $mockEngine = $this->getMock(
'SearchEngine', [
'makeSearchFieldMapping' ] );
169 $mockFieldBuilder =
function (
$name,
$type ) {
171 $this->getMockBuilder(
'SearchIndexFieldDefinition' )->setConstructorArgs( [
175 $mockField->expects( $this->any() )->method(
'getMapping' )->willReturn( [
176 'testData' =>
'test',
183 $mockEngine->expects( $this->atLeastOnce() )
184 ->method(
'makeSearchFieldMapping' )
185 ->willReturnCallback( $mockFieldBuilder );
189 [
'SearchIndexFields' => [ [ $this,
'hookSearchIndexFields', $mockFieldBuilder ] ] ] );
191 $fields = $mockEngine->getSearchIndexFields();
192 $this->assertArrayHasKey(
'language', $fields );
193 $this->assertArrayHasKey(
'category', $fields );
194 $this->assertInstanceOf(
'SearchIndexField', $fields[
'testField'] );
196 $mapping = $fields[
'testField']->getMapping( $mockEngine );
197 $this->assertArrayHasKey(
'testData', $mapping );
198 $this->assertEquals(
'test', $mapping[
'testData'] );
const INDEX_TYPE_TEXT
Field types.
setUp()
Checks for database type & version.
testSearchIndexFields()
SearchEngine::getSearchIndexFields.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Contain a class for special pages.
hookSearchIndexFields($mockFieldBuilder, &$fields, SearchEngine $engine)
testTextTitlePowerSearch()
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Allows to change the fields on the form that will be generated $name