Merge "SpecialNewPages: Fix omitted Show/Hide redirect value"
[lhc/web/wiklou.git] / tests / phpunit / mocks / search / MockSearchResultSet.php
1 <?php
2
3 class MockSearchResultSet extends SearchResultSet {
4 /*
5 * @var SearchResultSet[][] Map from result type to list of results for
6 * that type.
7 */
8 private $interwikiResults;
9
10 /**
11 * @param SearchResult[] $results
12 * @param SearchResultSet[][] $interwikiResults Map from result type
13 * to list of results for that type.
14 */
15 public function __construct( array $results, array $interwikiResults = [] ) {
16 parent::__construct( false, false );
17 $this->results = $results;
18 $this->interwikiResults = $interwikiResults;
19 }
20
21 public function numRows() {
22 return count( $this->results );
23 }
24
25 public function hasInterwikiResults( $type = self::SECONDARY_RESULTS ) {
26 return isset( $this->interwikiResults[$type] ) &&
27 count( $this->interwikiResults[$type] ) > 0;
28 }
29
30 public function getInterwikiResults( $type = self::SECONDARY_RESULTS ) {
31 if ( $this->hasInterwikiResults( $type ) ) {
32 return $this->interwikiResults[$type];
33 } else {
34 return null;
35 }
36 }
37 }