MediaWiki REL1_32
MockSearchEngine.php
Go to the documentation of this file.
1<?php
2
4
7 private static $results = [];
9 private static $interwikiResults = [];
10
11 public static function clearMockResults() {
12 self::$results = [];
13 self::$interwikiResults = [];
14 }
15
21 public static function addMockResults( $query, array $results ) {
22 $lc = MediaWikiServices::getInstance()->getLinkCache();
23 foreach ( $results as &$result ) {
24 // Resolve deferred results; needed to work around T203279
25 if ( is_callable( $result ) ) {
26 $result = $result();
27 }
28
29 // TODO: better page ids? Does it matter?
30 $lc->addGoodLinkObj( mt_rand(), $result->getTitle() );
31 }
32 self::$results[$query] = $results;
33 }
34
39 self::$interwikiResults = $interwikiResults;
40 }
41
42 protected function doSearchText( $term ) {
43 if ( isset( self::$results[ $term ] ) ) {
44 $results = array_slice( self::$results[ $term ], $this->offset, $this->limit );
45 } else {
46 $results = [];
47 }
48 return new MockSearchResultSet( $results, self::$interwikiResults );
49 }
50}
MediaWikiServices is the service locator for the application scope of MediaWiki.
static SearchResult[][] $results
doSearchText( $term)
Perform a full text search query and return a result set.
static setMockInterwikiResults(array $interwikiResults)
static addMockResults( $query, array $results)
static SearchResultSet[][] $interwikiResults
Contain a class for special pages.
namespace being checked & $result
Definition hooks.txt:2385
For QUnit the mediawiki tests qunit testrunner dependency will be added to any module whereas SearchGetNearMatch runs after $term
Definition hooks.txt:2926
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
Definition hooks.txt:1656
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))