testGetPropertyForCategory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 1
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(
30
			'label' => 'Category', 'mode' => 0
31
		);
32
33
		$property = new DIProperty( '_INST' );
34
		$property->setInterwiki( 'abc' );
35
36
		$instance = new ResponsePropertyList( 'abc' );
37
		$instance->addToPropertyList( $value );
38
39
		$this->assertEquals(
40
			$property,
41
			$instance->getProperty( 'Category' )
42
		);
43
44
		$this->assertEquals(
45
			$property,
46
			$instance->getProperty( '_INST' )
47
		);
48
	}
49
50
	public function testGetPropertyForRedirectedProperty() {
51
52
		$value = array(
53
			'label' => 'Foo', 'mode' => 2, 'redi' => 'was redirect from Bar' , 'typeid' => '_wpg'
54
		);
55
56
		$property = new DIProperty( 'Foo' );
57
		$property->setInterwiki( 'abc' );
58
		$property->setPropertyTypeId( '_wpg' );
0 ignored issues
show
Deprecated Code introduced by
The method SMW\DIProperty::setPropertyTypeId() has been deprecated with message: since 3.0, use DIProperty::setPropertyValueType

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
59
60
		$instance = new ResponsePropertyList( 'abc' );
61
		$instance->addToPropertyList( $value );
62
63
		$this->assertEquals(
64
			$property,
65
			$instance->getProperty( 'Foo' )
66
		);
67
68
		$this->assertEquals(
69
			$property,
70
			$instance->getProperty( 'was redirect from Bar' )
71
		);
72
73
		$this->assertEquals(
74
			array( 'Foo' => $property ),
75
			$instance->getPropertyList()
76
		);
77
	}
78
79
	public function testTryToRedeclareTypeOfPredefinedPropertyThrowsException() {
80
81
		$value = array(
82
			'label' => 'Modification date', 'mode' => 2, 'typeid' => '_wpg'
83
		);
84
85
		$instance = new ResponsePropertyList( 'abc' );
86
87
		$this->setExpectedException( 'RuntimeException' );
88
		$instance->addToPropertyList( $value );
89
	}
90
91
}
92