SortNodeTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 4
dl 0
loc 76
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetOperand() 0 7 1
A testGetPredicate() 0 7 1
A testGetType() 0 7 1
A testEquals() 0 10 1
A testNonEquals() 0 3 1
B nonEqualsProvider() 0 31 1
1
<?php
2
3
namespace PPP\DataModel;
4
5
/**
6
 * @covers PPP\DataModel\SortNode
7
 *
8
 * @licence AGPLv3+
9
 * @author Thomas Pellissier Tanon
10
 */
11
class SortNodeTest extends \PHPUnit_Framework_TestCase {
12
13
	public function testGetOperand() {
14
		$sortNode = new SortNode(
15
			new ResourceListNode(array(new StringResourceNode('s'))),
16
			new StringResourceNode('p')
17
		);
18
		$this->assertEquals(new ResourceListNode(array(new StringResourceNode('s'))), $sortNode->getOperand());
19
	}
20
21
	public function testGetPredicate() {
22
		$sortNode = new SortNode(
23
			new ResourceListNode(array(new StringResourceNode('s'))),
24
			new StringResourceNode('p')
25
		);
26
		$this->assertEquals(new StringResourceNode('p'), $sortNode->getPredicate());
27
	}
28
29
	public function testGetType() {
30
		$sortNode = new SortNode(
31
			new ResourceListNode(array(new StringResourceNode('s'))),
32
			new StringResourceNode('p')
33
		);
34
		$this->assertEquals('sort', $sortNode->getType());
35
	}
36
37
	public function testEquals() {
38
		$node = new SortNode(
39
			new ResourceListNode(array(new StringResourceNode('s'))),
40
			new StringResourceNode('p')
41
		);
42
		$this->assertTrue($node->equals(new SortNode(
43
			new ResourceListNode(array(new StringResourceNode('s'))),
44
			new StringResourceNode('p')
45
		)));
46
	}
47
48
	/**
49
	 * @dataProvider nonEqualsProvider
50
	 */
51
	public function testNonEquals(SortNode $node, $target) {
52
		$this->assertFalse($node->equals($target));
53
	}
54
55
	public function nonEqualsProvider() {
56
		return array(
57
			array(
58
				new SortNode(
59
					new ResourceListNode(array(new StringResourceNode('s'))),
60
					new StringResourceNode('p')
61
				),
62
				new MissingNode()
63
			),
64
			array(
65
				new SortNode(
66
					new ResourceListNode(array(new StringResourceNode('s'))),
67
					new StringResourceNode('p')
68
				),
69
				new SortNode(
70
					new MissingNode(),
71
					new StringResourceNode('p')
72
				)
73
			),
74
			array(
75
				new SortNode(
76
					new ResourceListNode(array(new StringResourceNode('s'))),
77
					new StringResourceNode('p')
78
				),
79
				new SortNode(
80
					new ResourceListNode(array(new StringResourceNode('s'))),
81
					new StringResourceNode('q')
82
				)
83
			),
84
		);
85
	}
86
}
87