ModuleResponseTest::testGetMeasures()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 0
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