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); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.