Completed
Push — master ( 1bc8a0...12c1cf )
by Dylan David
12s
created

DLNodeTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 38
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_can_construct_with_no_data() 0 6 1
A it_can_chain_previous_nodes() 0 8 1
A it_can_chain_next_nodes() 0 8 1
A it_can_construct_with_data() 0 4 1
1
<?php
2
3
namespace Ptypes\Test;
4
5
use Ptypes\DLNode;
6
7
class DLNodeTest extends \PHPUnit_Framework_TestCase
8
{
9
	/** @test */
10
	public function it_can_construct_with_no_data()
11
	{
12
		$node = new DLNode();
13
		$this->assertEquals($node->data, null);
14
		$this->assertEquals($node->prev, null);
15
		$this->assertEquals($node->next, null);
16
	}
17
	
18
	/** @test */
19
	public function it_can_construct_with_data()
20
	{
21
		$node = new DLNode("foobar");
1 ignored issue
show
Bug introduced by
'foobar' of type string is incompatible with the type object expected by parameter $data of Ptypes\DLNode::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

21
		$node = new DLNode(/** @scrutinizer ignore-type */ "foobar");
Loading history...
22
		$this->assertEquals($node->data, "foobar");
23
	}
24
	
25
	/** @test */
26
	public function it_can_chain_previous_nodes()
27
	{
28
		$node = new DLNode('1');
1 ignored issue
show
Bug introduced by
'1' of type string is incompatible with the type object expected by parameter $data of Ptypes\DLNode::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

28
		$node = new DLNode(/** @scrutinizer ignore-type */ '1');
Loading history...
29
		$node->prev = new DLNode('2');
30
		$node->prev->prev = new DLNode('3');
31
		
32
		$pn = $node->prev->prev->data;
33
		$this->assertEquals($pn, '3');
34
	}
35
	
36
	/** @test */
37
	public function it_can_chain_next_nodes()
38
	{
39
		$node = new DLNode('1');
1 ignored issue
show
Bug introduced by
'1' of type string is incompatible with the type object expected by parameter $data of Ptypes\DLNode::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
		$node = new DLNode(/** @scrutinizer ignore-type */ '1');
Loading history...
40
		$node->next = new DLNode('2');
41
		$node->next->next = new DLNode('3');
42
		
43
		$pn = $node->next->next->data;
44
		$this->assertEquals($pn, '3');
45
	}
46
}