Vector3Test   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 72
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructor() 0 12 1
A testCrossProduct() 0 13 1
A testGetSetZ() 0 12 1
A testGetInvalidElement() 0 11 1
A testSetInvalidElement() 0 11 1
1
<?php
2
3
namespace PHP\Math\VectorTest;
4
5
use PHP\Math\Vector\Vector3;
6
use PHPUnit_Framework_TestCase;
7
8
class Vector3Test extends PHPUnit_Framework_TestCase
9
{
10
    public function testConstructor()
11
    {
12
        // Arrange
13
        $vector = new Vector3(123, 456, 789);
14
15
        // Act
16
        // ...
17
18
        // Assert
19
        $this->assertInstanceOf('PHP\Math\BigNumber\BigNumber', $vector->getZ());
20
        $this->assertEquals('789.0', $vector->getZ());
21
    }
22
23
    public function testCrossProduct()
24
    {
25
        // Arrange
26
        $vector1 = new Vector3(1, 0, 0);
27
        $vector2 = new Vector3(0, 1, 0);
28
29
        // Act
30
        $crossProduct = $vector1->crossProduct($vector2);
31
32
        // Assert
33
        $this->assertInstanceOf('PHP\Math\Vector\Vector3', $crossProduct);
34
        $this->assertEquals('[0.0000000000, 0.0000000000, 1.0000000000]', $crossProduct->toString());
35
    }
36
37
    public function testGetSetZ()
38
    {
39
        // Arrange
40
        $vector = new Vector3(0, 0, 0);
41
42
        // Act
43
        $vector->setZ(123);
44
45
        // Assert
46
        $this->assertInstanceOf('PHP\Math\BigNumber\BigNumber', $vector->getZ());
47
        $this->assertEquals('123.0', $vector->getZ());
48
    }
49
50
    /**
51
     * @expectedException InvalidArgumentException
52
     */
53
    public function testGetInvalidElement()
54
    {
55
        // Arrange
56
        $vector = new Vector3(0, 0, 0);
57
58
        // Act
59
        $vector->getElement(123);
60
61
        // Assert
62
        // ...
63
    }
64
65
    /**
66
     * @expectedException InvalidArgumentException
67
     */
68
    public function testSetInvalidElement()
69
    {
70
        // Arrange
71
        $vector = new Vector3(0, 0, 0);
72
73
        // Act
74
        $vector->setElement(123, 0);
75
76
        // Assert
77
        // ...
78
    }
79
}
80