Completed
Push — master ( c3e068...3f9a02 )
by
unknown
02:14
created

ResponsePropertyListTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 75
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanConstruct() 0 7 1
A testGetPropertyForCategory() 0 22 1
A testGetPropertyForRedirectedProperty() 0 28 1
A testTryToRedeclareTypeOfPredefinedPropertyThrowsException() 0 11 1
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