QueryResultFactoryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 68
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testCanConstruct() 0 7 1
A testNewEmptyQueryResult() 0 21 1
A testNewByHttpLookupQueryResult() 0 25 1
1
<?php
2
3
namespace SEQL\Tests;
4
5
use SEQL\QueryResultFactory;
6
7
/**
8
 * @covers \SEQL\QueryResultFactory
9
 * @group semantic-external-query-lookup
10
 *
11
 * @license GNU GPL v2+
12
 * @since 1.0
13
 *
14
 * @author mwjames
15
 */
16
class QueryResultFactoryTest extends \PHPUnit_Framework_TestCase {
17
18
	private $store;
19
20
	protected function setUp() {
21
22
		$this->store = $this->getMockBuilder( '\SMW\Store' )
23
			->disableOriginalConstructor()
24
			->getMockForAbstractClass();
25
	}
26
27
	public function testCanConstruct() {
28
29
		$this->assertInstanceOf(
30
			'\SEQL\QueryResultFactory',
31
			new QueryResultFactory( $this->store )
32
		);
33
	}
34
35
	public function testNewEmptyQueryResult() {
36
37
		$description = $this->getMockBuilder( '\SMW\Query\Language\Description' )
38
			->disableOriginalConstructor()
39
			->getMockForAbstractClass();
40
41
		$query = $this->getMockBuilder( '\SMWQuery' )
42
			->disableOriginalConstructor()
43
			->getMock();
44
45
		$query->expects( $this->any() )
46
			->method( 'getDescription' )
47
			->will( $this->returnValue( $description ) );
48
49
		$instance = new QueryResultFactory( $this->store );
50
51
		$this->assertInstanceOf(
52
			'\SMWQueryResult',
53
			$instance->newEmptyQueryResult( $query )
54
		);
55
	}
56
57
	public function testNewByHttpLookupQueryResult() {
58
59
		$jsonResponseParser = $this->getMockBuilder( '\SEQL\ByHttpRequest\JsonResponseParser' )
60
			->disableOriginalConstructor()
61
			->getMockForAbstractClass();
62
63
		$description = $this->getMockBuilder( '\SMW\Query\Language\Description' )
64
			->disableOriginalConstructor()
65
			->getMockForAbstractClass();
66
67
		$query = $this->getMockBuilder( '\SMWQuery' )
68
			->disableOriginalConstructor()
69
			->getMock();
70
71
		$query->expects( $this->any() )
72
			->method( 'getDescription' )
73
			->will( $this->returnValue( $description ) );
74
75
		$instance = new QueryResultFactory( $this->store );
76
77
		$this->assertInstanceOf(
78
			'\SMWQueryResult',
79
			$instance->newByHttpRequestQueryResult( $query, $jsonResponseParser )
80
		);
81
	}
82
83
}
84