Merge "rest: Return a 400 for invalid render IDs"
[mediawiki.git] / tests / phpunit / includes / specials / SpecialSearchTestMockResultSet.php
blob566a0f6d1563792debaa3d3b1c35aabe59e9ff98
1 <?php
3 use MediaWiki\Title\Title;
5 class SpecialSearchTestMockResultSet extends SearchResultSet {
7 private ?string $suggestion;
8 private ?string $rewrittenQuery;
10 public function __construct(
11 ?string $suggestion = null,
12 ?string $rewrittenQuery = null,
13 array $results = [],
14 bool $containedSyntax = false
15 ) {
16 $this->suggestion = $suggestion;
17 $this->rewrittenQuery = $rewrittenQuery;
18 $this->results = $results;
19 $this->containedSyntax = $containedSyntax;
22 public function getTotalHits() {
23 return $this->numRows();
26 public function hasSuggestion() {
27 return $this->suggestion !== null;
30 public function getSuggestionQuery() {
31 return $this->suggestion;
34 public function getSuggestionSnippet() {
35 return $this->suggestion;
38 public function hasRewrittenQuery() {
39 return $this->rewrittenQuery !== null;
42 public function getQueryAfterRewrite() {
43 return $this->rewrittenQuery;
46 public function getQueryAfterRewriteSnippet() {
47 return htmlspecialchars( $this->rewrittenQuery );
50 public function getFirstResult(): ?Title {
51 $first = reset( $this->results );
52 return $first ? $first->getTitle() : null;