Go to the documentation of this file.
4 use Wikimedia\TestingAccessWrapper;
36 $this->
insertPage(
'Redirect test',
'#REDIRECT [[Redirect Test]]' );
38 $this->
insertPage(
'Redirect Test Worse Result' );
39 $this->
insertPage(
'Redirect test2',
'#REDIRECT [[Redirect Test2]]' );
40 $this->
insertPage(
'Redirect TEST2',
'#REDIRECT [[Redirect Test2]]' );
42 $this->
insertPage(
'Redirect Test2 Worse Result' );
54 $this->markTestSkipped(
'Main namespace does not support wikitext.' );
59 'wgSpecialPages' => [],
63 $this->search = MediaWikiServices::getInstance()->newSearchEngine();
64 $this->search->setNamespaces( [] );
66 $this->originalHandlers = TestingAccessWrapper::newFromClass(
'Hooks' )->handlers;
67 TestingAccessWrapper::newFromClass(
'Hooks' )->handlers = [];
81 if ( $results ===
null ) {
85 'PrefixSearchBackend' => [
103 'Main namespace with title prefix',
116 'Talk namespace prefix',
124 'User namespace prefix',
131 'Special namespace prefix',
132 'query' =>
'Special:',
134 'Special:ActiveUsers',
135 'Special:AllMessages',
136 'Special:AllMyUploads',
144 'Special namespace with prefix',
145 'query' =>
'Special:Un',
148 'Special:UncategorizedCategories',
149 'Special:UncategorizedFiles',
153 'Special:UncategorizedPages',
158 'query' =>
'Special:EditWatchlist',
160 'Special:EditWatchlist',
164 'Special page subpages',
165 'query' =>
'Special:EditWatchlist/',
167 'Special:EditWatchlist/clear',
168 'Special:EditWatchlist/raw',
172 'Special page subpages with prefix',
173 'query' =>
'Special:EditWatchlist/cl',
175 'Special:EditWatchlist/clear',
186 $this->search->setLimitOffset( 3 );
187 $results = $this->search->defaultPrefixSearch( $case[
'query'] );
188 $results = array_map(
function (
Title $t ) {
189 return $t->getPrefixedText();
204 $this->search->setLimitOffset( 3, 1 );
205 $results = $this->search->defaultPrefixSearch( $case[
'query'] );
206 $results = array_map(
function (
Title $t ) {
207 return $t->getPrefixedText();
211 array_shift( $case[
'results'] );
213 $expected = isset( $case[
'offsetresult'] ) ?
214 array_merge( $case[
'results'], $case[
'offsetresult'] ) :
241 'Exact match not on top (T72958)',
255 'Exact match missing (T72958)',
269 'Exact match missing and not existing',
283 "Exact match shouldn't override already found match if " .
284 "exact is redirect and found isn't",
287 'Redirect Test Worse Result',
290 'query' =>
'redirect test',
294 'Redirect Test Worse Result',
298 "Exact match shouldn't override already found match if " .
299 "both exact match and found match are redirect",
303 'Redirect Test2 Worse Result',
306 'query' =>
'redirect TEST2',
311 'Redirect Test2 Worse Result',
315 "Exact match should override any already found matches that " .
316 "are redirects to it",
320 'Redirect Test Worse Result',
323 'query' =>
'Redirect Test',
328 'Redirect Test Worse Result',
340 $search = $stub = $this->getMockBuilder(
'SearchEngine' )
341 ->setMethods( [
'completionSearchBackend' ] )->getMock();
346 ->method(
'completionSearchBackend' )
347 ->will( $this->returnValue( $return ) );
353 return $s->getText();
testSearchWithOffset(array $case)
provideSearch SearchEngine::defaultPrefixSearch
namespace and then decline to actually register it & $namespaces
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
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
static provideSearchBackend()
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
static fromStrings(array $titles)
Builds a new set of suggestion based on a string array.
Contain a class for special pages.
completionSearch( $search)
Perform a completion search.
searchProvision(array $results=null)
Represents a title within MediaWiki.
testSearch(array $case)
provideSearch SearchEngine::defaultPrefixSearch
static resetList()
Reset the internal list of special pages.
testSearchBackend(array $case)
provideSearchBackend PrefixSearch::searchBackend
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 MediaWikiServices
setLimitOffset( $limit, $offset=0)
Set the maximum number of results to return and how many to skip before returning the first.
the array() calling protocol came about after MediaWiki 1.4rc1.