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();
76 'T35270: No request nor user preferences should give default profile'
81 'Web request with specific NS should override user preference'
90 'advanced', [ 2, 14 ],
91 'T35583: search with no option should honor User search preferences'
92 .
' and have all other namespace disabled'
104 if (
$opt ===
null ) {
108 $u->setOption( $name,
$value );
121 'wgSearchType' =>
null,
124 # Initialize [[Special::Search]]
126 $term =
'{{SITENAME}}';
127 $ctx->setRequest(
new FauxRequest( [
'search' =>
$term,
'fulltext' => 1 ] ) );
128 $ctx->setTitle( Title::newFromText(
'Special:Search' ) );
130 $search->setContext( $ctx );
132 # Simulate a user searching for a given term
133 $search->execute(
'' );
135 # Lookup the HTML page title set for that page
145 "Search term '{$term}' should not be expanded in Special:Search <title>"
152 'With suggestion and no rewritten query shows did you mean',
153 '/Did you mean: <a[^>]+>first suggestion/',
156 [ Title::newMainPage() ]
160 'With rewritten query informs user of change',
161 '/Showing results for <a[^>]+>first suggestion/',
164 [ Title::newMainPage() ]
168 'When both queries have no results user gets no results',
169 '/There were no results matching the query/',
188 $results =
array_map(
function ( $title ) {
189 return SearchResult::newFromTitle( $title );
200 ->setMethods( [
'getSearchEngine' ] )
202 $search->expects( $this->
any() )
203 ->method(
'getSearchEngine' )
206 $search->getContext()->setTitle( Title::makeTitle(
NS_SPECIAL,
'Search' ) );
207 $search->getContext()->setLanguage( Language::factory(
'en' ) );
209 $search->showResults(
'this is a fake search' );
211 $html = $search->getContext()->getOutput()->getHTML();
212 foreach ( (
array)$expectRegex as $regex ) {
219 ->setMethods( [
'searchText',
'searchTitle' ] )
222 $mock->expects( $this->
any() )
223 ->method(
'searchText' )
234 'wgScript' =>
'/w/index.php',
238 $sp = Title::newFromText(
'Special:Search/foo_bar' );
239 MediaWikiServices::getInstance()->getSpecialPageFactory()->executePath( $sp, $ctx );
240 $url = $ctx->getOutput()->getRedirect();
260 $rewrittenQuery =
null,
279 return $this->suggestion !==
null;
291 return $this->rewrittenQuery !==
null;
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
WebRequest clone which takes values from a provided array.
Group all the pieces relevant to the context of a request into one instance.
$containedSyntax
Types of interwiki results.
hasRewrittenQuery()
Some search modes will run an alternative query that it thinks gives a better result than the provide...
getTotalHits()
Some search modes return a total hit count for the query in the entire article database.
__construct( $suggestion=null, $rewrittenQuery=null, array $results=[], $containedSyntax=false)
hasSuggestion()
Some search modes return a suggested alternate term if there are no exact hits.
getQueryAfterRewriteSnippet()
Test class for SpecialSearch class Copyright © 2012, Antoine Musso.
testSearchTermIsNotExpanded()
Verify we do not expand search term in <title> on search result page https://gerrit....
mockSearchEngine( $results)
testProfileAndNamespaceLoading( $requested, $userOptions, $expectedProfile, $expectedNS, $message='Profile name and namespaces mismatches!')
SpecialSearch::load provideSearchOptionsTests.
newUserWithSearchNS( $opt=null)
Helper to create a new User object with given options User remains anonymous though.
testRewriteQueryWithSuggestion( $message, $expectRegex, $suggestion, $rewrittenQuery, array $resultTitles)
provideRewriteQueryWithSuggestion SpecialSearch::showResults
testSubPageRedirect()
SpecialSearch::execute.
static provideSearchOptionsTests()
provideRewriteQueryWithSuggestion()
implements Special:Search - Run text & title search and display the output
static newFromId( $id)
Static factory method for creation from a given user ID.
whereas SearchGetNearMatch runs after $term
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
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
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
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))