4use 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::class )->handlers;
67 TestingAccessWrapper::newFromClass( Hooks::class )->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::class )
341 ->setMethods( [
'completionSearchBackend' ] )->getMock();
346 ->method(
'completionSearchBackend' )
347 ->will( $this->returnValue( $return ) );
353 return $s->getText();
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
testSearchBackend(array $case)
provideSearchBackend PrefixSearch::searchBackend
testSearchWithOffset(array $case)
provideSearch SearchEngine::defaultPrefixSearch
static provideSearchBackend()
testSearch(array $case)
provideSearch SearchEngine::defaultPrefixSearch
searchProvision(array $results=null)
Contain a class for special pages.
completionSearch( $search)
Perform a completion search.
setLimitOffset( $limit, $offset=0)
Set the maximum number of results to return and how many to skip before returning the first.
static fromStrings(array $titles)
Builds a new set of suggestion based on a string array.
static resetList()
Reset the internal list of special pages.
Represents a title within MediaWiki.
namespace and then decline to actually register it & $namespaces