Completed
Push — master ( d8adec...3d8ab4 )
by Daryl
03:59
created
includes/class-geocoder.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,7 +73,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 ) {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
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 );
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
templates/map-view.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
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>
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,36 +1,36 @@
 block discarded – undo
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';
Please login to merge, or discard this patch.
tests/unit/testGoogleMaps.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
tests/unit/testMapModel.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     
26 26
     public function setUp() {
27 27
         
28
-        $this->_model = new Map_Model(array('center' => $this->_center, 'markers' => array('foo', 'bar', 'baz'), 'zoom' => 12));
28
+        $this->_model = new Map_Model( array( 'center' => $this->_center, 'markers' => array( 'foo', 'bar', 'baz' ), 'zoom' => 12 ) );
29 29
         
30 30
     }
31 31
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function testCenter() {
36 36
 
37
-        $this->assertEquals($this->_center, $this->_model->center());
37
+        $this->assertEquals( $this->_center, $this->_model->center() );
38 38
 
39 39
     }
40 40
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function testMarkers() {
45 45
 
46
-        $this->assertEquals(array('foo','bar','baz'), $this->_model->markers());
46
+        $this->assertEquals( array( 'foo', 'bar', 'baz' ), $this->_model->markers() );
47 47
 
48 48
     }
49 49
 
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
      */
54 54
     function testAddMarker() {
55 55
 
56
-        $this->_model->add_marker('foobar');
56
+        $this->_model->add_marker( 'foobar' );
57 57
 
58
-        $this->assertContains('foobar', $this->_model->markers());
58
+        $this->assertContains( 'foobar', $this->_model->markers() );
59 59
 
60 60
     }
61 61
 
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
      */
66 66
     function testAddMarkers() {
67 67
 
68
-        $this->_model->add_markers(array('foobar', 'barbaz'));
68
+        $this->_model->add_markers( array( 'foobar', 'barbaz' ) );
69 69
 
70 70
         $markers = $this->_model->markers();
71 71
 
72
-        $this->assertContains('foobar', $markers);
73
-        $this->assertContains('barbaz', $markers);
72
+        $this->assertContains( 'foobar', $markers );
73
+        $this->assertContains( 'barbaz', $markers );
74 74
 
75 75
     }
76 76
 
@@ -78,6 +78,6 @@  discard block
 block discarded – undo
78 78
      * @covers ::zoom
79 79
      */
80 80
     public function testZoom() {
81
-        $this->assertEquals(12, $this->_model->zoom());
81
+        $this->assertEquals( 12, $this->_model->zoom() );
82 82
     }
83 83
 }
Please login to merge, or discard this patch.
tests/unit/testGeocoder.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
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,53 +35,53 @@  discard block
 block discarded – undo
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
-        $location = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_location', json_decode(file_get_contents(TEST_INCLUDES_DIR . '/geocoder-response.json'), true));
65
+        $location = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_location', json_decode( file_get_contents( TEST_INCLUDES_DIR.'/geocoder-response.json' ), true ) );
66 66
 
67
-        $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location);
68
-        $this->assertEquals('1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->address());
69
-        $this->assertEquals('1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->formatted_address());
70
-        $this->assertEquals(37.4224764, $location->latitude());
67
+        $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location );
68
+        $this->assertEquals( '1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->address() );
69
+        $this->assertEquals( '1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->formatted_address() );
70
+        $this->assertEquals( 37.4224764, $location->latitude() );
71 71
         $this->assertEquals(-122.0842499, $location->longitude());
72
-        $this->assertEquals('ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id());
73
-        $this->assertInternalType('array', $location->viewport());
74
-        $this->assertArrayHasKey('northeast', $location->viewport());
75
-        $this->assertArrayHasKey('southwest', $location->viewport());
76
-        $this->assertInternalType('array', $location->viewport()['northeast']);
77
-        $this->assertArrayHasKey('lat', $location->viewport()['northeast']);
78
-        $this->assertArrayHasKey('lng', $location->viewport()['northeast']);
79
-        $this->assertEquals(37.4238253802915, $location->viewport()['northeast']['lat']);
72
+        $this->assertEquals( 'ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id() );
73
+        $this->assertInternalType( 'array', $location->viewport() );
74
+        $this->assertArrayHasKey( 'northeast', $location->viewport() );
75
+        $this->assertArrayHasKey( 'southwest', $location->viewport() );
76
+        $this->assertInternalType( 'array', $location->viewport()['northeast'] );
77
+        $this->assertArrayHasKey( 'lat', $location->viewport()['northeast'] );
78
+        $this->assertArrayHasKey( 'lng', $location->viewport()['northeast'] );
79
+        $this->assertEquals( 37.4238253802915, $location->viewport()['northeast']['lat'] );
80 80
         $this->assertEquals(-122.0829009197085, $location->viewport()['northeast']['lng']);
81
-        $this->assertInternalType('array', $location->viewport()['southwest']);
82
-        $this->assertArrayHasKey('lat', $location->viewport()['southwest']);
83
-        $this->assertArrayHasKey('lng', $location->viewport()['southwest']);
84
-        $this->assertEquals(37.4211274197085, $location->viewport()['southwest']['lat']);
81
+        $this->assertInternalType( 'array', $location->viewport()['southwest'] );
82
+        $this->assertArrayHasKey( 'lat', $location->viewport()['southwest'] );
83
+        $this->assertArrayHasKey( 'lng', $location->viewport()['southwest'] );
84
+        $this->assertEquals( 37.4211274197085, $location->viewport()['southwest']['lat'] );
85 85
         $this->assertEquals(-122.0855988802915, $location->viewport()['southwest']['lng']);
86 86
     }
87 87
 
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
      * @covers ::_make_request
90 90
      */
91 91
     public function testMakeRequestInvalidURL() {
92
-        $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', 'foo.bar');
93
-        $this->assertInstanceOf('WP_Error', $response);
92
+        $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', 'foo.bar' );
93
+        $this->assertInstanceOf( 'WP_Error', $response );
94 94
     }
95 95
 
96 96
 }
97 97
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-map-model.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
      */
84 84
     function html_id() {
85 85
 
86
-        if ( ! isset( $this->_html_id ) ) {
86
+        if ( !isset($this->_html_id) ) {
87 87
             $this->_html_id = sprintf( 'map-%1$s', md5( serialize( array( $this->center(), $this->markers() ) ) ) );
88 88
         }
89 89
 
Please login to merge, or discard this patch.
includes/class-map-view.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
         $markers      = $this->_make_markers_args();
19 19
         $info_windows = $this->_make_info_windows();
20 20
 
21
-        require dirname( __DIR__) . '/templates/map-view.php';
21
+        require dirname( __DIR__ ).'/templates/map-view.php';
22 22
 
23 23
     }
24 24
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         /**
47 47
          * @var Marker $marker
48 48
          */
49
-        foreach( $this->item->markers() as $marker ) {
49
+        foreach ( $this->item->markers() as $marker ) {
50 50
             $windows[] = array(
51 51
                 'content'      => $marker->info_window()->content(),
52 52
                 'pixel_offset' => $marker->info_window()->pixel_offset(),
Please login to merge, or discard this patch.