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' );
57 $this->markTestSkipped(
'Main namespace does not support wikitext.' );
62 'wgSpecialPages' => [],
66 $this->search = MediaWikiServices::getInstance()->newSearchEngine();
67 $this->search->setNamespaces( [] );
69 $this->originalHandlers = TestingAccessWrapper::newFromClass( Hooks::class )->handlers;
70 TestingAccessWrapper::newFromClass( Hooks::class )->handlers = [];
82 if ( $results ===
null ) {
86 'PrefixSearchBackend' => [
104 'Main namespace with title prefix',
117 'Talk namespace prefix',
125 'User namespace prefix',
132 'Special namespace prefix',
133 'query' =>
'Special:',
135 'Special:ActiveUsers',
136 'Special:AllMessages',
137 'Special:AllMyUploads',
145 'Special namespace with prefix',
146 'query' =>
'Special:Un',
149 'Special:UncategorizedCategories',
150 'Special:UncategorizedFiles',
154 'Special:UncategorizedPages',
159 'query' =>
'Special:EditWatchlist',
161 'Special:EditWatchlist',
165 'Special page subpages',
166 'query' =>
'Special:EditWatchlist/',
168 'Special:EditWatchlist/clear',
169 'Special:EditWatchlist/raw',
173 'Special page subpages with prefix',
174 'query' =>
'Special:EditWatchlist/cl',
176 'Special:EditWatchlist/clear',
187 $this->search->setLimitOffset( 3 );
188 $results = $this->search->defaultPrefixSearch( $case[
'query'] );
189 $results = array_map(
function (
Title $t ) {
190 return $t->getPrefixedText();
205 $this->search->setLimitOffset( 3, 1 );
206 $results = $this->search->defaultPrefixSearch( $case[
'query'] );
207 $results = array_map(
function (
Title $t ) {
208 return $t->getPrefixedText();
212 array_shift( $case[
'results'] );
214 $expected = isset( $case[
'offsetresult'] ) ?
215 array_merge( $case[
'results'], $case[
'offsetresult'] ) :
242 'Exact match not in first result should be moved to the first result (T72958)',
256 'Exact match missing from results should be added as first result (T72958)',
270 'Exact match missing and not existing pages should be dropped',
282 "Exact match shouldn't override already found match if " .
283 "exact is redirect and found isn't",
286 'Redirect Test Worse Result',
289 'query' =>
'redirect test',
293 'Redirect Test Worse Result',
297 "Exact match shouldn't override already found match if " .
298 "both exact match and found match are redirect",
302 'Redirect Test2 Worse Result',
305 'query' =>
'redirect TEST2',
310 'Redirect Test2 Worse Result',
314 "Exact match should override any already found matches that " .
315 "are redirects to it",
319 'Redirect Test Worse Result',
322 'query' =>
'Redirect Test',
327 'Redirect Test Worse Result',
332 "Extra results must not be returned",
358 return $s->getText();
369 $res = [
'Example',
'Example Bar',
'Example Foo',
'Example Foo/Bar' ];
371 'With less than requested results no pagination' => [
372 false, array_slice(
$res, 0, 2 ),
374 'With same as requested results no pagination' => [
375 false, array_slice(
$res, 0, 3 ),
377 'With extra result returned offer pagination' => [
390 $this->assertEquals( $hasMoreResults, $results->hasMoreResults() );
394 $search = $stub = $this->getMockBuilder( SearchEngine::class )
395 ->setMethods( [
'completionSearchBackend' ] )->getMock();
399 $search->expects( $this->any() )
400 ->method(
'completionSearchBackend' )
401 ->will( $this->returnValue( $return ) );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
mockSearchWithResults( $titleStrings, $limit=3)
testSearchBackend(array $case)
provideSearchBackend PrefixSearch::searchBackend
testSearchWithOffset(array $case)
provideSearch SearchEngine::defaultPrefixSearch
static provideSearchBackend()
testSearch(array $case)
provideSearch SearchEngine::defaultPrefixSearch
searchProvision(array $results=null)
testPagination( $hasMoreResults, $provision)
paginationProvider
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, $hasMoreResults=false)
Builds a new set of suggestion based on a string array.
Represents a title within MediaWiki.
namespace and then decline to actually register it & $namespaces
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))