PropertyListTest::testSetAndGetElements()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\Queryr\Resources\Builders;
4
5
use Queryr\Resources\PropertyList;
6
use Queryr\Resources\PropertyListElement;
7
use Wikibase\DataModel\Entity\PropertyId;
8
9
/**
10
 * @covers Queryr\Resources\PropertyList
11
 * @covers Queryr\Resources\PropertyListElement
12
 *
13
 * @licence GNU GPL v2+
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class PropertyListTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testSetAndGetElements() {
19
		$items = [
20
			new PropertyListElement(
21
				new PropertyId( 'P1' ),
22
				'number',
23
				'https://www.wikidata.org/wiki/Property:P1',
24
				'http://api.queryr.com/properties/P1'
25
			),
26
			new PropertyListElement(
27
				new PropertyId( 'P2' ),
28
				'string',
29
				'https://www.wikidata.org/wiki/Property:P2',
30
				'http://api.queryr.com/properties/P2'
31
			)
32
		];
33
34
		$list = new PropertyList( $items );
35
		$this->assertSame( $items, $list->getElements() );
36
37
38
	}
39
40
	public function testElement() {
41
		$item = new PropertyListElement(
42
			new PropertyId( 'P1' ),
43
			'number',
44
			'https://www.wikidata.org/wiki/Property:P1',
45
			'http://api.queryr.com/properties/P1'
46
		);
47
48
		$this->assertEquals( new PropertyId( 'P1' ), $item->getPropertyId() );
49
		$this->assertEquals( 'number', $item->getPropertyType() );
50
		$this->assertEquals( 'https://www.wikidata.org/wiki/Property:P1', $item->getWikidataUrl() );
51
		$this->assertEquals( 'http://api.queryr.com/properties/P1', $item->getApiUrl() );
52
	}
53
54
}
55