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' )->handlers;
62 TestingAccessWrapper::newFromClass(
'Hooks' )->handlers = [];
65 MWNamespace::getCanonicalNamespaces(
true );
66 Language::factory(
'en' )->resetNamespaces();
80 if ( $results ===
null ) {
84 'PrefixSearchBackend' => [
85 function (
$namespaces, $search, $limit, &$srchres ) use ( $results ) {
102 'Main namespace with title prefix',
115 'Talk namespace prefix',
123 'User namespace prefix',
130 'Special namespace prefix',
131 'query' =>
'Special:',
133 'Special:ActiveUsers',
134 'Special:AllMessages',
135 'Special:AllMyUploads',
143 'Special namespace with prefix',
144 'query' =>
'Special:Un',
147 'Special:UncategorizedCategories',
148 'Special:UncategorizedFiles',
152 'Special:UncategorizedPages',
157 'query' =>
'Special:EditWatchlist',
159 'Special:EditWatchlist',
163 'Special page subpages',
164 'query' =>
'Special:EditWatchlist/',
166 'Special:EditWatchlist/clear',
167 'Special:EditWatchlist/raw',
171 'Special page subpages with prefix',
172 'query' =>
'Special:EditWatchlist/cl',
174 'Special:EditWatchlist/clear',
178 'Namespace with case sensitive first letter',
179 'query' =>
'NonCap:upper',
183 'Multinamespace search',
192 'Multinamespace search with lowercase first letter',
211 $namespaces = isset( $case[
'namespaces'] ) ? $case[
'namespaces'] : [];
215 sort( $case[
'results'], SORT_STRING );
235 $namespaces = isset( $case[
'namespaces'] ) ? $case[
'namespaces'] : [];
242 sort( $case[
'results'], SORT_STRING );
246 array_shift( $case[
'results'] );
248 $expected = isset( $case[
'offsetresult'] ) ?
249 array_merge( $case[
'results'], $case[
'offsetresult'] ) :
276 'Exact match not on top (T72958)',
290 'Exact match missing (T72958)',
304 'Exact match missing and not existing',
318 "Exact match shouldn't override already found match if " .
319 "exact is redirect and found isn't",
322 'Redirect Test Worse Result',
325 'query' =>
'redirect test',
329 'Redirect Test Worse Result',
333 "Exact match shouldn't override already found match if " .
334 "both exact match and found match are redirect",
338 'Redirect Test2 Worse Result',
341 'query' =>
'redirect TEST2',
346 'Redirect Test2 Worse Result',
350 "Exact match should override any already found matches that " .
351 "are redirects to it",
355 'Redirect Test Worse Result',
358 'query' =>
'Redirect Test',
363 'Redirect Test Worse Result',
376 $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