1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace PhpValueObjects\Tests\Spatial; |
6
|
|
|
|
7
|
|
|
use PhpValueObjects\Spatial\Exception\InvalidPolygonException; |
8
|
|
|
use PhpValueObjects\Tests\BaseUnitTestCase; |
9
|
|
|
|
10
|
|
|
final class MultiPolygonTest extends BaseUnitTestCase |
11
|
|
|
{ |
12
|
|
|
public function invalidDataProvider(): array |
13
|
|
|
{ |
14
|
|
|
return [ |
15
|
|
|
[[['string']]] |
16
|
|
|
]; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @test |
21
|
|
|
* @dataProvider invalidDataProvider |
22
|
|
|
*/ |
23
|
|
|
public function itShouldThrowException(array $data): void |
24
|
|
|
{ |
25
|
|
|
$this->expectException(InvalidPolygonException::class); |
26
|
|
|
|
27
|
|
|
new MultiPolygon($data); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @test |
32
|
|
|
*/ |
33
|
|
|
public function itShouldWorksFine(): void |
34
|
|
|
{ |
35
|
|
|
$latitude1 = $this->faker()->latitude; |
36
|
|
|
$latitude2 = $this->faker()->latitude; |
37
|
|
|
$longitude1 = $this->faker()->longitude; |
38
|
|
|
$longitude2 = $this->faker()->longitude; |
39
|
|
|
|
40
|
|
|
$data = [ |
41
|
|
|
[ |
42
|
|
|
[$latitude1, $longitude1], |
43
|
|
|
[$this->faker()->latitude, $this->faker()->longitude], |
44
|
|
|
[$this->faker()->latitude, $this->faker()->longitude], |
45
|
|
|
[$latitude1, $longitude1], |
46
|
|
|
], |
47
|
|
|
[ |
48
|
|
|
[$latitude2, $longitude2], |
49
|
|
|
[$this->faker()->latitude, $this->faker()->longitude], |
50
|
|
|
[$this->faker()->latitude, $this->faker()->longitude], |
51
|
|
|
[$latitude2, $longitude2] |
52
|
|
|
] |
53
|
|
|
]; |
54
|
|
|
|
55
|
|
|
$multiPolygon = new MultiPolygon($data); |
56
|
|
|
$this->assertNotNull($multiPolygon->value()); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|