NodeTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 3
eloc 15
c 2
b 0
f 2
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testPointSetter() 0 7 1
A testLeafSetters() 0 10 1
A testConstruction() 0 6 1
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