Completed
Push — master ( a11cd2...d581f7 )
by mw
02:32
created

testGetPropertyForCategory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 20
rs 9.4286
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
namespace SEQL\ByHttpRequest\Tests;
4
5
use SEQL\ByHttpRequest\ResponsePropertyList;
6
use SMW\DIProperty;
7
8
/**
9
 * @covers \SEQL\ByHttpRequest\ResponsePropertyList
10
 * @group semantic-external-query-lookup
11
 *
12
 * @license GNU GPL v2+
13
 * @since 1.0
14
 *
15
 * @author mwjames
16
 */
17
class ResponsePropertyListTest extends \PHPUnit_Framework_TestCase {
18
19
	public function testCanConstruct() {
20
21
		$this->assertInstanceOf(
22
			'\SEQL\ByHttpRequest\ResponsePropertyList',
23
			new ResponsePropertyList( 'abc' )
24
		);
25
	}
26
27
	public function testGetPropertyForCategory() {
28
29
		$value = array( 'label' => 'Category', 'mode' => 0 );
30
31
		$property = new DIProperty( '_INST' );
32
		$property->setInterwiki( 'abc' );
33
34
		$instance = new ResponsePropertyList( 'abc' );
35
		$instance->addToPropertyList( $value );
36
37
		$this->assertEquals(
38
			$property,
39
			$instance->getProperty( 'Category' )
40
		);
41
42
		$this->assertEquals(
43
			$property,
44
			$instance->getProperty( '_INST' )
45
		);
46
	}
47
48
	public function testGetPropertyForRedirectedProperty() {
49
50
		$value = array(  'label' => 'Foo', 'mode' => 2, 'redi' => 'was redirect from Bar' , 'typeid' => '_wpg' );
51
52
		$property = new DIProperty( 'Foo' );
53
		$property->setInterwiki( 'abc' );
54
		$property->setPropertyTypeId( '_wpg' );
55
56
		$instance = new ResponsePropertyList( 'abc' );
57
		$instance->addToPropertyList( $value );
58
59
		$this->assertEquals(
60
			$property,
61
			$instance->getProperty( 'Foo' )
62
		);
63
64
		$this->assertEquals(
65
			$property,
66
			$instance->getProperty( 'was redirect from Bar' )
67
		);
68
69
		$this->assertEquals(
70
			array( 'Foo' => $property ),
71
			$instance->getPropertyList()
72
		);
73
	}
74
75
}
76