Convert SearchResultSet to typical iteration
[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 $this->results = $results;
17 $this->interwikiResults = $interwikiResults;
18 }
19
20 public function numRows() {
21 return count( $this->results );
22 }
23
24 public function hasInterwikiResults( $type = self::SECONDARY_RESULTS ) {
25 return isset( $this->interwikiResults[$type] ) &&
26 count( $this->interwikiResults[$type] ) > 0;
27 }
28
29 public function getInterwikiResults( $type = self::SECONDARY_RESULTS ) {
30 if ( $this->hasInterwikiResults( $type ) ) {
31 return $this->interwikiResults[$type];
32 } else {
33 return null;
34 }
35 }
36 }