BetweenQueryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 0
cbo 3
dl 0
loc 37
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetPropertyId() 0 4 1
A testGetType() 0 4 1
A testGetBeginValue() 0 11 1
A testGetEndValue() 0 11 1
1
<?php
2
3
namespace WikidataQueryApi\Query;
4
5
use DataValues\TimeValue;
6
use Wikibase\DataModel\Entity\PropertyId;
7
8
/**
9
 * @covers WikidataQueryApi\Query\BetweenQuery
10
 *
11
 * @licence GPLv2+
12
 * @author Thomas Pellissier Tanon
13
 */
14
class BetweenQueryTest extends \PHPUnit_Framework_TestCase {
15
16
	public function testGetPropertyId() {
17
		$query = new BetweenQuery( new PropertyId( 'P42' ) );
18
		$this->assertEquals( new PropertyId( 'P42' ), $query->getPropertyId() );
19
	}
20
21
	public function testGetBeginValue() {
22
		$query = new BetweenQuery(
23
			new PropertyId( 'P42' ),
24
			new TimeValue( '+1952-03-11T00:00:00Z', 0, 0, 0, TimeValue::PRECISION_DAY, 'foo' ),
25
			new TimeValue( '+1952-03-12T00:00:00Z', 0, 0, 0, TimeValue::PRECISION_DAY, 'foo' )
26
		);
27
		$this->assertEquals(
28
			new TimeValue( '+1952-03-11T00:00:00Z', 0, 0, 0, TimeValue::PRECISION_DAY, 'foo' ),
29
			$query->getBeginValue()
30
		);
31
	}
32
33
34
	public function testGetEndValue() {
35
		$query = new BetweenQuery(
36
			new PropertyId( 'P42' ),
37
			new TimeValue( '+1952-03-11T00:00:00Z', 0, 0, 0, TimeValue::PRECISION_DAY, 'foo' ),
38
			new TimeValue( '+1952-03-12T00:00:00Z', 0, 0, 0, TimeValue::PRECISION_DAY, 'foo' )
39
		);
40
		$this->assertEquals(
41
			new TimeValue( '+1952-03-12T00:00:00Z', 0, 0, 0, TimeValue::PRECISION_DAY, 'foo' ),
42
			$query->getEndValue()
43
		);
44
	}
45
46
	public function testGetType() {
47
		$query = new BetweenQuery( new PropertyId( 'P42' ) );
48
		$this->assertEquals( 'between', $query->getType() );
49
	}
50
}
51