NodeTest::testConstruction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
eloc 3
c 2
b 0
f 2
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Structure;
4
5
use KDTree\Structure\Node;
6
use KDTree\ValueObject\Point;
7
use PHPUnit\Framework\TestCase;
8
9
final class NodeTest extends TestCase
10
{
11
    public function testConstruction(): void
12
    {
13
        $point = new Point(1, 2);
14
        $node = new Node($point);
15
16
        $this->assertEquals($point, $node->getPoint());
17
    }
18
19
    public function testPointSetter(): void
20
    {
21
        $node = new Node(new Point(1, 2));
22
        $newPoint = new Point(0, 0);
23
        $node->setPoint($newPoint);
24
25
        $this->assertEquals($newPoint, $node->getPoint());
26
    }
27
28
    public function testLeafSetters(): void
29
    {
30
        $node = new Node(new Point(1, 2));
31
        $nodeLeft = new Node(new Point(0, 0));
32
        $nodeRight = new Node(new Point(3, 3));
33
        $node->setRight($nodeRight);
34
        $node->setLeft($nodeLeft);
35
36
        $this->assertEquals($nodeLeft, $node->getLeft());
37
        $this->assertEquals($nodeRight, $node->getRight());
38
    }
39
}
40