@@ -20,38 +20,38 @@ discard block |
||
| 20 | 20 | private $_geocoder; |
| 21 | 21 | |
| 22 | 22 | public function setUp() { |
| 23 | - $this->_geocoder = new Geocoder(['api_key' => '']); |
|
| 23 | + $this->_geocoder = new Geocoder( ['api_key' => ''] ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @covers ::_make_request |
| 28 | 28 | */ |
| 29 | 29 | public function testMakeRequest() { |
| 30 | - $url = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA'); |
|
| 31 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', $url); |
|
| 30 | + $url = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
| 31 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', $url ); |
|
| 32 | 32 | |
| 33 | - $this->assertInternalType('array', $response); |
|
| 33 | + $this->assertInternalType( 'array', $response ); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @covers ::_make_request |
| 38 | 38 | */ |
| 39 | 39 | public function testMakeRequestError404() { |
| 40 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', 'https://maps.googleapis.com/maps/api/geo'); |
|
| 40 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', 'https://maps.googleapis.com/maps/api/geo' ); |
|
| 41 | 41 | |
| 42 | - $this->assertInstanceOf('WP_Error', $response); |
|
| 43 | - $this->assertObjectHasAttribute('errors', $response); |
|
| 44 | - $this->assertArrayHasKey('404', $response->errors); |
|
| 42 | + $this->assertInstanceOf( 'WP_Error', $response ); |
|
| 43 | + $this->assertObjectHasAttribute( 'errors', $response ); |
|
| 44 | + $this->assertArrayHasKey( '404', $response->errors ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @covers ::_get_data |
| 49 | 49 | */ |
| 50 | 50 | public function testGetData() { |
| 51 | - $url = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA'); |
|
| 52 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_get_data', $url); |
|
| 51 | + $url = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
| 52 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_get_data', $url ); |
|
| 53 | 53 | |
| 54 | - $this->assertInternalType('array', $response); |
|
| 54 | + $this->assertInternalType( 'array', $response ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -59,26 +59,26 @@ discard block |
||
| 59 | 59 | * @covers ::_make_location |
| 60 | 60 | */ |
| 61 | 61 | public function testGeocode() { |
| 62 | - $location = $this->_geocoder->geocode('1600 Amphitheatre Parkway, Mountain View, CA'); |
|
| 62 | + $location = $this->_geocoder->geocode( '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
| 63 | 63 | |
| 64 | - $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location); |
|
| 65 | - $this->assertEquals('1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->address()); |
|
| 66 | - $this->assertEquals('1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->formatted_address()); |
|
| 67 | - $this->assertInternalType('double', $location->latitude()); |
|
| 68 | - $this->assertInternalType('double', $location->longitude()); |
|
| 69 | - $this->assertEquals('ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id()); |
|
| 70 | - $this->assertInternalType('array', $location->viewport()); |
|
| 71 | - $this->assertArrayHasKey('northeast', $location->viewport()); |
|
| 72 | - $this->assertArrayHasKey('southwest', $location->viewport()); |
|
| 73 | - $this->assertInternalType('array', $location->viewport()['northeast']); |
|
| 74 | - $this->assertArrayHasKey('lat', $location->viewport()['northeast']); |
|
| 75 | - $this->assertArrayHasKey('lng', $location->viewport()['northeast']); |
|
| 76 | - $this->assertInternalType('double', $location->viewport()['northeast']['lat']); |
|
| 77 | - $this->assertInternalType('double', $location->viewport()['northeast']['lng']); |
|
| 78 | - $this->assertInternalType('array', $location->viewport()['southwest']); |
|
| 79 | - $this->assertArrayHasKey('lat', $location->viewport()['southwest']); |
|
| 80 | - $this->assertArrayHasKey('lng', $location->viewport()['southwest']); |
|
| 81 | - $this->assertInternalType('double', $location->viewport()['southwest']['lat']); |
|
| 82 | - $this->assertInternalType('double', $location->viewport()['southwest']['lng']); |
|
| 64 | + $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location ); |
|
| 65 | + $this->assertEquals( '1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->address() ); |
|
| 66 | + $this->assertEquals( '1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->formatted_address() ); |
|
| 67 | + $this->assertInternalType( 'double', $location->latitude() ); |
|
| 68 | + $this->assertInternalType( 'double', $location->longitude() ); |
|
| 69 | + $this->assertEquals( 'ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id() ); |
|
| 70 | + $this->assertInternalType( 'array', $location->viewport() ); |
|
| 71 | + $this->assertArrayHasKey( 'northeast', $location->viewport() ); |
|
| 72 | + $this->assertArrayHasKey( 'southwest', $location->viewport() ); |
|
| 73 | + $this->assertInternalType( 'array', $location->viewport()['northeast'] ); |
|
| 74 | + $this->assertArrayHasKey( 'lat', $location->viewport()['northeast'] ); |
|
| 75 | + $this->assertArrayHasKey( 'lng', $location->viewport()['northeast'] ); |
|
| 76 | + $this->assertInternalType( 'double', $location->viewport()['northeast']['lat'] ); |
|
| 77 | + $this->assertInternalType( 'double', $location->viewport()['northeast']['lng'] ); |
|
| 78 | + $this->assertInternalType( 'array', $location->viewport()['southwest'] ); |
|
| 79 | + $this->assertArrayHasKey( 'lat', $location->viewport()['southwest'] ); |
|
| 80 | + $this->assertArrayHasKey( 'lng', $location->viewport()['southwest'] ); |
|
| 81 | + $this->assertInternalType( 'double', $location->viewport()['southwest']['lat'] ); |
|
| 82 | + $this->assertInternalType( 'double', $location->viewport()['southwest']['lng'] ); |
|
| 83 | 83 | } |
| 84 | 84 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | 29 | public function setUp() { |
| 30 | - $this->_geocoder = new Geocoder(['api_key' => $this->_api_key]); |
|
| 30 | + $this->_geocoder = new Geocoder( ['api_key' => $this->_api_key] ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -35,54 +35,54 @@ discard block |
||
| 35 | 35 | * @covers ::api_key |
| 36 | 36 | */ |
| 37 | 37 | public function testConstructorWithAPIKey() { |
| 38 | - $this->assertEquals($this->_api_key, $this->_geocoder->api_key()); |
|
| 38 | + $this->assertEquals( $this->_api_key, $this->_geocoder->api_key() ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @covers ::_make_url |
| 43 | 43 | */ |
| 44 | 44 | public function testMakeUrl() { |
| 45 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '123 Anywhere Street New York 10001'); |
|
| 45 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '123 Anywhere Street New York 10001' ); |
|
| 46 | 46 | |
| 47 | - $this->assertInternalType('string', $response); |
|
| 48 | - $this->assertRegExp('/address\=123\+Anywhere\+Street\+New\+York\+10001/', $response); |
|
| 49 | - $this->assertRegExp("/key={$this->_api_key}/", $response); |
|
| 47 | + $this->assertInternalType( 'string', $response ); |
|
| 48 | + $this->assertRegExp( '/address\=123\+Anywhere\+Street\+New\+York\+10001/', $response ); |
|
| 49 | + $this->assertRegExp( "/key={$this->_api_key}/", $response ); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * @covers ::_get_data |
| 54 | 54 | */ |
| 55 | 55 | public function testGetDataCache() { |
| 56 | - wp_cache_add( md5(serialize('foo.bar')), 'foobar'); |
|
| 56 | + wp_cache_add( md5( serialize( 'foo.bar' ) ), 'foobar' ); |
|
| 57 | 57 | |
| 58 | - $this->assertEquals('foobar', $this->reflectionMethodInvokeArgs($this->_geocoder, '_get_data', 'foo.bar')); |
|
| 58 | + $this->assertEquals( 'foobar', $this->reflectionMethodInvokeArgs( $this->_geocoder, '_get_data', 'foo.bar' ) ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * @covers ::_make_location |
| 63 | 63 | */ |
| 64 | 64 | public function testMakeLocation() { |
| 65 | - $response = json_decode(file_get_contents(TEST_INCLUDES_DIR . '/geocoder-response.json'), true); |
|
| 66 | - $location = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_location', $response['results'][0] ); |
|
| 65 | + $response = json_decode( file_get_contents( TEST_INCLUDES_DIR.'/geocoder-response.json' ), true ); |
|
| 66 | + $location = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_location', $response['results'][0] ); |
|
| 67 | 67 | |
| 68 | - $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location); |
|
| 69 | - $this->assertEquals('1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->address()); |
|
| 70 | - $this->assertEquals('1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->formatted_address()); |
|
| 71 | - $this->assertEquals(37.4224764, $location->latitude()); |
|
| 68 | + $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location ); |
|
| 69 | + $this->assertEquals( '1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->address() ); |
|
| 70 | + $this->assertEquals( '1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->formatted_address() ); |
|
| 71 | + $this->assertEquals( 37.4224764, $location->latitude() ); |
|
| 72 | 72 | $this->assertEquals(-122.0842499, $location->longitude()); |
| 73 | - $this->assertEquals('ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id()); |
|
| 74 | - $this->assertInternalType('array', $location->viewport()); |
|
| 75 | - $this->assertArrayHasKey('northeast', $location->viewport()); |
|
| 76 | - $this->assertArrayHasKey('southwest', $location->viewport()); |
|
| 77 | - $this->assertInternalType('array', $location->viewport()['northeast']); |
|
| 78 | - $this->assertArrayHasKey('lat', $location->viewport()['northeast']); |
|
| 79 | - $this->assertArrayHasKey('lng', $location->viewport()['northeast']); |
|
| 80 | - $this->assertEquals(37.4238253802915, $location->viewport()['northeast']['lat']); |
|
| 73 | + $this->assertEquals( 'ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id() ); |
|
| 74 | + $this->assertInternalType( 'array', $location->viewport() ); |
|
| 75 | + $this->assertArrayHasKey( 'northeast', $location->viewport() ); |
|
| 76 | + $this->assertArrayHasKey( 'southwest', $location->viewport() ); |
|
| 77 | + $this->assertInternalType( 'array', $location->viewport()['northeast'] ); |
|
| 78 | + $this->assertArrayHasKey( 'lat', $location->viewport()['northeast'] ); |
|
| 79 | + $this->assertArrayHasKey( 'lng', $location->viewport()['northeast'] ); |
|
| 80 | + $this->assertEquals( 37.4238253802915, $location->viewport()['northeast']['lat'] ); |
|
| 81 | 81 | $this->assertEquals(-122.0829009197085, $location->viewport()['northeast']['lng']); |
| 82 | - $this->assertInternalType('array', $location->viewport()['southwest']); |
|
| 83 | - $this->assertArrayHasKey('lat', $location->viewport()['southwest']); |
|
| 84 | - $this->assertArrayHasKey('lng', $location->viewport()['southwest']); |
|
| 85 | - $this->assertEquals(37.4211274197085, $location->viewport()['southwest']['lat']); |
|
| 82 | + $this->assertInternalType( 'array', $location->viewport()['southwest'] ); |
|
| 83 | + $this->assertArrayHasKey( 'lat', $location->viewport()['southwest'] ); |
|
| 84 | + $this->assertArrayHasKey( 'lng', $location->viewport()['southwest'] ); |
|
| 85 | + $this->assertEquals( 37.4211274197085, $location->viewport()['southwest']['lat'] ); |
|
| 86 | 86 | $this->assertEquals(-122.0855988802915, $location->viewport()['southwest']['lng']); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | * @covers ::_make_request |
| 91 | 91 | */ |
| 92 | 92 | public function testMakeRequestInvalidURL() { |
| 93 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', 'foo.bar'); |
|
| 94 | - $this->assertInstanceOf('WP_Error', $response); |
|
| 93 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', 'foo.bar' ); |
|
| 94 | + $this->assertInstanceOf( 'WP_Error', $response ); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | \ No newline at end of file |