Passed
Pull Request — main (#8)
by Alex
03:11 queued 01:35
created

LongitudeTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGivenAValidLongitudeAValidVOIsReturned() 0 11 1
A testGivenATooHighLongitudeAnExceptionIsThrown() 0 10 1
A testGivenATooLowLongitudeAnExceptionIsThrown() 0 10 1
1
<?php
2
3
namespace StraTDeS\VO\Tests\Single;
4
5
use StraTDeS\VO\Single\CoordinatesLongitude;
6
use PHPUnit\Framework\TestCase;
7
8
class LongitudeTest extends TestCase
9
{
10
    public function testGivenAValidLongitudeAValidVOIsReturned(): void
11
    {
12
        // Arrange
13
        $longitude = 1.7200366092330326;
14
15
        // Act
16
        $longitudeVO = CoordinatesLongitude::fromValue($longitude);
17
18
        // Assert
19
        $this->assertInstanceOf(CoordinatesLongitude::class, $longitudeVO);
20
        $this->assertEquals($longitude, $longitudeVO->value());
21
    }
22
23
    public function testGivenATooLowLongitudeAnExceptionIsThrown(): void
24
    {
25
        $this->expectException(\InvalidArgumentException::class);
26
        $this->expectExceptionMessage("Longitude must be a float number between -180.00 and 180.00.");
27
28
        // Arrange
29
        $longitude = -190.00;
30
31
        // Act
32
        CoordinatesLongitude::fromValue($longitude);
33
    }
34
35
    public function testGivenATooHighLongitudeAnExceptionIsThrown(): void
36
    {
37
        $this->expectException(\InvalidArgumentException::class);
38
        $this->expectExceptionMessage("Longitude must be a float number between -180.00 and 180.00.");
39
40
        // Arrange
41
        $longitude = +190.00;
42
43
        // Act
44
        CoordinatesLongitude::fromValue($longitude);
45
    }
46
}
47