@@ -90,7 +90,7 @@ |
||
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | - * @param $url |
|
| 93 | + * @param string $url |
|
| 94 | 94 | * @return array|\WP_Error |
| 95 | 95 | */ |
| 96 | 96 | private function _make_request( $url ) { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $return = $this->_make_request( $url ); |
| 49 | 49 | |
| 50 | - if ( ! is_wp_error( $return ) ) { |
|
| 50 | + if ( !is_wp_error( $return ) ) { |
|
| 51 | 51 | $return = $this->_parse_response( $return ); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $return = array(); |
| 81 | 81 | |
| 82 | - if ( isset( $response['results'][0]['geometry']['location'] ) ) { |
|
| 83 | - $return['lat'] = $response['results'][0]['geometry']['location']['lat']; |
|
| 82 | + if ( isset($response['results'][0]['geometry']['location']) ) { |
|
| 83 | + $return['lat'] = $response['results'][0]['geometry']['location']['lat']; |
|
| 84 | 84 | $return['lng'] = $response['results'][0]['geometry']['location']['lng']; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | $cache_key = md5( serialize( $url ) ); |
| 122 | 122 | |
| 123 | - if ( ! $data = wp_cache_get( $cache_key ) ) { |
|
| 123 | + if ( !$data = wp_cache_get( $cache_key ) ) { |
|
| 124 | 124 | $data = wp_remote_get( $url ); |
| 125 | 125 | wp_cache_add( $cache_key, $data, 300 ); |
| 126 | 126 | } |
@@ -18,48 +18,48 @@ |
||
| 18 | 18 | private $_geocoder; |
| 19 | 19 | |
| 20 | 20 | public function setUp() { |
| 21 | - $this->_geocoder = new Geocoder(['api_key' => '']); |
|
| 21 | + $this->_geocoder = new Geocoder( ['api_key' => ''] ); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * @covers ::_make_request |
| 26 | 26 | */ |
| 27 | 27 | public function testMakeRequest() { |
| 28 | - $url = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA'); |
|
| 29 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', $url); |
|
| 28 | + $url = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
| 29 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', $url ); |
|
| 30 | 30 | |
| 31 | - $this->assertInternalType('array', $response); |
|
| 31 | + $this->assertInternalType( 'array', $response ); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * @covers ::_make_request |
| 36 | 36 | */ |
| 37 | 37 | public function testMakeRequestError404() { |
| 38 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', 'https://maps.googleapis.com/maps/api/geo'); |
|
| 38 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', 'https://maps.googleapis.com/maps/api/geo' ); |
|
| 39 | 39 | |
| 40 | - $this->assertInstanceOf('WP_Error', $response); |
|
| 41 | - $this->assertObjectHasAttribute('errors', $response); |
|
| 42 | - $this->assertArrayHasKey('404', $response->errors); |
|
| 40 | + $this->assertInstanceOf( 'WP_Error', $response ); |
|
| 41 | + $this->assertObjectHasAttribute( 'errors', $response ); |
|
| 42 | + $this->assertArrayHasKey( '404', $response->errors ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * @covers ::_get_data |
| 47 | 47 | */ |
| 48 | 48 | public function testGetData() { |
| 49 | - $url = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA'); |
|
| 50 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_get_data', $url); |
|
| 49 | + $url = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
| 50 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_get_data', $url ); |
|
| 51 | 51 | |
| 52 | - $this->assertInternalType('array', $response); |
|
| 52 | + $this->assertInternalType( 'array', $response ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * @covers ::geocode |
| 57 | 57 | */ |
| 58 | 58 | public function testGeocode() { |
| 59 | - $result = $this->_geocoder->geocode('1600 Amphitheatre Parkway, Mountain View, CA'); |
|
| 59 | + $result = $this->_geocoder->geocode( '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
| 60 | 60 | |
| 61 | - $this->assertInternalType('array', $result); |
|
| 62 | - $this->assertArrayHasKey('lat', $result); |
|
| 63 | - $this->assertArrayHasKey('lng', $result); |
|
| 61 | + $this->assertInternalType( 'array', $result ); |
|
| 62 | + $this->assertArrayHasKey( 'lat', $result ); |
|
| 63 | + $this->assertArrayHasKey( 'lng', $result ); |
|
| 64 | 64 | } |
| 65 | 65 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | */ |
| 28 | 28 | public function setUp() { |
| 29 | - $this->_geocoder = new Geocoder(['api_key' => $this->_api_key]); |
|
| 29 | + $this->_geocoder = new Geocoder( ['api_key' => $this->_api_key] ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -34,46 +34,46 @@ discard block |
||
| 34 | 34 | * @covers ::api_key |
| 35 | 35 | */ |
| 36 | 36 | public function testConstructorWithAPIKey() { |
| 37 | - $this->assertEquals($this->_api_key, $this->_geocoder->api_key()); |
|
| 37 | + $this->assertEquals( $this->_api_key, $this->_geocoder->api_key() ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @covers ::_make_url |
| 42 | 42 | */ |
| 43 | 43 | public function testMakeUrl() { |
| 44 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '123 Anywhere Street New York 10001'); |
|
| 44 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '123 Anywhere Street New York 10001' ); |
|
| 45 | 45 | |
| 46 | - $this->assertInternalType('string', $response); |
|
| 47 | - $this->assertRegExp('/address\=123\+Anywhere\+Street\+New\+York\+10001/', $response); |
|
| 48 | - $this->assertRegExp("/key={$this->_api_key}/", $response); |
|
| 46 | + $this->assertInternalType( 'string', $response ); |
|
| 47 | + $this->assertRegExp( '/address\=123\+Anywhere\+Street\+New\+York\+10001/', $response ); |
|
| 48 | + $this->assertRegExp( "/key={$this->_api_key}/", $response ); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * @covers ::_get_data |
| 53 | 53 | */ |
| 54 | 54 | public function testGetDataCache() { |
| 55 | - wp_cache_add( md5(serialize('foo.bar')), 'foobar'); |
|
| 55 | + wp_cache_add( md5( serialize( 'foo.bar' ) ), 'foobar' ); |
|
| 56 | 56 | |
| 57 | - $this->assertEquals('foobar', $this->reflectionMethodInvokeArgs($this->_geocoder, '_get_data', 'foo.bar')); |
|
| 57 | + $this->assertEquals( 'foobar', $this->reflectionMethodInvokeArgs( $this->_geocoder, '_get_data', 'foo.bar' ) ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @covers ::_parse_response |
| 62 | 62 | */ |
| 63 | 63 | public function testParseResponse() { |
| 64 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_parse_response', json_decode(file_get_contents(INCLUDES_DIR . '/geocoder-response.json'), true)); |
|
| 64 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_parse_response', json_decode( file_get_contents( INCLUDES_DIR.'/geocoder-response.json' ), true ) ); |
|
| 65 | 65 | |
| 66 | - $this->assertInternalType('array', $response); |
|
| 67 | - $this->assertArrayHasKey('lat', $response); |
|
| 68 | - $this->assertArrayHasKey('lng', $response); |
|
| 66 | + $this->assertInternalType( 'array', $response ); |
|
| 67 | + $this->assertArrayHasKey( 'lat', $response ); |
|
| 68 | + $this->assertArrayHasKey( 'lng', $response ); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @covers ::_make_request |
| 73 | 73 | */ |
| 74 | 74 | public function testMakeRequestInvalidURL() { |
| 75 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', 'foo.bar'); |
|
| 76 | - $this->assertInstanceOf('WP_Error', $response); |
|
| 75 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', 'foo.bar' ); |
|
| 76 | + $this->assertInstanceOf( 'WP_Error', $response ); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | \ No newline at end of file |
@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | private $_latlng = ['lat' => 100.2345325, 'lng' => -45.23423423567]; |
| 35 | 35 | |
| 36 | 36 | public function setUp() { |
| 37 | - $this->_geocoder = \Mockery::mock('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder'); |
|
| 38 | - $this->_geocoder->shouldReceive('geocode')->andReturn($this->_latlng); |
|
| 37 | + $this->_geocoder = \Mockery::mock( '\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder' ); |
|
| 38 | + $this->_geocoder->shouldReceive( 'geocode' )->andReturn( $this->_latlng ); |
|
| 39 | 39 | |
| 40 | - $this->_model = new Marker_Model([ |
|
| 40 | + $this->_model = new Marker_Model( [ |
|
| 41 | 41 | 'address' => $this->_address, |
| 42 | 42 | 'geocoder' => $this->_geocoder, |
| 43 | - ]); |
|
| 43 | + ] ); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -50,15 +50,15 @@ discard block |
||
| 50 | 50 | public function testLatLngObject() { |
| 51 | 51 | $latlng = $this->_model->latlng_object(); |
| 52 | 52 | |
| 53 | - $this->assertJson($latlng); |
|
| 54 | - $this->assertEquals(json_encode($this->_latlng), $latlng); |
|
| 53 | + $this->assertJson( $latlng ); |
|
| 54 | + $this->assertEquals( json_encode( $this->_latlng ), $latlng ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * @covers ::_geocoder |
| 59 | 59 | */ |
| 60 | 60 | public function testGeocoder() { |
| 61 | - $this->assertEquals($this->_geocoder, $this->reflectionMethodInvoke($this->_model, '_geocoder')); |
|
| 61 | + $this->assertEquals( $this->_geocoder, $this->reflectionMethodInvoke( $this->_model, '_geocoder' ) ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -66,6 +66,6 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function testCreateGeocoder() { |
| 68 | 68 | $marker_model = new Marker_Model(); |
| 69 | - $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', $this->reflectionMethodInvoke($marker_model, '_geocoder')); |
|
| 69 | + $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', $this->reflectionMethodInvoke( $marker_model, '_geocoder' ) ); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | \ No newline at end of file |
@@ -1,26 +1,26 @@ |
||
| 1 | 1 | <?php |
| 2 | -define('VENDOR_DIRECTORY', dirname(__DIR__) . '/vendor'); |
|
| 3 | -define('INCLUDES_DIR', dirname(__FILE__) . '/includes'); |
|
| 2 | +define( 'VENDOR_DIRECTORY', dirname( __DIR__ ).'/vendor' ); |
|
| 3 | +define( 'INCLUDES_DIR', dirname( __FILE__ ).'/includes' ); |
|
| 4 | 4 | |
| 5 | -if (! file_exists( dirname(__DIR__) . '/build' ) ) { |
|
| 6 | - mkdir(dirname(__DIR__) . '/build'); |
|
| 5 | +if ( !file_exists( dirname( __DIR__ ).'/build' ) ) { |
|
| 6 | + mkdir( dirname( __DIR__ ).'/build' ); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -require_once getenv( 'WP_TESTS_DIR' ) . '/tests/phpunit/includes/functions.php'; |
|
| 10 | -require getenv( 'WP_TESTS_DIR' ) . '/tests/phpunit/includes/bootstrap.php'; |
|
| 9 | +require_once getenv( 'WP_TESTS_DIR' ).'/tests/phpunit/includes/functions.php'; |
|
| 10 | +require getenv( 'WP_TESTS_DIR' ).'/tests/phpunit/includes/bootstrap.php'; |
|
| 11 | 11 | |
| 12 | 12 | require 'includes/testCase.php'; |
| 13 | 13 | |
| 14 | -require VENDOR_DIRECTORY . '/autoload.php'; |
|
| 14 | +require VENDOR_DIRECTORY.'/autoload.php'; |
|
| 15 | 15 | |
| 16 | -if ( ! function_exists( 'wplib_define' ) ) { |
|
| 17 | - require( VENDOR_DIRECTORY . '/wplib/wplib/defines.php' ); |
|
| 16 | +if ( !function_exists( 'wplib_define' ) ) { |
|
| 17 | + require(VENDOR_DIRECTORY.'/wplib/wplib/defines.php'); |
|
| 18 | 18 | wplib_define( 'WPLib_Runmode', 'PRODUCTION' ); |
| 19 | 19 | wplib_define( 'WPLib_Stability', 'EXPERIMENTAL' ); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -require VENDOR_DIRECTORY . '/wplib/wplib/wplib.php'; |
|
| 22 | +require VENDOR_DIRECTORY.'/wplib/wplib/wplib.php'; |
|
| 23 | 23 | WPLib::initialize(); |
| 24 | 24 | |
| 25 | -require_once dirname(__DIR__) . '/includes/class-geocoder.php'; |
|
| 26 | -require_once dirname(__DIR__) . '/includes/class-marker-model.php'; |
|
| 25 | +require_once dirname( __DIR__ ).'/includes/class-geocoder.php'; |
|
| 26 | +require_once dirname( __DIR__ ).'/includes/class-marker-model.php'; |
|
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | protected $_latlng; |
| 27 | 27 | |
| 28 | 28 | function latlng_object() { |
| 29 | - if (empty($this->_latlng)) { |
|
| 30 | - $this->_latlng = $this->_geocoder()->geocode($this->_address); |
|
| 29 | + if ( empty($this->_latlng) ) { |
|
| 30 | + $this->_latlng = $this->_geocoder()->geocode( $this->_address ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | return json_encode( $this->_latlng ); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @return Geocoder |
| 38 | 38 | */ |
| 39 | 39 | private function _geocoder() { |
| 40 | - if (! is_object($this->_geocoder)) { |
|
| 40 | + if ( !is_object( $this->_geocoder ) ) { |
|
| 41 | 41 | $this->_geocoder = new Geocoder(); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -6,6 +6,6 @@ |
||
| 6 | 6 | * Class Marker_View |
| 7 | 7 | * @package Clubdeuce\WPLib\Components\GoogleMaps |
| 8 | 8 | */ |
| 9 | -class Marker_View extends \WPLib_View_Base { |
|
| 9 | +class Marker_View extends \WPLib_View_Base { |
|
| 10 | 10 | |
| 11 | 11 | } |
| 12 | 12 | \ No newline at end of file |