Vector2Test   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 74
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 74
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructor() 0 15 1
A testGetSetX() 0 12 1
A testGetSetY() 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\Vector2;
6
use PHPUnit_Framework_TestCase;
7
8
class Vector2Test extends PHPUnit_Framework_TestCase
9
{
10
    public function testConstructor()
11
    {
12
        // Arrange
13
        $vector = new Vector2(123, 456);
14
15
        // Act
16
        // ...
17
18
        // Assert
19
        $this->assertInstanceOf('PHP\Math\BigNumber\BigNumber', $vector->getX());
20
        $this->assertEquals('123.0', $vector->getX());
21
22
        $this->assertInstanceOf('PHP\Math\BigNumber\BigNumber', $vector->getY());
23
        $this->assertEquals('456.0', $vector->getY());
24
    }
25
26
    public function testGetSetX()
27
    {
28
        // Arrange
29
        $vector = new Vector2(0, 0);
30
31
        // Act
32
        $vector->setX(123);
33
34
        // Assert
35
        $this->assertInstanceOf('PHP\Math\BigNumber\BigNumber', $vector->getX());
36
        $this->assertEquals('123.0', $vector->getX());
37
    }
38
39
    public function testGetSetY()
40
    {
41
        // Arrange
42
        $vector = new Vector2(0, 0);
43
44
        // Act
45
        $vector->setY(123);
46
47
        // Assert
48
        $this->assertInstanceOf('PHP\Math\BigNumber\BigNumber', $vector->getY());
49
        $this->assertEquals('123.0', $vector->getY());
50
    }
51
52
    /**
53
     * @expectedException InvalidArgumentException
54
     */
55
    public function testGetInvalidElement()
56
    {
57
        // Arrange
58
        $vector = new Vector2(0, 0);
59
60
        // Act
61
        $vector->getElement(123);
62
63
        // Assert
64
        // ...
65
    }
66
67
    /**
68
     * @expectedException InvalidArgumentException
69
     */
70
    public function testSetInvalidElement()
71
    {
72
        // Arrange
73
        $vector = new Vector2(0, 0);
74
75
        // Act
76
        $vector->setElement(123, 0);
77
78
        // Assert
79
        // ...
80
    }
81
}
82