OperatorNodeBaseTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 42
c 0
b 0
f 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
buildNode() 0 1 ?
A testGetOperands() 0 4 1
A testEquals() 0 4 1
A testNonEquals() 0 3 1
A nonEqualsProvider() 0 16 1
1
<?php
2
3
namespace PPP\DataModel;
4
5
/**
6
 * @licence AGPLv3+
7
 * @author Thomas Pellissier Tanon
8
 */
9
abstract class OperatorNodeBaseTest extends \PHPUnit_Framework_TestCase {
10
11
	/**
12
	 * @param AbstractNode[] $operands
13
	 * @return OperatorNode
14
	 */
15
	protected abstract function buildNode(array $operands);
16
17
	public function testGetOperands() {
18
		$operatorNode = $this->buildNode(array(new StringResourceNode('foo')));
19
		$this->assertEquals(array(new StringResourceNode('foo')), $operatorNode->getOperands());
20
	}
21
22
	public function testEquals() {
23
		$node = $this->buildNode(array(new StringResourceNode('foo'), new StringResourceNode('bar')));
24
		$this->assertTrue($node->equals($this->buildNode(array(new StringResourceNode('bar'), new StringResourceNode('foo')))));
25
	}
26
27
	/**
28
	 * @dataProvider nonEqualsProvider
29
	 */
30
	public function testNonEquals(OperatorNode $node, $target) {
31
		$this->assertFalse($node->equals($target));
32
	}
33
34
	public function nonEqualsProvider() {
35
		return array(
36
			array(
37
				$this->buildNode(array(new StringResourceNode('foo'), new StringResourceNode('bar'))),
38
				new MissingNode()
39
			),
40
			array(
41
				$this->buildNode(array(new StringResourceNode('foo'), new StringResourceNode('bar'))),
42
				$this->buildNode(array(new StringResourceNode('foo'))),
43
			),
44
			array(
45
				$this->buildNode(array(new StringResourceNode('foo'), new StringResourceNode('bar'))),
46
				$this->buildNode(array(new StringResourceNode('foo')), new StringResourceNode('bar2')),
47
			),
48
		);
49
	}
50
}
51