Completed
Push — master ( dab420...bd7180 )
by mw
33:01 queued 12:20
created

MappedSearchResultSetTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SIL\Tests\Search;
4
5
use SIL\Search\MappedSearchResultSet;
6
7
use SMW\DIProperty;
8
9
/**
10
 * @covers \SIL\Search\MappedSearchResultSet
11
 *
12
 * @group semantic-interlanguage-links
13
 *
14
 * @license GNU GPL v2+
15
 * @since 1.0
16
 *
17
 * @author mwjames
18
 */
19
class MappedSearchResultSetTest extends \PHPUnit_Framework_TestCase {
20
21
	protected function setUp() : void {
22
		$this->markTestSkipped( 'The each() function is deprecated. This message will be suppressed on further calls' );
23
	}
24
25
	public function testCanConstruct() {
26
27
		$searchMatches = [];
28
		$termMatches = [];
29
30
		$this->assertInstanceOf(
31
			'\SIL\Search\MappedSearchResultSet',
32
			new MappedSearchResultSet( $searchMatches, $termMatches )
33
		);
34
	}
35
36
	public function testEmptyResulSet() {
37
38
		$searchMatches = [];
39
		$termMatches = [];
40
41
		$instance = new MappedSearchResultSet( $searchMatches, $termMatches, 42 );
42
43
		$this->assertEquals(
44
			0,
45
			$instance->numRows()
46
		);
47
48
		$this->assertFalse(
49
			$instance->hasResults()
50
		);
51
52
		$this->assertEquals(
53
			42,
54
			$instance->getTotalHits()
55
		);
56
57
		$this->assertEmpty(
58
			$instance->termMatches()
59
		);
60
61
		$this->assertFalse(
62
			$instance->next()
63
		);
64
	}
65
66
	public function testNextSearchResult() {
67
68
		$searchResult = $this->getMockBuilder( '\SearchResult' )
69
			->disableOriginalConstructor()
70
			->getMock();
71
72
		$fakeTitle = $this->getMockBuilder( '\Title' )
73
			->disableOriginalConstructor()
74
			->getMock();
75
76
		$searchMatches = [ $searchResult, $fakeTitle, 'Foo' ];
77
		$termMatches = [];
78
79
		$instance = new MappedSearchResultSet( $searchMatches, $termMatches );
80
81
		$this->assertEquals(
82
			$searchResult,
83
			$instance->next()
84
		);
85
86
		$this->assertInstanceOf(
87
			'\SearchResult',
88
			$instance->next()
89
		);
90
91
		$this->assertFalse(
92
			$instance->next()
93
		);
94
	}
95
96
}
97