3use Wikimedia\TestingAccessWrapper;
28 $this->
insertPage(
'Redirect test',
'#REDIRECT [[Redirect Test]]' );
30 $this->
insertPage(
'Redirect Test Worse Result' );
31 $this->
insertPage(
'Redirect test2',
'#REDIRECT [[Redirect Test2]]' );
32 $this->
insertPage(
'Redirect TEST2',
'#REDIRECT [[Redirect Test2]]' );
34 $this->
insertPage(
'Redirect Test2 Worse Result' );
41 $this->
insertPage( Title::makeTitle( self::NS_NONCAP,
'Bar' ) );
42 $this->
insertPage( Title::makeTitle( self::NS_NONCAP,
'Upper' ) );
43 $this->
insertPage( Title::makeTitle( self::NS_NONCAP,
'sandbox' ) );
50 $this->markTestSkipped(
'Main namespace does not support wikitext.' );
55 'wgSpecialPages' => [],
57 'wgExtraNamespaces' => [ self::NS_NONCAP =>
'NonCap' ],
58 'wgCapitalLinkOverrides' => [ self::NS_NONCAP =>
false ],
61 $this->originalHandlers = TestingAccessWrapper::newFromClass( Hooks::class )->handlers;
62 TestingAccessWrapper::newFromClass( Hooks::class )->handlers = [];
65 MWNamespace::clearCaches();
66 Language::factory(
'en' )->resetNamespaces();
72 MWNamespace::clearCaches();
73 Language::factory(
'en' )->resetNamespaces();
83 if ( $results ===
null ) {
87 'PrefixSearchBackend' => [
88 function (
$namespaces, $search, $limit, &$srchres ) use ( $results ) {
105 'Main namespace with title prefix',
118 'Talk namespace prefix',
126 'User namespace prefix',
133 'Special namespace prefix',
134 'query' =>
'Special:',
136 'Special:ActiveUsers',
137 'Special:AllMessages',
138 'Special:AllMyUploads',
146 'Special namespace with prefix',
147 'query' =>
'Special:Un',
150 'Special:UncategorizedCategories',
151 'Special:UncategorizedFiles',
155 'Special:UncategorizedPages',
160 'query' =>
'Special:EditWatchlist',
162 'Special:EditWatchlist',
166 'Special page subpages',
167 'query' =>
'Special:EditWatchlist/',
169 'Special:EditWatchlist/clear',
170 'Special:EditWatchlist/raw',
174 'Special page subpages with prefix',
175 'query' =>
'Special:EditWatchlist/cl',
177 'Special:EditWatchlist/clear',
181 'Namespace with case sensitive first letter',
182 'query' =>
'NonCap:upper',
186 'Multinamespace search',
195 'Multinamespace search with lowercase first letter',
214 $namespaces = isset( $case[
'namespaces'] ) ? $case[
'namespaces'] : [];
218 sort( $case[
'results'], SORT_STRING );
238 $namespaces = isset( $case[
'namespaces'] ) ? $case[
'namespaces'] : [];
245 sort( $case[
'results'], SORT_STRING );
249 array_shift( $case[
'results'] );
251 $expected = isset( $case[
'offsetresult'] ) ?
252 array_merge( $case[
'results'], $case[
'offsetresult'] ) :
279 'Exact match not on top (T72958)',
293 'Exact match missing (T72958)',
307 'Exact match missing and not existing',
321 "Exact match shouldn't override already found match if " .
322 "exact is redirect and found isn't",
325 'Redirect Test Worse Result',
328 'query' =>
'redirect test',
332 'Redirect Test Worse Result',
336 "Exact match shouldn't override already found match if " .
337 "both exact match and found match are redirect",
341 'Redirect Test2 Worse Result',
344 'query' =>
'redirect TEST2',
349 'Redirect Test2 Worse Result',
353 "Exact match should override any already found matches that " .
354 "are redirects to it",
358 'Redirect Test Worse Result',
361 'query' =>
'Redirect Test',
366 'Redirect Test Worse Result',
379 $results = $searcher->
search( $case[
'query'], 3 );
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Search Database PrefixSearch.
testSearch(array $case)
provideSearch PrefixSearch::search PrefixSearch::searchBackend
testSearchBackend(array $case)
provideSearchBackend PrefixSearch::searchBackend
searchProvision(array $results=null)
testSearchWithOffset(array $case)
provideSearch PrefixSearch::search PrefixSearch::searchBackend
static provideSearchBackend()
search( $search, $limit, $namespaces=[], $offset=0)
Do a prefix search of titles and return a list of matching page names.
static resetList()
Reset the internal list of special pages.
Performs prefix search, returning strings.
namespace and then decline to actually register it & $namespaces