1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2018 - present |
4
|
|
|
* Google Maps PHP - ViewportTest.php |
5
|
|
|
* author: Roberto Belotti - [email protected] |
6
|
|
|
* web : robertobelotti.com, github.com/biscolab |
7
|
|
|
* Initial version created on: 5/9/2018 |
8
|
|
|
* MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Biscolab\geocode\Tests; |
12
|
|
|
|
13
|
|
|
use Biscolab\GoogleMaps\Fields\LatLngBoundsFields; |
14
|
|
|
use Biscolab\GoogleMaps\Fields\LatLngFields; |
15
|
|
|
use Biscolab\GoogleMaps\Object\LatLng; |
16
|
|
|
use Biscolab\GoogleMaps\Object\LatLngBounds; |
17
|
|
|
use Biscolab\GoogleMaps\Object\Viewport; |
18
|
|
|
use PHPUnit\Framework\TestCase; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class ViewportTest |
22
|
|
|
* @package Biscolab\geocode\Tests |
23
|
|
|
*/ |
24
|
|
|
class ViewportTest extends TestCase { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var LatLngBounds |
28
|
|
|
*/ |
29
|
|
|
private $viewport; |
30
|
|
|
|
31
|
|
|
public function setUp()/* The :void return type declaration that should be here would cause a BC issue */ { |
32
|
|
|
|
33
|
|
|
parent::setUp(); // TODO: Change the autogenerated stub |
34
|
|
|
|
35
|
|
|
$this->viewport = new Viewport(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @test |
40
|
|
|
*/ |
41
|
|
|
public function testViewportSetterGetter() { |
42
|
|
|
|
43
|
|
|
$viewport = $this->viewport; |
44
|
|
|
|
45
|
|
|
$southwest = new LatLng([ |
46
|
|
|
LatLngFields::LAT => 20.89, |
47
|
|
|
LatLngFields::LNG => -40.82, |
48
|
|
|
]); |
49
|
|
|
|
50
|
|
|
$northeast = new LatLng([ |
51
|
|
|
LatLngFields::LAT => 22.73, |
52
|
|
|
LatLngFields::LNG => 3.6370, |
53
|
|
|
]); |
54
|
|
|
|
55
|
|
|
$viewport->setSouthwest($southwest); |
|
|
|
|
56
|
|
|
$viewport->setNortheast($northeast); |
|
|
|
|
57
|
|
|
|
58
|
|
|
$this->assertEquals(new Viewport([ |
59
|
|
|
LatLngBoundsFields::SOUTHWEST => [ |
60
|
|
|
LatLngFields::LAT => 20.89, |
61
|
|
|
LatLngFields::LNG => -40.82, |
62
|
|
|
], |
63
|
|
|
LatLngBoundsFields::NORTHEAST => [ |
64
|
|
|
LatLngFields::LAT => 22.73, |
65
|
|
|
LatLngFields::LNG => 3.6370, |
66
|
|
|
], |
67
|
|
|
]), $viewport); |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|