OperatorNodeBaseTest::nonEqualsProvider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
rs 9.4285
nc 1
cc 1
eloc 11
nop 0
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