Completed
Push — master ( 9e1461...cdd4b1 )
by
unknown
13:17
created

MappedSearchResultSetTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 74
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanConstruct() 0 10 1
A testEmptyResulSet() 0 29 1
A testNextSearchResult() 0 29 1
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
	public function testCanConstruct() {
22
23
		$searchMatches = array();
24
		$termMatches = array();
25
26
		$this->assertInstanceOf(
27
			'\SIL\Search\MappedSearchResultSet',
28
			new MappedSearchResultSet( $searchMatches, $termMatches )
29
		);
30
	}
31
32
	public function testEmptyResulSet() {
33
34
		$searchMatches = array();
35
		$termMatches = array();
36
37
		$instance = new MappedSearchResultSet( $searchMatches, $termMatches, 42 );
38
39
		$this->assertEquals(
40
			0,
41
			$instance->numRows()
42
		);
43
44
		$this->assertFalse(
45
			$instance->hasResults()
46
		);
47
48
		$this->assertEquals(
49
			42,
50
			$instance->getTotalHits()
51
		);
52
53
		$this->assertEmpty(
54
			$instance->termMatches()
55
		);
56
57
		$this->assertFalse(
58
			$instance->next()
59
		);
60
	}
61
62
	public function testNextSearchResult() {
63
64
		$searchResult = $this->getMockBuilder( '\SearchResult' )
65
			->disableOriginalConstructor()
66
			->getMock();
67
68
		$fakeTitle = $this->getMockBuilder( '\Title' )
69
			->disableOriginalConstructor()
70
			->getMock();
71
72
		$searchMatches = array( $searchResult, $fakeTitle, 'Foo' );
73
		$termMatches = array();
74
75
		$instance = new MappedSearchResultSet( $searchMatches, $termMatches );
76
77
		$this->assertEquals(
78
			$searchResult,
79
			$instance->next()
80
		);
81
82
		$this->assertInstanceOf(
83
			'\SearchResult',
84
			$instance->next()
85
		);
86
87
		$this->assertFalse(
88
			$instance->next()
89
		);
90
	}
91
92
}
93