@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | */ |
62 | 62 | static function geocoder() { |
63 | 63 | |
64 | - if ( ! isset( static::$_geocoder ) ) { |
|
65 | - static::$_geocoder = new Geocoder( ['api_key' => self::api_key() ] ); |
|
64 | + if ( !isset(static::$_geocoder) ) { |
|
65 | + static::$_geocoder = new Geocoder( ['api_key' => self::api_key()] ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | return static::$_geocoder; |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | $source = sprintf( '%1$s/assets/maps.js', self::source_url() ); |
108 | 108 | } |
109 | 109 | |
110 | - wp_register_script('google-maps', "https://maps.google.com/maps/api/js?v=3&key={$key}", false, '3.0', true ); |
|
111 | - wp_register_script('map-control', $source, array( 'jquery', 'google-maps' ), '0.1.2', true ); |
|
110 | + wp_register_script( 'google-maps', "https://maps.google.com/maps/api/js?v=3&key={$key}", false, '3.0', true ); |
|
111 | + wp_register_script( 'map-control', $source, array( 'jquery', 'google-maps' ), '0.1.2', true ); |
|
112 | 112 | |
113 | 113 | $conditions = array_map( array( __CLASS__, '_evaluate_condition' ), static::$_script_conditions ); |
114 | 114 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param array $args |
145 | 145 | * @return string |
146 | 146 | */ |
147 | - static function driving_directions_href($destination, $args = array() ) { |
|
147 | + static function driving_directions_href( $destination, $args = array() ) { |
|
148 | 148 | |
149 | 149 | $args = wp_parse_args( $args, array( |
150 | 150 | 'start' => 'My Location', |
@@ -7,48 +7,48 @@ |
||
7 | 7 | class RoboFile extends \Robo\Tasks |
8 | 8 | { |
9 | 9 | // define public methods as commands |
10 | - function tests() |
|
11 | - { |
|
12 | - |
|
13 | - $this->taskExec('mysql -e "CREATE DATABASE IF NOT EXISTS test_db"')->run(); |
|
14 | - $this->taskExec('mysql -e "GRANT ALL ON test_db.* to \'root\'@\'%\'"')->run(); |
|
15 | - $this->taskSvnStack() |
|
16 | - ->checkout('https://develop.svn.wordpress.org/tags/4.8.3 wp-tests') |
|
17 | - ->run(); |
|
18 | - |
|
19 | - $this->setTestConfig(); |
|
20 | - $this->phpunit(); |
|
21 | - |
|
22 | - } |
|
23 | - |
|
24 | - function phpunit() |
|
25 | - { |
|
26 | - $this->taskPhpUnit('vendor/bin/phpunit') |
|
27 | - ->configFile('tests/phpunit.xml.dist') |
|
28 | - ->run(); |
|
29 | - } |
|
30 | - |
|
31 | - private function setTestConfig() |
|
32 | - { |
|
33 | - |
|
34 | - if (file_exists('wp-tests/wp-tests-config-sample.php')) { |
|
35 | - copy('wp-tests/wp-tests-config-sample.php', 'wp-tests/wp-tests-config.php'); |
|
36 | - } |
|
37 | - |
|
38 | - $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php') |
|
39 | - ->from('youremptytestdbnamehere') |
|
40 | - ->to('test_db') |
|
41 | - ->run(); |
|
42 | - |
|
43 | - $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php') |
|
44 | - ->from('yourusernamehere') |
|
45 | - ->to('root') |
|
46 | - ->run(); |
|
47 | - |
|
48 | - $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php') |
|
49 | - ->from('yourpasswordhere') |
|
50 | - ->to('') |
|
51 | - ->run(); |
|
52 | - } |
|
10 | + function tests() |
|
11 | + { |
|
12 | + |
|
13 | + $this->taskExec('mysql -e "CREATE DATABASE IF NOT EXISTS test_db"')->run(); |
|
14 | + $this->taskExec('mysql -e "GRANT ALL ON test_db.* to \'root\'@\'%\'"')->run(); |
|
15 | + $this->taskSvnStack() |
|
16 | + ->checkout('https://develop.svn.wordpress.org/tags/4.8.3 wp-tests') |
|
17 | + ->run(); |
|
18 | + |
|
19 | + $this->setTestConfig(); |
|
20 | + $this->phpunit(); |
|
21 | + |
|
22 | + } |
|
23 | + |
|
24 | + function phpunit() |
|
25 | + { |
|
26 | + $this->taskPhpUnit('vendor/bin/phpunit') |
|
27 | + ->configFile('tests/phpunit.xml.dist') |
|
28 | + ->run(); |
|
29 | + } |
|
30 | + |
|
31 | + private function setTestConfig() |
|
32 | + { |
|
33 | + |
|
34 | + if (file_exists('wp-tests/wp-tests-config-sample.php')) { |
|
35 | + copy('wp-tests/wp-tests-config-sample.php', 'wp-tests/wp-tests-config.php'); |
|
36 | + } |
|
37 | + |
|
38 | + $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php') |
|
39 | + ->from('youremptytestdbnamehere') |
|
40 | + ->to('test_db') |
|
41 | + ->run(); |
|
42 | + |
|
43 | + $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php') |
|
44 | + ->from('yourusernamehere') |
|
45 | + ->to('root') |
|
46 | + ->run(); |
|
47 | + |
|
48 | + $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php') |
|
49 | + ->from('yourpasswordhere') |
|
50 | + ->to('') |
|
51 | + ->run(); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | \ No newline at end of file |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | function tests() |
11 | 11 | { |
12 | 12 | |
13 | - $this->taskExec('mysql -e "CREATE DATABASE IF NOT EXISTS test_db"')->run(); |
|
14 | - $this->taskExec('mysql -e "GRANT ALL ON test_db.* to \'root\'@\'%\'"')->run(); |
|
13 | + $this->taskExec( 'mysql -e "CREATE DATABASE IF NOT EXISTS test_db"' )->run(); |
|
14 | + $this->taskExec( 'mysql -e "GRANT ALL ON test_db.* to \'root\'@\'%\'"' )->run(); |
|
15 | 15 | $this->taskSvnStack() |
16 | - ->checkout('https://develop.svn.wordpress.org/tags/4.8.3 wp-tests') |
|
16 | + ->checkout( 'https://develop.svn.wordpress.org/tags/4.8.3 wp-tests' ) |
|
17 | 17 | ->run(); |
18 | 18 | |
19 | 19 | $this->setTestConfig(); |
@@ -23,31 +23,31 @@ discard block |
||
23 | 23 | |
24 | 24 | function phpunit() |
25 | 25 | { |
26 | - $this->taskPhpUnit('vendor/bin/phpunit') |
|
27 | - ->configFile('tests/phpunit.xml.dist') |
|
26 | + $this->taskPhpUnit( 'vendor/bin/phpunit' ) |
|
27 | + ->configFile( 'tests/phpunit.xml.dist' ) |
|
28 | 28 | ->run(); |
29 | 29 | } |
30 | 30 | |
31 | 31 | private function setTestConfig() |
32 | 32 | { |
33 | 33 | |
34 | - if (file_exists('wp-tests/wp-tests-config-sample.php')) { |
|
35 | - copy('wp-tests/wp-tests-config-sample.php', 'wp-tests/wp-tests-config.php'); |
|
34 | + if ( file_exists( 'wp-tests/wp-tests-config-sample.php' ) ) { |
|
35 | + copy( 'wp-tests/wp-tests-config-sample.php', 'wp-tests/wp-tests-config.php' ); |
|
36 | 36 | } |
37 | 37 | |
38 | - $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php') |
|
39 | - ->from('youremptytestdbnamehere') |
|
40 | - ->to('test_db') |
|
38 | + $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php' ) |
|
39 | + ->from( 'youremptytestdbnamehere' ) |
|
40 | + ->to( 'test_db' ) |
|
41 | 41 | ->run(); |
42 | 42 | |
43 | - $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php') |
|
44 | - ->from('yourusernamehere') |
|
45 | - ->to('root') |
|
43 | + $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php' ) |
|
44 | + ->from( 'yourusernamehere' ) |
|
45 | + ->to( 'root' ) |
|
46 | 46 | ->run(); |
47 | 47 | |
48 | - $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php') |
|
49 | - ->from('yourpasswordhere') |
|
50 | - ->to('') |
|
48 | + $this->taskReplaceInFile( 'wp-tests/wp-tests-config.php' ) |
|
49 | + ->from( 'yourpasswordhere' ) |
|
50 | + ->to( '' ) |
|
51 | 51 | ->run(); |
52 | 52 | } |
53 | 53 |
@@ -20,38 +20,38 @@ discard block |
||
20 | 20 | private $_geocoder; |
21 | 21 | |
22 | 22 | public function setUp() { |
23 | - $this->_geocoder = new Geocoder(['api_key' => getenv('MAPS_API_KEY')]); |
|
23 | + $this->_geocoder = new Geocoder( ['api_key' => getenv( 'MAPS_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,25 +59,25 @@ 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->assertInternalType('string', $location->address()); |
|
66 | - $this->assertInternalType('string', $location->formatted_address()); |
|
67 | - $this->assertInternalType('double', $location->latitude()); |
|
68 | - $this->assertInternalType('double', $location->longitude()); |
|
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->assertInternalType('double', $location->viewport()['northeast']['lat']); |
|
76 | - $this->assertInternalType('double', $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->assertInternalType('double', $location->viewport()['southwest']['lat']); |
|
81 | - $this->assertInternalType('double', $location->viewport()['southwest']['lng']); |
|
64 | + $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location ); |
|
65 | + $this->assertInternalType( 'string', $location->address() ); |
|
66 | + $this->assertInternalType( 'string', $location->formatted_address() ); |
|
67 | + $this->assertInternalType( 'double', $location->latitude() ); |
|
68 | + $this->assertInternalType( 'double', $location->longitude() ); |
|
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->assertInternalType( 'double', $location->viewport()['northeast']['lat'] ); |
|
76 | + $this->assertInternalType( 'double', $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->assertInternalType( 'double', $location->viewport()['southwest']['lat'] ); |
|
81 | + $this->assertInternalType( 'double', $location->viewport()['southwest']['lng'] ); |
|
82 | 82 | } |
83 | 83 | } |
@@ -118,16 +118,16 @@ |
||
118 | 118 | |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * @return array |
|
123 | - */ |
|
124 | - function make_args() { |
|
121 | + /** |
|
122 | + * @return array |
|
123 | + */ |
|
124 | + function make_args() { |
|
125 | 125 | |
126 | - return array( |
|
127 | - 'center' => $this->center(), |
|
128 | - 'zoom' => (int)$this->zoom() |
|
129 | - ); |
|
126 | + return array( |
|
127 | + 'center' => $this->center(), |
|
128 | + 'zoom' => (int)$this->zoom() |
|
129 | + ); |
|
130 | 130 | |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | 133 | } |
@@ -83,7 +83,7 @@ discard block |
||
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 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | return array( |
127 | 127 | 'center' => $this->center(), |
128 | - 'zoom' => (int)$this->zoom() |
|
128 | + 'zoom' => ( int ) $this->zoom() |
|
129 | 129 | ); |
130 | 130 | |
131 | 131 | } |
@@ -81,22 +81,22 @@ |
||
81 | 81 | $this->assertEquals(12, $this->_model->zoom()); |
82 | 82 | } |
83 | 83 | |
84 | - /** |
|
85 | - * @covers ::make_args |
|
86 | - */ |
|
84 | + /** |
|
85 | + * @covers ::make_args |
|
86 | + */ |
|
87 | 87 | public function testMakeArgs() { |
88 | 88 | |
89 | - $args = $this->_model->make_args(); |
|
90 | - |
|
91 | - $this->assertInternalType('array', $args); |
|
92 | - $this->assertArrayHasKey('center', $args); |
|
93 | - $this->assertArrayHasKey('zoom', $args); |
|
94 | - $this->assertInternalType('array', $args['center']); |
|
95 | - $this->assertInternalType('integer', $args['zoom']); |
|
96 | - $this->assertArrayHasKey('lat', $args['center']); |
|
97 | - $this->assertArrayHasKey('lat', $args['center']); |
|
98 | - $this->assertInternalType('float', $args['center']['lat']); |
|
99 | - $this->assertInternalType('float', $args['center']['lng']); |
|
89 | + $args = $this->_model->make_args(); |
|
90 | + |
|
91 | + $this->assertInternalType('array', $args); |
|
92 | + $this->assertArrayHasKey('center', $args); |
|
93 | + $this->assertArrayHasKey('zoom', $args); |
|
94 | + $this->assertInternalType('array', $args['center']); |
|
95 | + $this->assertInternalType('integer', $args['zoom']); |
|
96 | + $this->assertArrayHasKey('lat', $args['center']); |
|
97 | + $this->assertArrayHasKey('lat', $args['center']); |
|
98 | + $this->assertInternalType('float', $args['center']['lat']); |
|
99 | + $this->assertInternalType('float', $args['center']['lng']); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | } |
@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,7 +78,7 @@ discard block |
||
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 | |
84 | 84 | /** |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | |
89 | 89 | $args = $this->_model->make_args(); |
90 | 90 | |
91 | - $this->assertInternalType('array', $args); |
|
92 | - $this->assertArrayHasKey('center', $args); |
|
93 | - $this->assertArrayHasKey('zoom', $args); |
|
94 | - $this->assertInternalType('array', $args['center']); |
|
95 | - $this->assertInternalType('integer', $args['zoom']); |
|
96 | - $this->assertArrayHasKey('lat', $args['center']); |
|
97 | - $this->assertArrayHasKey('lat', $args['center']); |
|
98 | - $this->assertInternalType('float', $args['center']['lat']); |
|
99 | - $this->assertInternalType('float', $args['center']['lng']); |
|
91 | + $this->assertInternalType( 'array', $args ); |
|
92 | + $this->assertArrayHasKey( 'center', $args ); |
|
93 | + $this->assertArrayHasKey( 'zoom', $args ); |
|
94 | + $this->assertInternalType( 'array', $args['center'] ); |
|
95 | + $this->assertInternalType( 'integer', $args['zoom'] ); |
|
96 | + $this->assertArrayHasKey( 'lat', $args['center'] ); |
|
97 | + $this->assertArrayHasKey( 'lat', $args['center'] ); |
|
98 | + $this->assertInternalType( 'float', $args['center']['lat'] ); |
|
99 | + $this->assertInternalType( 'float', $args['center']['lng'] ); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | } |
@@ -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 |