1 | <?php |
||
15 | |||
16 | /** |
||
17 | * @var Geocoder; |
||
18 | */ |
||
19 | private $_geocoder; |
||
20 | |||
21 | public function setUp() { |
||
22 | $this->_geocoder = new Geocoder(array('api_key' => getenv('MAPS_API_KEY'))); |
||
23 | parent::setUp(); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @covers ::geocode |
||
28 | */ |
||
29 | public function testGeocode() { |
||
30 | $location = $this->_geocoder->geocode('1600 Amphitheatre Parkway, Mountain View, CA'); |
||
31 | |||
32 | $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location); |
||
33 | $this->assertInternalType('string', $location->address()); |
||
34 | $this->assertInternalType('string', $location->formatted_address()); |
||
35 | $this->assertInternalType('double', $location->latitude()); |
||
36 | $this->assertInternalType('double', $location->longitude()); |
||
37 | $this->assertInternalType('array', $location->viewport()); |
||
38 | $this->assertArrayHasKey('northeast', $location->viewport()); |
||
39 | $this->assertArrayHasKey('southwest', $location->viewport()); |
||
40 | $this->assertInternalType('array', $location->viewport()['northeast']); |
||
41 | $this->assertArrayHasKey('lat', $location->viewport()['northeast']); |
||
42 | $this->assertArrayHasKey('lng', $location->viewport()['northeast']); |
||
43 | $this->assertInternalType('double', $location->viewport()['northeast']['lat']); |
||
44 | $this->assertInternalType('double', $location->viewport()['northeast']['lng']); |
||
45 | $this->assertInternalType('array', $location->viewport()['southwest']); |
||
46 | $this->assertArrayHasKey('lat', $location->viewport()['southwest']); |
||
47 | $this->assertArrayHasKey('lng', $location->viewport()['southwest']); |
||
48 | $this->assertInternalType('double', $location->viewport()['southwest']['lat']); |
||
49 | $this->assertInternalType('double', $location->viewport()['southwest']['lng']); |
||
50 | } |
||
51 | |||
52 | } |
||
53 |