ModuleResponseTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 4
Bugs 0 Features 3
Metric Value
wmc 7
c 4
b 0
f 3
lcom 0
cbo 3
dl 0
loc 55
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetLanguageCode() 0 4 1
A testGetSentenceTree() 0 4 1
A testGetMeasures() 0 4 1
A testGetTrace() 0 4 1
A testEquals() 0 4 1
A testNonEquals() 0 3 1
A nonEqualsProvider() 0 20 1
1
<?php
2
3
namespace PPP\Module\DataModel;
4
5
use PPP\DataModel\FirstNode;
6
use PPP\DataModel\MissingNode;
7
8
/**
9
 * @covers PPP\Module\DataModel\ModuleResponse
10
 *
11
 * @licence MIT
12
 * @author Thomas Pellissier Tanon
13
 */
14
class ModuleResponseTest extends \PHPUnit_Framework_TestCase {
15
16
	public function testGetLanguageCode() {
17
		$response = new ModuleResponse('en', new MissingNode());
18
		$this->assertEquals('en', $response->getLanguageCode());
19
	}
20
21
	public function testGetSentenceTree() {
22
		$response = new ModuleResponse('en', new MissingNode());
23
		$this->assertEquals(new MissingNode(), $response->getSentenceTree());
24
	}
25
26
	public function testGetMeasures() {
27
		$response = new ModuleResponse('en', new MissingNode(), array('accuracy' => 1));
28
		$this->assertEquals(array('accuracy' => 1), $response->getMeasures());
29
	}
30
31
	public function testGetTrace() {
32
		$response = new ModuleResponse('en', new MissingNode(), array('accuracy' => 1), array('a'));
33
		$this->assertEquals(array('a'), $response->getTrace());
34
	}
35
36
	public function testEquals() {
37
		$response = new ModuleResponse('en', new MissingNode(), array('accuracy' => 1), array('a'));
38
		$this->assertTrue($response->equals(new ModuleResponse('en', new MissingNode(), array('accuracy' => 1))));
39
	}
40
41
	/**
42
	 * @dataProvider nonEqualsProvider
43
	 */
44
	public function testNonEquals(ModuleResponse $node, $target) {
45
		$this->assertFalse($node->equals($target));
46
	}
47
48
	public function nonEqualsProvider() {
49
		return array(
50
			array(
51
				new ModuleResponse('en', new MissingNode(), array('accuracy' => 1)),
52
				new MissingNode()
53
			),
54
			array(
55
				new ModuleResponse('en', new MissingNode(), array('accuracy' => 1)),
56
				new ModuleResponse('fr', new MissingNode(), array('accuracy' => 1))
57
			),
58
			array(
59
				new ModuleResponse('en', new MissingNode(), array('accuracy' => 1)),
60
				new ModuleResponse('en', new FirstNode(new MissingNode()), array('accuracy' => 1))
61
			),
62
			array(
63
				new ModuleResponse('en', new MissingNode(), array('accuracy' => 1)),
64
				new ModuleResponse('en', new MissingNode(), array('accuracy' => 0))
65
			),
66
		);
67
	}
68
}
69