Completed
Push — master ( 2e5d0e...583994 )
by Bartko
06:02
created

NodeInfoTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 7
Bugs 1 Features 2
Metric Value
wmc 8
c 7
b 1
f 2
lcom 1
cbo 2
dl 0
loc 71
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testNodeInfoWithScope() 0 11 1
A testSetLevel() 0 7 1
A testSetLeftIndex() 0 7 1
A testSetRightIndex() 0 7 1
A testIsNotRoot() 0 6 1
A testIsRoot() 0 6 1
A testDefaultNeedUpdate() 0 6 1
A testSetNeedUpdate() 0 10 1
1
<?php
2
namespace StefanoTreeTest\Unit\NestedSet;
3
4
use StefanoTree\NestedSet\NodeInfo;
5
6
class NodeInfoTest
7
    extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
8
{
9
    public function testNodeInfoWithScope()
10
    {
11
        $nodeInfo = new NodeInfo(11, 29, 33, 44, 62, 45);
12
13
        $this->assertEquals(11, $nodeInfo->getId());
14
        $this->assertEquals(29, $nodeInfo->getParentId());
15
        $this->assertEquals(33, $nodeInfo->getLevel());
16
        $this->assertEquals(44, $nodeInfo->getLeft());
17
        $this->assertEquals(62, $nodeInfo->getRight());
18
        $this->assertEquals(45, $nodeInfo->getScope());
19
    }
20
21
    public function testSetLevel()
22
    {
23
        $nodeInfo = new NodeInfo(0, 0, 0, 0, 0, 0);
24
25
        $nodeInfo->setLevel(123);
26
        $this->assertEquals(123, $nodeInfo->getLevel());
27
    }
28
29
    public function testSetLeftIndex()
30
    {
31
        $nodeInfo = new NodeInfo(0, 0, 0, 0, 0, 0);
32
33
        $nodeInfo->setLeft(456);
34
        $this->assertEquals(456, $nodeInfo->getLeft());
35
    }
36
37
    public function testSetRightIndex()
38
    {
39
        $nodeInfo = new NodeInfo(0, 0, 0, 0, 0, 0);
40
41
        $nodeInfo->setRight(789);
42
        $this->assertEquals(789, $nodeInfo->getRight());
43
    }
44
45
    public function testIsNotRoot()
46
    {
47
        $nodeInfo = new NodeInfo(11, 29, 33, 44, 62, null);
48
49
        $this->assertFalse($nodeInfo->isRoot());
50
    }
51
52
    public function testIsRoot()
53
    {
54
        $nodeInfo = new NodeInfo(125, 0, 0, 1, 156, null);
55
56
        $this->assertTrue($nodeInfo->isRoot());
57
    }
58
59
    public function testDefaultNeedUpdate()
60
    {
61
        $nodeInfo = new NodeInfo(0, 0, 0, 0, 0, 0);
62
63
        $this->assertEquals(false, $nodeInfo->needUpdate());
64
    }
65
66
    public function testSetNeedUpdate()
67
    {
68
        $nodeInfo = new NodeInfo(0, 0, 0, 0, 0, 0);
69
70
        $nodeInfo->setNeedUpdate(false);
71
        $this->assertEquals(false, $nodeInfo->needUpdate());
72
73
        $nodeInfo->setNeedUpdate(true);
74
        $this->assertEquals(true, $nodeInfo->needUpdate());
75
    }
76
}
77