Completed
Push — master ( ecb243...bb1b22 )
by Pablo
03:58
created

MultiPolygonTest::itShouldWorksFine()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 0
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