|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace LauLamanApps\IzettleApi\Tests\Unit\Client\Purchase; |
|
6
|
|
|
|
|
7
|
|
|
use LauLamanApps\IzettleApi\API\Purchase\Coordinates; |
|
8
|
|
|
use LauLamanApps\IzettleApi\Client\Purchase\CoordinatesBuilder; |
|
9
|
|
|
use PHPUnit\Framework\TestCase; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @small |
|
13
|
|
|
*/ |
|
14
|
|
|
final class CoordinatesBuilderTest extends TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @test |
|
18
|
|
|
* @dataProvider getCoordinates |
|
19
|
|
|
*/ |
|
20
|
|
|
public function parse(float $latitude, float $longitude, float $accuracyMeters): void |
|
21
|
|
|
{ |
|
22
|
|
|
$data = [ |
|
23
|
|
|
'latitude' => $latitude, |
|
24
|
|
|
'longitude' => $longitude, |
|
25
|
|
|
'accuracyMeters' => $accuracyMeters, |
|
26
|
|
|
]; |
|
27
|
|
|
|
|
28
|
|
|
$builder = new CoordinatesBuilder(); |
|
29
|
|
|
$coordinate = $builder->buildFromArray($data); |
|
30
|
|
|
|
|
31
|
|
|
self::assertInstanceOf(Coordinates::class, $coordinate); |
|
32
|
|
|
self::assertSame($latitude, $coordinate->getLatitude()); |
|
33
|
|
|
self::assertSame($longitude, $coordinate->getLongitude()); |
|
34
|
|
|
self::assertSame($accuracyMeters, $coordinate->getAccuracyMeters()); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
View Code Duplication |
public function getCoordinates(): array |
|
38
|
|
|
{ |
|
39
|
|
|
return [ |
|
40
|
|
|
'Almere Poort, The Netherlands' => [52.3504547, 5.1511458, 10], |
|
41
|
|
|
'Amsterdam, The Netherlands' => [52.3702157, 4.8951679, 0], |
|
42
|
|
|
'Den Haag, The Netherlands' => [52.0704978, 4.3006999, -10.1], |
|
43
|
|
|
]; |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|