@@ -63,12 +63,12 @@ |
||
63 | 63 | return $reflection->invoke( $class, $args ); |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * @return string |
|
68 | - */ |
|
66 | + /** |
|
67 | + * @return string |
|
68 | + */ |
|
69 | 69 | public function get_sample_response() { |
70 | 70 | |
71 | - return file_get_contents( __DIR__ . '/geocoder-response.json' ); |
|
71 | + return file_get_contents( __DIR__ . '/geocoder-response.json' ); |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $reflection = new \ReflectionMethod( $class, $method ); |
43 | 43 | $reflection->setAccessible( true ); |
44 | - if (is_string($class)) { |
|
44 | + if ( is_string( $class ) ) { |
|
45 | 45 | $class = null; |
46 | 46 | } |
47 | 47 | return $reflection->invoke( $class ); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | $reflection = new \ReflectionMethod( $class, $method ); |
59 | 59 | $reflection->setAccessible( true ); |
60 | - if (is_string($class)) { |
|
60 | + if ( is_string( $class ) ) { |
|
61 | 61 | $class = null; |
62 | 62 | } |
63 | 63 | return $reflection->invoke( $class, $args ); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function get_sample_response() { |
70 | 70 | |
71 | - return file_get_contents( __DIR__ . '/geocoder-response.json' ); |
|
71 | + return file_get_contents( __DIR__.'/geocoder-response.json' ); |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -1,38 +1,38 @@ |
||
1 | 1 | <?php |
2 | -define('SRC_DIR', dirname(__DIR__)); |
|
3 | -define('VENDOR_DIRECTORY', SRC_DIR . '/vendor'); |
|
4 | -define('TEST_INCLUDES_DIR', SRC_DIR . '/includes'); |
|
2 | +define( 'SRC_DIR', dirname( __DIR__ ) ); |
|
3 | +define( 'VENDOR_DIRECTORY', SRC_DIR.'/vendor' ); |
|
4 | +define( 'TEST_INCLUDES_DIR', SRC_DIR.'/includes' ); |
|
5 | 5 | |
6 | -require_once getenv( 'WP_TESTS_DIR' ) . '/tests/phpunit/includes/functions.php'; |
|
7 | -require getenv( 'WP_TESTS_DIR' ) . '/tests/phpunit/includes/bootstrap.php'; |
|
6 | +require_once getenv( 'WP_TESTS_DIR' ).'/tests/phpunit/includes/functions.php'; |
|
7 | +require getenv( 'WP_TESTS_DIR' ).'/tests/phpunit/includes/bootstrap.php'; |
|
8 | 8 | |
9 | 9 | require 'includes/testCase.php'; |
10 | 10 | |
11 | -require VENDOR_DIRECTORY . '/autoload.php'; |
|
11 | +require VENDOR_DIRECTORY.'/autoload.php'; |
|
12 | 12 | |
13 | -if ( ! function_exists( 'wplib_define' ) ) { |
|
14 | - require( VENDOR_DIRECTORY . '/wplib/wplib/defines.php' ); |
|
13 | +if ( !function_exists( 'wplib_define' ) ) { |
|
14 | + require(VENDOR_DIRECTORY.'/wplib/wplib/defines.php'); |
|
15 | 15 | wplib_define( 'WPLib_Runmode', 'PRODUCTION' ); |
16 | 16 | wplib_define( 'WPLib_Stability', 'EXPERIMENTAL' ); |
17 | 17 | } |
18 | 18 | |
19 | -require VENDOR_DIRECTORY . '/wplib/wplib/wplib.php'; |
|
19 | +require VENDOR_DIRECTORY.'/wplib/wplib/wplib.php'; |
|
20 | 20 | WPLib::initialize(); |
21 | 21 | |
22 | -require_once dirname(__DIR__) . '/includes/class-geocoder.php'; |
|
23 | -require_once dirname(__DIR__) . '/includes/class-info-window-model.php'; |
|
24 | -require_once dirname(__DIR__) . '/includes/class-info-window-view.php'; |
|
25 | -require_once dirname(__DIR__) . '/includes/class-info-window.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-map.php'; |
|
30 | -require_once dirname(__DIR__) . '/includes/class-map-model.php'; |
|
31 | -require_once dirname(__DIR__) . '/includes/class-map-view.php'; |
|
32 | -require_once dirname(__DIR__) . '/includes/class-marker.php'; |
|
33 | -require_once dirname(__DIR__) . '/includes/class-marker-label.php'; |
|
34 | -require_once dirname(__DIR__) . '/includes/class-marker-label-model.php'; |
|
35 | -require_once dirname(__DIR__) . '/includes/class-marker-label-view.php'; |
|
36 | -require_once dirname(__DIR__) . '/includes/class-marker-model.php'; |
|
37 | -require_once dirname(__DIR__) . '/includes/class-marker-view.php'; |
|
38 | -require_once dirname(__DIR__) . '/component-google-maps.php'; |
|
22 | +require_once dirname( __DIR__ ).'/includes/class-geocoder.php'; |
|
23 | +require_once dirname( __DIR__ ).'/includes/class-info-window-model.php'; |
|
24 | +require_once dirname( __DIR__ ).'/includes/class-info-window-view.php'; |
|
25 | +require_once dirname( __DIR__ ).'/includes/class-info-window.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-map.php'; |
|
30 | +require_once dirname( __DIR__ ).'/includes/class-map-model.php'; |
|
31 | +require_once dirname( __DIR__ ).'/includes/class-map-view.php'; |
|
32 | +require_once dirname( __DIR__ ).'/includes/class-marker.php'; |
|
33 | +require_once dirname( __DIR__ ).'/includes/class-marker-label.php'; |
|
34 | +require_once dirname( __DIR__ ).'/includes/class-marker-label-model.php'; |
|
35 | +require_once dirname( __DIR__ ).'/includes/class-marker-label-view.php'; |
|
36 | +require_once dirname( __DIR__ ).'/includes/class-marker-model.php'; |
|
37 | +require_once dirname( __DIR__ ).'/includes/class-marker-view.php'; |
|
38 | +require_once dirname( __DIR__ ).'/component-google-maps.php'; |
@@ -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($this->get_sample_response(), true); |
|
66 | - $location = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_location', $response['results'][0] ); |
|
65 | + $response = json_decode( $this->get_sample_response(), 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 |
@@ -14,24 +14,24 @@ |
||
14 | 14 | */ |
15 | 15 | class TestGoogleMaps extends TestCase { |
16 | 16 | |
17 | - /** |
|
18 | - * @covers ::_wp_enqueue_scripts_9 |
|
19 | - */ |
|
20 | - function testScriptRegistered() { |
|
21 | - $this->assertTrue(wp_script_is('google-maps', 'registered')); |
|
22 | - $this->assertTrue(wp_script_is('map-control', 'registered')); |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @covers ::_wp_enqueue_scripts_9 |
|
27 | - * @depends testScriptRegistered |
|
28 | - */ |
|
29 | - function testScriptEnqueued() { |
|
30 | - |
|
31 | - Google_Maps::register_script_condition(function(){return true;}); |
|
32 | - |
|
33 | - $this->assertTrue(wp_script_is('google-maps', 'enqueued')); |
|
34 | - $this->assertTrue(wp_script_is('map-control', 'enqueued')); |
|
35 | - |
|
36 | - } |
|
17 | + /** |
|
18 | + * @covers ::_wp_enqueue_scripts_9 |
|
19 | + */ |
|
20 | + function testScriptRegistered() { |
|
21 | + $this->assertTrue(wp_script_is('google-maps', 'registered')); |
|
22 | + $this->assertTrue(wp_script_is('map-control', 'registered')); |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @covers ::_wp_enqueue_scripts_9 |
|
27 | + * @depends testScriptRegistered |
|
28 | + */ |
|
29 | + function testScriptEnqueued() { |
|
30 | + |
|
31 | + Google_Maps::register_script_condition(function(){return true;}); |
|
32 | + |
|
33 | + $this->assertTrue(wp_script_is('google-maps', 'enqueued')); |
|
34 | + $this->assertTrue(wp_script_is('map-control', 'enqueued')); |
|
35 | + |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | \ No newline at end of file |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | * @covers ::_wp_enqueue_scripts_9 |
19 | 19 | */ |
20 | 20 | function testScriptRegistered() { |
21 | - $this->assertTrue(wp_script_is('google-maps', 'registered')); |
|
22 | - $this->assertTrue(wp_script_is('map-control', 'registered')); |
|
21 | + $this->assertTrue( wp_script_is( 'google-maps', 'registered' ) ); |
|
22 | + $this->assertTrue( wp_script_is( 'map-control', 'registered' ) ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function testScriptEnqueued() { |
30 | 30 | |
31 | - Google_Maps::register_script_condition(function(){return true;}); |
|
31 | + Google_Maps::register_script_condition( function() {return true; }); |
|
32 | 32 | |
33 | - $this->assertTrue(wp_script_is('google-maps', 'enqueued')); |
|
34 | - $this->assertTrue(wp_script_is('map-control', 'enqueued')); |
|
33 | + $this->assertTrue( wp_script_is( 'google-maps', 'enqueued' ) ); |
|
34 | + $this->assertTrue( wp_script_is( 'map-control', 'enqueued' ) ); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | } |
38 | 38 | \ No newline at end of file |