|
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
|
|
|
|