@@ -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 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | private $_location; |
19 | 19 | |
20 | 20 | public function setUp() { |
21 | - $this->_location = new Location_Model([ |
|
21 | + $this->_location = new Location_Model( [ |
|
22 | 22 | 'address' => '1600 Amphitheatre Parkway Mountain View CA', |
23 | 23 | 'formatted_address' => '1600 Amphitheatre Parkway, Mountain View, CA, 12345', |
24 | 24 | 'latitude' => 100.12345, |
@@ -32,21 +32,21 @@ discard block |
||
32 | 32 | * @covers ::__call |
33 | 33 | */ |
34 | 34 | public function testAddress() { |
35 | - $this->assertEquals('1600 Amphitheatre Parkway Mountain View CA', $this->_location->address()); |
|
35 | + $this->assertEquals( '1600 Amphitheatre Parkway Mountain View CA', $this->_location->address() ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @covers ::__call |
40 | 40 | */ |
41 | 41 | public function testFormattedAddress() { |
42 | - $this->assertEquals('1600 Amphitheatre Parkway, Mountain View, CA, 12345', $this->_location->formatted_address()); |
|
42 | + $this->assertEquals( '1600 Amphitheatre Parkway, Mountain View, CA, 12345', $this->_location->formatted_address() ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @covers ::__call |
47 | 47 | */ |
48 | 48 | public function testLatitude() { |
49 | - $this->assertEquals(100.12345, $this->_location->latitude()); |
|
49 | + $this->assertEquals( 100.12345, $this->_location->latitude() ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @covers ::__call() |
61 | 61 | */ |
62 | 62 | public function testPlaceId() { |
63 | - $this->assertEquals('foobar', $this->_location->place_id()); |
|
63 | + $this->assertEquals( 'foobar', $this->_location->place_id() ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @covers ::__call() |
68 | 68 | */ |
69 | 69 | public function testViewport() { |
70 | - $this->assertEquals(['foo', 'bar'], $this->_location->viewport()); |
|
70 | + $this->assertEquals( ['foo', 'bar'], $this->_location->viewport() ); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | \ No newline at end of file |
@@ -19,38 +19,38 @@ discard block |
||
19 | 19 | private $_geocoder; |
20 | 20 | |
21 | 21 | public function setUp() { |
22 | - $this->_geocoder = new Geocoder(['api_key' => '']); |
|
22 | + $this->_geocoder = new Geocoder( ['api_key' => ''] ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @covers ::_make_request |
27 | 27 | */ |
28 | 28 | public function testMakeRequest() { |
29 | - $url = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA'); |
|
30 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', $url); |
|
29 | + $url = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
30 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', $url ); |
|
31 | 31 | |
32 | - $this->assertInternalType('array', $response); |
|
32 | + $this->assertInternalType( 'array', $response ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @covers ::_make_request |
37 | 37 | */ |
38 | 38 | public function testMakeRequestError404() { |
39 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', 'https://maps.googleapis.com/maps/api/geo'); |
|
39 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', 'https://maps.googleapis.com/maps/api/geo' ); |
|
40 | 40 | |
41 | - $this->assertInstanceOf('WP_Error', $response); |
|
42 | - $this->assertObjectHasAttribute('errors', $response); |
|
43 | - $this->assertArrayHasKey('404', $response->errors); |
|
41 | + $this->assertInstanceOf( 'WP_Error', $response ); |
|
42 | + $this->assertObjectHasAttribute( 'errors', $response ); |
|
43 | + $this->assertArrayHasKey( '404', $response->errors ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @covers ::_get_data |
48 | 48 | */ |
49 | 49 | public function testGetData() { |
50 | - $url = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA'); |
|
51 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_get_data', $url); |
|
50 | + $url = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
51 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_get_data', $url ); |
|
52 | 52 | |
53 | - $this->assertInternalType('array', $response); |
|
53 | + $this->assertInternalType( 'array', $response ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -58,26 +58,26 @@ discard block |
||
58 | 58 | * @covers ::_make_location |
59 | 59 | */ |
60 | 60 | public function testGeocode() { |
61 | - $location = $this->_geocoder->geocode('1600 Amphitheatre Parkway, Mountain View, CA'); |
|
61 | + $location = $this->_geocoder->geocode( '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
62 | 62 | |
63 | - $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location); |
|
64 | - $this->assertEquals('1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->address()); |
|
65 | - $this->assertEquals('1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->formatted_address()); |
|
66 | - $this->assertEquals(37.422366400000001, $location->latitude()); |
|
63 | + $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location ); |
|
64 | + $this->assertEquals( '1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->address() ); |
|
65 | + $this->assertEquals( '1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->formatted_address() ); |
|
66 | + $this->assertEquals( 37.422366400000001, $location->latitude() ); |
|
67 | 67 | $this->assertEquals(-122.084406, $location->longitude()); |
68 | - $this->assertEquals('ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id()); |
|
69 | - $this->assertInternalType('array', $location->viewport()); |
|
70 | - $this->assertArrayHasKey('northeast', $location->viewport()); |
|
71 | - $this->assertArrayHasKey('southwest', $location->viewport()); |
|
72 | - $this->assertInternalType('array', $location->viewport()['northeast']); |
|
73 | - $this->assertArrayHasKey('lat', $location->viewport()['northeast']); |
|
74 | - $this->assertArrayHasKey('lng', $location->viewport()['northeast']); |
|
75 | - $this->assertEquals(37.423715380291497, $location->viewport()['northeast']['lat']); |
|
68 | + $this->assertEquals( 'ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id() ); |
|
69 | + $this->assertInternalType( 'array', $location->viewport() ); |
|
70 | + $this->assertArrayHasKey( 'northeast', $location->viewport() ); |
|
71 | + $this->assertArrayHasKey( 'southwest', $location->viewport() ); |
|
72 | + $this->assertInternalType( 'array', $location->viewport()['northeast'] ); |
|
73 | + $this->assertArrayHasKey( 'lat', $location->viewport()['northeast'] ); |
|
74 | + $this->assertArrayHasKey( 'lng', $location->viewport()['northeast'] ); |
|
75 | + $this->assertEquals( 37.423715380291497, $location->viewport()['northeast']['lat'] ); |
|
76 | 76 | $this->assertEquals(-122.08305701970851, $location->viewport()['northeast']['lng']); |
77 | - $this->assertInternalType('array', $location->viewport()['southwest']); |
|
78 | - $this->assertArrayHasKey('lat', $location->viewport()['southwest']); |
|
79 | - $this->assertArrayHasKey('lng', $location->viewport()['southwest']); |
|
80 | - $this->assertEquals(37.421017419708512, $location->viewport()['southwest']['lat']); |
|
77 | + $this->assertInternalType( 'array', $location->viewport()['southwest'] ); |
|
78 | + $this->assertArrayHasKey( 'lat', $location->viewport()['southwest'] ); |
|
79 | + $this->assertArrayHasKey( 'lng', $location->viewport()['southwest'] ); |
|
80 | + $this->assertEquals( 37.421017419708512, $location->viewport()['southwest']['lat'] ); |
|
81 | 81 | $this->assertEquals(-122.0857549802915, $location->viewport()['southwest']['lng']); |
82 | 82 | } |
83 | 83 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | |
34 | 34 | public function setUp() { |
35 | - $this->_location = new Location([ |
|
35 | + $this->_location = new Location( [ |
|
36 | 36 | 'address' => '123 Anywhere Street Anywhere NY', |
37 | 37 | 'formatted_address' => '123 Anywhere Street, Anywhere, NY 12345 USA', |
38 | 38 | 'latitude' => 100.12345, |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | 'place_id' => 'foobar', |
41 | 41 | 'types' => ['foo', 'bar'], |
42 | 42 | 'viewport' => ['northeast' => ['lat' => 100.12346, 'lng' => -100.12344], 'southwest' => ['lat' => 100.12344, 'lng' => -100.12346]], |
43 | - ]); |
|
43 | + ] ); |
|
44 | 44 | |
45 | - $this->_geocoder = \Mockery::mock('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder'); |
|
46 | - $this->_geocoder->shouldReceive('geocode')->andReturn($this->_location); |
|
45 | + $this->_geocoder = \Mockery::mock( '\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder' ); |
|
46 | + $this->_geocoder->shouldReceive( 'geocode' )->andReturn( $this->_location ); |
|
47 | 47 | |
48 | - $this->_model = new Marker_Model([ |
|
48 | + $this->_model = new Marker_Model( [ |
|
49 | 49 | 'address' => $this->_address, |
50 | 50 | 'geocoder' => $this->_geocoder, |
51 | - ]); |
|
51 | + ] ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | * @covers ::latitude |
57 | 57 | */ |
58 | 58 | public function testLatitude() { |
59 | - $this->assertEquals(100.12345, $this->_model->latitude()); |
|
59 | + $this->assertEquals( 100.12345, $this->_model->latitude() ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @covers ::location |
64 | 64 | */ |
65 | 65 | public function testLocation() { |
66 | - $this->assertEquals($this->_location, $this->_model->location()); |
|
66 | + $this->assertEquals( $this->_location, $this->_model->location() ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @covers ::_geocoder |
78 | 78 | */ |
79 | 79 | public function testGeocoder() { |
80 | - $this->assertEquals($this->_geocoder, $this->reflectionMethodInvoke($this->_model, '_geocoder')); |
|
80 | + $this->assertEquals( $this->_geocoder, $this->reflectionMethodInvoke( $this->_model, '_geocoder' ) ); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -85,6 +85,6 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function testCreateGeocoder() { |
87 | 87 | $marker_model = new Marker_Model(); |
88 | - $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', $this->reflectionMethodInvoke($marker_model, '_geocoder')); |
|
88 | + $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', $this->reflectionMethodInvoke( $marker_model, '_geocoder' ) ); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | \ No newline at end of file |
@@ -23,7 +23,7 @@ |
||
23 | 23 | function make_args() { |
24 | 24 | return array( |
25 | 25 | 'center' => $this->center(), |
26 | - 'zoom' => (int)$this->zoom(), |
|
26 | + 'zoom' => ( int ) $this->zoom(), |
|
27 | 27 | ); |
28 | 28 | } |
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -73,7 +73,6 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * Convert the response body into an a Location object |
75 | 75 | * |
76 | - * @param array $response |
|
77 | 76 | * @return Location |
78 | 77 | */ |
79 | 78 | private function _make_location( $results ) { |
@@ -95,7 +94,7 @@ discard block |
||
95 | 94 | |
96 | 95 | |
97 | 96 | /** |
98 | - * @param $url |
|
97 | + * @param string $url |
|
99 | 98 | * @return array|\WP_Error |
100 | 99 | */ |
101 | 100 | private function _make_request( $url ) { |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | */ |
44 | 44 | function geocode( $address ) { |
45 | 45 | |
46 | - $location = new \WP_Error(100, 'No results found', array( 'address' => $address ) ); |
|
46 | + $location = new \WP_Error( 100, 'No results found', array( 'address' => $address ) ); |
|
47 | 47 | $url = $this->_make_url( $address ); |
48 | 48 | |
49 | 49 | $response = $this->_make_request( $url ); |
50 | 50 | |
51 | - if ( ! is_wp_error( $response ) && count( $response['results'] ) > 0 ) { |
|
51 | + if ( !is_wp_error( $response ) && count( $response['results'] ) > 0 ) { |
|
52 | 52 | $location = $this->_make_location( $response['results'][0] ); |
53 | 53 | } |
54 | 54 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $response = new Location( array( |
82 | 82 | 'address' => $results['formatted_address'], |
83 | 83 | 'formatted_address' => $results['formatted_address'], |
84 | - 'state' => isset( $results['address_components'][4] ) ? $results['address_components'][4]['short_name'] : '', |
|
84 | + 'state' => isset($results['address_components'][4]) ? $results['address_components'][4]['short_name'] : '', |
|
85 | 85 | 'latitude' => $results['geometry']['location']['lat'], |
86 | 86 | 'longitude' => $results['geometry']['location']['lng'], |
87 | 87 | 'place_id' => $results['place_id'], |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | $cache_key = md5( serialize( $url ) ); |
127 | 127 | |
128 | - if ( ! $data = wp_cache_get( $cache_key ) ) { |
|
128 | + if ( !$data = wp_cache_get( $cache_key ) ) { |
|
129 | 129 | $data = wp_remote_get( $url ); |
130 | 130 | wp_cache_add( $cache_key, $data, 300 ); |
131 | 131 | } |
@@ -12,10 +12,10 @@ |
||
12 | 12 | <script type="application/javascript"> |
13 | 13 | jQuery(document).ready(function() { |
14 | 14 | generate_map( |
15 | - "<?php echo esc_js($map_id); ?>", |
|
16 | - <?php echo json_encode($map_params); ?>, |
|
17 | - <?php echo json_encode($markers); ?>, |
|
18 | - <?php echo json_encode($info_windows); ?> |
|
15 | + "<?php echo esc_js( $map_id ); ?>", |
|
16 | + <?php echo json_encode( $map_params ); ?>, |
|
17 | + <?php echo json_encode( $markers ); ?>, |
|
18 | + <?php echo json_encode( $info_windows ); ?> |
|
19 | 19 | ); |
20 | 20 | }); |
21 | 21 | </script> |
@@ -1,36 +1,36 @@ |
||
1 | 1 | <?php |
2 | -define('VENDOR_DIRECTORY', dirname(__DIR__) . '/vendor'); |
|
3 | -define('TEST_INCLUDES_DIR', dirname(__FILE__) . '/includes'); |
|
2 | +define( 'VENDOR_DIRECTORY', dirname( __DIR__ ).'/vendor' ); |
|
3 | +define( 'TEST_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-location.php'; |
|
27 | -require_once dirname(__DIR__) . '/includes/class-location-model.php'; |
|
28 | -require_once dirname(__DIR__) . '/includes/class-location-view.php'; |
|
29 | -require_once dirname(__DIR__) . '/includes/class-info-window-model.php'; |
|
30 | -require_once dirname(__DIR__) . '/includes/class-info-window-view.php'; |
|
31 | -require_once dirname(__DIR__) . '/includes/class-info-window.php'; |
|
32 | -require_once dirname(__DIR__) . '/includes/class-marker-model.php'; |
|
33 | -require_once dirname(__DIR__) . '/includes/class-map.php'; |
|
34 | -require_once dirname(__DIR__) . '/includes/class-map-model.php'; |
|
35 | -require_once dirname(__DIR__) . '/includes/class-map-view.php'; |
|
36 | -require_once dirname(__DIR__) . '/component-google-maps.php'; |
|
25 | +require_once dirname( __DIR__ ).'/includes/class-geocoder.php'; |
|
26 | +require_once dirname( __DIR__ ).'/includes/class-location.php'; |
|
27 | +require_once dirname( __DIR__ ).'/includes/class-location-model.php'; |
|
28 | +require_once dirname( __DIR__ ).'/includes/class-location-view.php'; |
|
29 | +require_once dirname( __DIR__ ).'/includes/class-info-window-model.php'; |
|
30 | +require_once dirname( __DIR__ ).'/includes/class-info-window-view.php'; |
|
31 | +require_once dirname( __DIR__ ).'/includes/class-info-window.php'; |
|
32 | +require_once dirname( __DIR__ ).'/includes/class-marker-model.php'; |
|
33 | +require_once dirname( __DIR__ ).'/includes/class-map.php'; |
|
34 | +require_once dirname( __DIR__ ).'/includes/class-map-model.php'; |
|
35 | +require_once dirname( __DIR__ ).'/includes/class-map-view.php'; |
|
36 | +require_once dirname( __DIR__ ).'/component-google-maps.php'; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Clubdeuce\WPLib\Components\GoogleMaps\Tests\UnitTests; |
4 | 4 | |
5 | -require_once dirname( dirname(__DIR__) ) . '/component-google-maps.php'; |
|
5 | +require_once dirname( dirname( __DIR__ ) ).'/component-google-maps.php'; |
|
6 | 6 | |
7 | 7 | use Clubdeuce\WPLib\Components\Google_Maps; |
8 | 8 | use Clubdeuce\WPLib\Components\GoogleMaps\Tests\TestCase; |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function testApiKeySetAndGet() { |
22 | 22 | |
23 | - Google_Maps::register_api_key('foo'); |
|
24 | - $this->assertEquals('foo', Google_Maps::api_key()); |
|
23 | + Google_Maps::register_api_key( 'foo' ); |
|
24 | + $this->assertEquals( 'foo', Google_Maps::api_key() ); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function testGeocoder() { |
32 | 32 | |
33 | - $this->assertInstanceOf('Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', Google_Maps::geocoder()); |
|
33 | + $this->assertInstanceOf( 'Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', Google_Maps::geocoder() ); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | $map = Google_Maps::make_new_map(); |
43 | 43 | |
44 | - $this->assertInstanceOf('Clubdeuce\WPLib\Components\GoogleMaps\Map', $map); |
|
44 | + $this->assertInstanceOf( 'Clubdeuce\WPLib\Components\GoogleMaps\Map', $map ); |
|
45 | 45 | |
46 | 46 | } |
47 | 47 |