Completed
Push — master ( 446020...5be29e )
by Pablo
03:42
created

itShouldThrowInvalidMultipolygonException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace PhpValueObjects\Tests\Spatial;
4
5
use PhpValueObjects\Spatial\Exception\InvalidMultiPolygonException;
6
use PhpValueObjects\Tests\BaseUnitTestCase;
7
8
class MultiPolygonValueObjectTest extends BaseUnitTestCase
9
{
10
    public function invalidDataProvider()
11
    {
12
        return [
13
            'no_array' => ['string'],
14
            'no_multiple' => [
15
                [
16
                    [$this->faker()->latitude, $this->faker()->longitude]
17
                ]
18
            ]
19
        ];
20
    }
21
22
    /**
23
     * @param $data
24
     * @test
25
     * @dataProvider invalidDataProvider
26
     */
27
    public function itShouldThrowInvalidMultipolygonException($data)
28
    {
29
        $this->expectException(InvalidMultiPolygonException::class);
30
31
        new MultiPolygonValueObject($data);
32
    }
33
34
    /**
35
     * @test
36
     */
37
    public function itShouldWorksFine()
38
    {
39
        $latitude1 = $this->faker()->latitude;
40
        $latitude2 = $this->faker()->latitude;
41
        $longitude1 = $this->faker()->longitude;
42
        $longitude2 = $this->faker()->longitude;
43
44
        $data = [
45
            [
46
                [$latitude1, $longitude1],
47
                [$this->faker()->latitude, $this->faker()->longitude],
48
                [$this->faker()->latitude, $this->faker()->longitude],
49
                [$latitude1, $longitude1],
50
            ],
51
            [
52
                [$latitude2, $longitude2],
53
                [$this->faker()->latitude, $this->faker()->longitude],
54
                [$this->faker()->latitude, $this->faker()->longitude],
55
                [$latitude2, $longitude2]
56
            ]
57
        ];
58
59
        $multiPolygon = new MultiPolygonValueObject($data);
0 ignored issues
show
Unused Code introduced by
$multiPolygon is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
60
    }
61
}
62