25 $expectedProfile, $expectedNS, $message =
'Profile name and namespaces mismatches!'
49 'ProfileName' => $expectedProfile,
50 'Namespaces' => $expectedNS,
53 'ProfileName' => $search->getProfile(),
54 'Namespaces' => $search->getNamespaces(),
61 $defaultNS = MediaWikiServices::getInstance()->getSearchEngineConfig()->defaultNamespaces();
74 $EMPTY_REQUEST, $NO_USER_PREF,
75 'default', $defaultNS,
76 'Bug 33270: No request nor user preferences should give default profile'
79 [
'ns5' => 1 ], $NO_USER_PREF,
81 'Web request with specific NS should override user preference'
87 ] + array_fill_keys( array_map(
function ( $ns ) {
90 'advanced', [ 2, 14 ],
91 'Bug 33583: search with no option should honor User search preferences'
92 .
' and have all other namespace disabled'
104 if ( $opt === null ) {
120 'wgSearchType' => null,
123 # Initialize [[Special::Search]]
128 # Simulate a user searching for a given term
129 $term =
'{{SITENAME}}';
130 $search->showResults(
$term );
132 # Lookup the HTML page title set for that page
140 '/' . preg_quote(
$term,
'/' ) .
'/',
142 "Search term '{$term}' should not be expanded in Special:Search <title>"
149 'With suggestion and no rewritten query shows did you mean',
150 '/Did you mean: <a[^>]+>first suggestion/',
157 'With rewritten query informs user of change',
158 '/Showing results for <a[^>]+>first suggestion/',
165 'When both queries have no results user gets no results',
166 '/There were no results matching the query/',
177 $search = $this->getMockBuilder(
'SpecialSearch' )
178 ->setMethods( [
'getSearchEngine' ] )
180 $search->expects( $this->any() )
181 ->method(
'getSearchEngine' )
182 ->will( $this->returnValue( $mockSearchEngine ) );
187 $search->showResults(
'this is a fake search' );
189 $html = $search->getContext()->getOutput()->getHTML();
190 foreach ( (
array)$expectRegex
as $regex ) {
191 $this->assertRegExp( $regex,
$html, $message );
196 $mock = $this->getMockBuilder(
'SearchEngine' )
197 ->setMethods( [
'searchText',
'searchTitle' ] )
200 $mock->expects( $this->any() )
201 ->method(
'searchText' )
202 ->will( $this->returnValue( $results ) );
214 $rewrittenQuery = null,
219 $this->rewrittenQuery = $rewrittenQuery;
225 return count( $this->results );
233 return $this->suggestion !== null;
245 return $this->rewrittenQuery !== null;
249 return $this->rewrittenQuery;
253 return htmlspecialchars( $this->rewrittenQuery );
testRewriteQueryWithSuggestion($message, $expectRegex, $results)
provideRewriteQueryWithSuggestion
external whereas SearchGetNearMatch runs after $term
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
the array() calling protocol came about after MediaWiki 1.4rc1.
Group all the pieces relevant to the context of a request into one instance.
static newMainPage()
Create a new Title for the Main Page.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
implements Special:Search - Run text & title search and display the output
newUserWithSearchNS($opt=null)
Helper to create a new User object with given options User remains anonymous though.
__construct($suggestion=null, $rewrittenQuery=null, array $results=[], $containedSyntax=false)
static newFromId($id)
Static factory method for creation from a given user ID.
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
getQueryAfterRewriteSnippet()
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static newFromTitle($title)
Return a new SearchResult and initializes it with a title.
testProfileAndNamespaceLoading($requested, $userOptions, $expectedProfile, $expectedNS, $message= 'Profile name and namespaces mismatches!')
SpecialSearch::load provideSearchOptionsTests.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
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
$containedSyntax
Types of interwiki results.
mockSearchEngine($results)
Test class for SpecialSearch class Copyright © 2012, Antoine Musso.
provideRewriteQueryWithSuggestion()
static factory($code)
Get a cached or new language object for a given language code.
static provideSearchOptionsTests()
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
testSearchTermIsNotExpanded()
Verify we do not expand search term in
on search result page https://gerrit.wikimedia.org/r/4841.
Allows to change the fields on the form that will be generated $name