NodeSimplifierBaseTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 55
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
buildSimplifier() 0 1 ?
A testImplementsNodeSimplifierInterface() 0 3 1
A testIsNodeSimplifierForReturnsTrue() 0 3 1
simplifiableProvider() 0 1 ?
A testIsNodeSimplifierForReturnsFalse() 0 3 1
A testSimplificationThrowsUnsupportedObjectException() 0 4 1
nonSimplifiableProvider() 0 1 ?
simplificationProvider() 0 1 ?
A testSimplification() 0 6 1
1
<?php
2
3
namespace PPP\Module\TreeSimplifier;
4
5
/**
6
 * @licence MIT
7
 * @author Thomas Pellissier Tanon
8
 */
9
abstract class NodeSimplifierBaseTest extends \PHPUnit_Framework_TestCase {
10
11
	/**
12
	 * @return NodeSimplifier
13
	 */
14
	protected abstract function buildSimplifier();
15
16
	public function testImplementsNodeSimplifierInterface() {
17
		$this->assertInstanceOf('PPP\Module\TreeSimplifier\NodeSimplifier', $this->buildSimplifier());
18
	}
19
20
	/**
21
	 * @dataProvider simplifiableProvider
22
	 */
23
	public function testIsNodeSimplifierForReturnsTrue($simplifiable) {
24
		$this->assertTrue($this->buildSimplifier()->isSimplifierFor($simplifiable));
25
	}
26
	
27
	public abstract function simplifiableProvider();
28
29
	/**
30
	 * @dataProvider nonSimplifiableProvider
31
	 */
32
	public function testIsNodeSimplifierForReturnsFalse($nonSimplifiable) {
33
		$this->assertFalse($this->buildSimplifier()->isSimplifierFor($nonSimplifiable));
34
	}
35
36
	/**
37
	 * @dataProvider nonSimplifiableProvider
38
	 */
39
	public function testSimplificationThrowsUnsupportedObjectException($nonSimplifiable) {
40
		$this->setExpectedException('InvalidArgumentException');
41
		$this->buildSimplifier()->simplify($nonSimplifiable);
42
	}
43
44
	/**
45
	 * @return array
46
	 */
47
	public abstract function nonSimplifiableProvider();
48
49
	/**
50
	 * @dataProvider simplificationProvider
51
	 */
52
	public function testSimplification($simplified, $object) {
53
		$this->assertEquals(
54
			$simplified,
55
			$this->buildSimplifier()->simplify($object)
56
		);
57
	}
58
59
	/**
60
	 * @return array
61
	 */
62
	public abstract function simplificationProvider();
63
}
64