testCanConstructNearByParserFunctionDefinition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 32
rs 9.408
cc 1
nc 1
nop 0
1
<?php
2
3
namespace WNBY\Tests;
4
5
use WNBY\ParserFunctionFactory;
6
7
/**
8
 * @covers \WNBY\ParserFunctionFactory
9
 * @group whats-nearby
10
 *
11
 * @license GNU GPL v2+
12
 * @since 1.0
13
 *
14
 * @author mwjames
15
 */
16
class ParserFunctionFactoryTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$this->assertInstanceOf(
21
			'\WNBY\ParserFunctionFactory',
22
			new ParserFunctionFactory()
23
		);
24
	}
25
26
	public function testCanConstructNearByParserFunctionDefinition() {
27
28
		$instance = new ParserFunctionFactory();
29
30
		list( $name, $definition, $flag ) = $instance->newNearbyParserFunctionDefinition();
0 ignored issues
show
Unused Code introduced by
The assignment to $flag is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
31
32
		$this->assertEquals(
33
			'nearby',
34
			$name
35
		);
36
37
		$this->assertInstanceOf(
38
			'\Closure',
39
			$definition
40
		);
41
42
		$parserOutput = $this->getMockBuilder( '\ParserOutput' )
43
			->disableOriginalConstructor()
44
			->getMock();
45
46
		$parser = $this->getMockBuilder( '\Parser' )
47
			->disableOriginalConstructor()
48
			->getMock();
49
50
		$parser->expects( $this->any() )
51
			->method( 'getOutput' )
52
			->will( $this->returnValue( $parserOutput ) );
53
54
		$this->assertNotEmpty(
55
			call_user_func_array( $definition, array( $parser ) )
56
		);
57
	}
58
59
}
60