|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace StefanoTreeTest\Unit\NestedSet; |
|
6
|
|
|
|
|
7
|
|
|
use StefanoTree\NestedSet\NodeInfo; |
|
8
|
|
|
use StefanoTreeTest\UnitTestCase; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @internal |
|
12
|
|
|
*/ |
|
13
|
|
|
class NodeInfoTest extends UnitTestCase |
|
14
|
|
|
{ |
|
15
|
|
|
public function testNodeInfoWithScope() |
|
16
|
|
|
{ |
|
17
|
|
|
$nodeInfo = new NodeInfo(11, 29, 33, 44, 62, 45); |
|
18
|
|
|
|
|
19
|
|
|
$this->assertEquals(11, $nodeInfo->getId()); |
|
20
|
|
|
$this->assertEquals(29, $nodeInfo->getParentId()); |
|
21
|
|
|
$this->assertEquals(33, $nodeInfo->getLevel()); |
|
22
|
|
|
$this->assertEquals(44, $nodeInfo->getLeft()); |
|
23
|
|
|
$this->assertEquals(62, $nodeInfo->getRight()); |
|
24
|
|
|
$this->assertEquals(45, $nodeInfo->getScope()); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testSetLevel() |
|
28
|
|
|
{ |
|
29
|
|
|
$nodeInfo = new NodeInfo(0, 0, 0, 0, 0, 0); |
|
30
|
|
|
|
|
31
|
|
|
$nodeInfo->setLevel(123); |
|
32
|
|
|
$this->assertEquals(123, $nodeInfo->getLevel()); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testSetLeftIndex() |
|
36
|
|
|
{ |
|
37
|
|
|
$nodeInfo = new NodeInfo(0, 0, 0, 0, 0, 0); |
|
38
|
|
|
|
|
39
|
|
|
$nodeInfo->setLeft(456); |
|
40
|
|
|
$this->assertEquals(456, $nodeInfo->getLeft()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testSetRightIndex() |
|
44
|
|
|
{ |
|
45
|
|
|
$nodeInfo = new NodeInfo(0, 0, 0, 0, 0, 0); |
|
46
|
|
|
|
|
47
|
|
|
$nodeInfo->setRight(789); |
|
48
|
|
|
$this->assertEquals(789, $nodeInfo->getRight()); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testIsNotRoot() |
|
52
|
|
|
{ |
|
53
|
|
|
$nodeInfo = new NodeInfo(11, 29, 33, 44, 62, null); |
|
54
|
|
|
$this->assertFalse($nodeInfo->isRoot()); |
|
55
|
|
|
|
|
56
|
|
|
$nodeInfo = new NodeInfo('acs', 'cst', 33, 44, 62, null); |
|
57
|
|
|
$this->assertFalse($nodeInfo->isRoot()); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testIsRoot() |
|
61
|
|
|
{ |
|
62
|
|
|
$nodeInfo = new NodeInfo(25, null, 0, 1, 186, null); |
|
63
|
|
|
$this->assertTrue($nodeInfo->isRoot()); |
|
64
|
|
|
|
|
65
|
|
|
$nodeInfo = new NodeInfo('ac', null, 0, 1, 16, 'b'); |
|
66
|
|
|
$this->assertTrue($nodeInfo->isRoot()); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|