Completed
Push — master ( f2bf98...37a392 )
by Mike
09:43 queued 04:46
created
unit-tests/Tests/Version2/system-status.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 		wp_set_current_user( $this->user );
77 77
 		$response    = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) );
78 78
 		$data        = $response->get_data();
79
-		$environment = (array) $data['environment'];
79
+		$environment = (array) $data[ 'environment' ];
80 80
 
81 81
 		// Make sure all expected data is present.
82 82
 		$this->assertEquals( 32, count( $environment ) );
83 83
 
84 84
 		// Test some responses to make sure they match up.
85
-		$this->assertEquals( get_option( 'home' ), $environment['home_url'] );
86
-		$this->assertEquals( get_option( 'siteurl' ), $environment['site_url'] );
87
-		$this->assertEquals( WC()->version, $environment['version'] );
85
+		$this->assertEquals( get_option( 'home' ), $environment[ 'home_url' ] );
86
+		$this->assertEquals( get_option( 'siteurl' ), $environment[ 'site_url' ] );
87
+		$this->assertEquals( WC()->version, $environment[ 'version' ] );
88 88
 	}
89 89
 
90 90
 	/**
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 		wp_set_current_user( $this->user );
98 98
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) );
99 99
 		$data     = $response->get_data();
100
-		$database = (array) $data['database'];
100
+		$database = (array) $data[ 'database' ];
101 101
 
102
-		$this->assertEquals( get_option( 'woocommerce_db_version' ), $database['wc_database_version'] );
103
-		$this->assertEquals( $wpdb->prefix, $database['database_prefix'] );
104
-		$this->assertEquals( WC_Geolocation::get_local_database_path(), $database['maxmind_geoip_database'] );
105
-		$this->assertArrayHasKey( 'woocommerce', $database['database_tables'], print_r( $database, true ) );
106
-		$this->assertArrayHasKey( $wpdb->prefix . 'woocommerce_payment_tokens', $database['database_tables']['woocommerce'], print_r( $database, true ) );
102
+		$this->assertEquals( get_option( 'woocommerce_db_version' ), $database[ 'wc_database_version' ] );
103
+		$this->assertEquals( $wpdb->prefix, $database[ 'database_prefix' ] );
104
+		$this->assertEquals( WC_Geolocation::get_local_database_path(), $database[ 'maxmind_geoip_database' ] );
105
+		$this->assertArrayHasKey( 'woocommerce', $database[ 'database_tables' ], print_r( $database, true ) );
106
+		$this->assertArrayHasKey( $wpdb->prefix . 'woocommerce_payment_tokens', $database[ 'database_tables' ][ 'woocommerce' ], print_r( $database, true ) );
107 107
 	}
108 108
 
109 109
 	/**
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 		update_option( 'active_plugins', array() );
121 121
 
122 122
 		$data    = $response->get_data();
123
-		$plugins = (array) $data['active_plugins'];
123
+		$plugins = (array) $data[ 'active_plugins' ];
124 124
 
125 125
 		$this->assertEquals( 1, count( $plugins ) );
126
-		$this->assertEquals( 'Hello Dolly', $plugins[0]['name'] );
126
+		$this->assertEquals( 'Hello Dolly', $plugins[ 0 ][ 'name' ] );
127 127
 	}
128 128
 
129 129
 	/**
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 
138 138
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) );
139 139
 		$data     = $response->get_data();
140
-		$theme    = (array) $data['theme'];
140
+		$theme    = (array) $data[ 'theme' ];
141 141
 
142 142
 		$this->assertEquals( 13, count( $theme ) );
143
-		$this->assertEquals( $active_theme->Name, $theme['name'] ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
143
+		$this->assertEquals( $active_theme->Name, $theme[ 'name' ] ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
144 144
 	}
145 145
 
146 146
 	/**
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 
160 160
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) );
161 161
 		$data     = $response->get_data();
162
-		$settings = (array) $data['settings'];
162
+		$settings = (array) $data[ 'settings' ];
163 163
 
164 164
 		$this->assertEquals( 12, count( $settings ) );
165
-		$this->assertEquals( ( 'yes' === get_option( 'woocommerce_api_enabled' ) ), $settings['api_enabled'] );
166
-		$this->assertEquals( get_woocommerce_currency(), $settings['currency'] );
167
-		$this->assertEquals( $term_response, $settings['taxonomies'] );
165
+		$this->assertEquals( ( 'yes' === get_option( 'woocommerce_api_enabled' ) ), $settings[ 'api_enabled' ] );
166
+		$this->assertEquals( get_woocommerce_currency(), $settings[ 'currency' ] );
167
+		$this->assertEquals( $term_response, $settings[ 'taxonomies' ] );
168 168
 	}
169 169
 
170 170
 	/**
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 
178 178
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) );
179 179
 		$data     = $response->get_data();
180
-		$settings = (array) $data['security'];
180
+		$settings = (array) $data[ 'security' ];
181 181
 
182 182
 		$this->assertEquals( 2, count( $settings ) );
183
-		$this->assertEquals( 'https' === substr( wc_get_page_permalink( 'shop' ), 0, 5 ), $settings['secure_connection'] );
184
-		$this->assertEquals( ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), $settings['hide_errors'] );
183
+		$this->assertEquals( 'https' === substr( wc_get_page_permalink( 'shop' ), 0, 5 ), $settings[ 'secure_connection' ] );
184
+		$this->assertEquals( ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), $settings[ 'hide_errors' ] );
185 185
 	}
186 186
 
187 187
 	/**
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		wp_set_current_user( $this->user );
194 194
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) );
195 195
 		$data     = $response->get_data();
196
-		$pages    = $data['pages'];
196
+		$pages    = $data[ 'pages' ];
197 197
 		$this->assertEquals( 5, count( $pages ) );
198 198
 	}
199 199
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v2/system_status' );
207 207
 		$response   = $this->server->dispatch( $request );
208 208
 		$data       = $response->get_data();
209
-		$properties = $data['schema']['properties'];
209
+		$properties = $data[ 'schema' ][ 'properties' ];
210 210
 		$this->assertEquals( 9, count( $properties ) );
211 211
 		$this->assertArrayHasKey( 'environment', $properties );
212 212
 		$this->assertArrayHasKey( 'database', $properties );
@@ -273,17 +273,17 @@  discard block
 block discarded – undo
273 273
 
274 274
 		$tools_controller = new WC_REST_System_Status_Tools_Controller();
275 275
 		$raw_tools        = $tools_controller->get_tools();
276
-		$raw_tool         = $raw_tools['recount_terms'];
276
+		$raw_tool         = $raw_tools[ 'recount_terms' ];
277 277
 
278 278
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status/tools/recount_terms' ) );
279 279
 		$data     = $response->get_data();
280 280
 
281 281
 		$this->assertEquals( 200, $response->get_status() );
282 282
 
283
-		$this->assertEquals( 'recount_terms', $data['id'] );
284
-		$this->assertEquals( 'Term counts', $data['name'] );
285
-		$this->assertEquals( 'Recount terms', $data['action'] );
286
-		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data['description'] );
283
+		$this->assertEquals( 'recount_terms', $data[ 'id' ] );
284
+		$this->assertEquals( 'Term counts', $data[ 'name' ] );
285
+		$this->assertEquals( 'Recount terms', $data[ 'action' ] );
286
+		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data[ 'description' ] );
287 287
 	}
288 288
 
289 289
 	/**
@@ -307,16 +307,16 @@  discard block
 block discarded – undo
307 307
 
308 308
 		$tools_controller = new WC_REST_System_Status_Tools_Controller();
309 309
 		$raw_tools        = $tools_controller->get_tools();
310
-		$raw_tool         = $raw_tools['recount_terms'];
310
+		$raw_tool         = $raw_tools[ 'recount_terms' ];
311 311
 
312 312
 		$response = $this->server->dispatch( new WP_REST_Request( 'POST', '/wc/v2/system_status/tools/recount_terms' ) );
313 313
 		$data     = $response->get_data();
314 314
 
315
-		$this->assertEquals( 'recount_terms', $data['id'] );
316
-		$this->assertEquals( 'Term counts', $data['name'] );
317
-		$this->assertEquals( 'Recount terms', $data['action'] );
318
-		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data['description'] );
319
-		$this->assertTrue( $data['success'] );
315
+		$this->assertEquals( 'recount_terms', $data[ 'id' ] );
316
+		$this->assertEquals( 'Term counts', $data[ 'name' ] );
317
+		$this->assertEquals( 'Recount terms', $data[ 'action' ] );
318
+		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data[ 'description' ] );
319
+		$this->assertTrue( $data[ 'success' ] );
320 320
 		$this->assertEquals( 1, did_action( 'woocommerce_rest_insert_system_status_tool' ) );
321 321
 
322 322
 		$response = $this->server->dispatch( new WP_REST_Request( 'POST', '/wc/v2/system_status/tools/not_a_real_tool' ) );
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v2/system_status/tools' );
344 344
 		$response   = $this->server->dispatch( $request );
345 345
 		$data       = $response->get_data();
346
-		$properties = $data['schema']['properties'];
346
+		$properties = $data[ 'schema' ][ 'properties' ];
347 347
 
348 348
 		$this->assertEquals( 6, count( $properties ) );
349 349
 		$this->assertArrayHasKey( 'id', $properties );
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/SystemStatus.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 	public function test_get_system_status_info_environment() {
100 100
 		$response    = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/system_status' ) );
101 101
 		$data        = $response->get_data();
102
-		$environment = (array) $data['environment'];
102
+		$environment = (array) $data[ 'environment' ];
103 103
 
104 104
 		// Make sure all expected data is present.
105 105
 		$this->assertEquals( 32, count( $environment ) );
106 106
 
107 107
 		// Test some responses to make sure they match up.
108
-		$this->assertEquals( get_option( 'home' ), $environment['home_url'] );
109
-		$this->assertEquals( get_option( 'siteurl' ), $environment['site_url'] );
110
-		$this->assertEquals( WC()->version, $environment['version'] );
108
+		$this->assertEquals( get_option( 'home' ), $environment[ 'home_url' ] );
109
+		$this->assertEquals( get_option( 'siteurl' ), $environment[ 'site_url' ] );
110
+		$this->assertEquals( WC()->version, $environment[ 'version' ] );
111 111
 	}
112 112
 
113 113
 	/**
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 		global $wpdb;
120 120
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/system_status' ) );
121 121
 		$data     = $response->get_data();
122
-		$database = (array) $data['database'];
122
+		$database = (array) $data[ 'database' ];
123 123
 
124
-		$this->assertEquals( get_option( 'woocommerce_db_version' ), $database['wc_database_version'] );
125
-		$this->assertEquals( $wpdb->prefix, $database['database_prefix'] );
126
-		$this->assertEquals( \WC_Geolocation::get_local_database_path(), $database['maxmind_geoip_database'] );
127
-		$this->assertArrayHasKey( 'woocommerce', $database['database_tables'], wc_print_r( $database, true ) );
128
-		$this->assertArrayHasKey( $wpdb->prefix . 'woocommerce_payment_tokens', $database['database_tables']['woocommerce'], wc_print_r( $database, true ) );
124
+		$this->assertEquals( get_option( 'woocommerce_db_version' ), $database[ 'wc_database_version' ] );
125
+		$this->assertEquals( $wpdb->prefix, $database[ 'database_prefix' ] );
126
+		$this->assertEquals( \WC_Geolocation::get_local_database_path(), $database[ 'maxmind_geoip_database' ] );
127
+		$this->assertArrayHasKey( 'woocommerce', $database[ 'database_tables' ], wc_print_r( $database, true ) );
128
+		$this->assertArrayHasKey( $wpdb->prefix . 'woocommerce_payment_tokens', $database[ 'database_tables' ][ 'woocommerce' ], wc_print_r( $database, true ) );
129 129
 	}
130 130
 
131 131
 	/**
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 		update_option( 'active_plugins', array() );
141 141
 
142 142
 		$data    = $response->get_data();
143
-		$plugins = (array) $data['active_plugins'];
143
+		$plugins = (array) $data[ 'active_plugins' ];
144 144
 
145 145
 		$this->assertEquals( 1, count( $plugins ) );
146
-		$this->assertEquals( 'Hello Dolly', $plugins[0]['name'] );
146
+		$this->assertEquals( 'Hello Dolly', $plugins[ 0 ][ 'name' ] );
147 147
 	}
148 148
 
149 149
 	/**
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
 
157 157
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/system_status' ) );
158 158
 		$data     = $response->get_data();
159
-		$theme    = (array) $data['theme'];
159
+		$theme    = (array) $data[ 'theme' ];
160 160
 
161 161
 		$this->assertEquals( 13, count( $theme ) );
162
-		$this->assertEquals( $active_theme->Name, $theme['name'] ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
162
+		$this->assertEquals( $active_theme->Name, $theme[ 'name' ] ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
163 163
 	}
164 164
 
165 165
 	/**
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
 
177 177
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/system_status' ) );
178 178
 		$data     = $response->get_data();
179
-		$settings = (array) $data['settings'];
179
+		$settings = (array) $data[ 'settings' ];
180 180
 
181 181
 		$this->assertEquals( 12, count( $settings ) );
182
-		$this->assertEquals( ( 'yes' === get_option( 'woocommerce_api_enabled' ) ), $settings['api_enabled'] );
183
-		$this->assertEquals( get_woocommerce_currency(), $settings['currency'] );
184
-		$this->assertEquals( $term_response, $settings['taxonomies'] );
182
+		$this->assertEquals( ( 'yes' === get_option( 'woocommerce_api_enabled' ) ), $settings[ 'api_enabled' ] );
183
+		$this->assertEquals( get_woocommerce_currency(), $settings[ 'currency' ] );
184
+		$this->assertEquals( $term_response, $settings[ 'taxonomies' ] );
185 185
 	}
186 186
 
187 187
 	/**
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 	public function test_get_system_status_info_security() {
193 193
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/system_status' ) );
194 194
 		$data     = $response->get_data();
195
-		$settings = (array) $data['security'];
195
+		$settings = (array) $data[ 'security' ];
196 196
 
197 197
 		$this->assertEquals( 2, count( $settings ) );
198
-		$this->assertEquals( 'https' === substr( wc_get_page_permalink( 'shop' ), 0, 5 ), $settings['secure_connection'] );
199
-		$this->assertEquals( ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), $settings['hide_errors'] );
198
+		$this->assertEquals( 'https' === substr( wc_get_page_permalink( 'shop' ), 0, 5 ), $settings[ 'secure_connection' ] );
199
+		$this->assertEquals( ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), $settings[ 'hide_errors' ] );
200 200
 	}
201 201
 
202 202
 	/**
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	public function test_get_system_status_info_pages() {
208 208
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/system_status' ) );
209 209
 		$data     = $response->get_data();
210
-		$pages    = $data['pages'];
210
+		$pages    = $data[ 'pages' ];
211 211
 		$this->assertEquals( 5, count( $pages ) );
212 212
 	}
213 213
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/system_status' );
221 221
 		$response   = $this->server->dispatch( $request );
222 222
 		$data       = $response->get_data();
223
-		$properties = $data['schema']['properties'];
223
+		$properties = $data[ 'schema' ][ 'properties' ];
224 224
 		$this->assertEquals( 10, count( $properties ) );
225 225
 		$this->assertArrayHasKey( 'environment', $properties );
226 226
 		$this->assertArrayHasKey( 'database', $properties );
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
 
313 313
 		$this->assertEquals( 200, $response->get_status() );
314 314
 
315
-		$this->assertEquals( 'recount_terms', $data['id'] );
316
-		$this->assertEquals( 'Term counts', $data['name'] );
317
-		$this->assertEquals( 'Recount terms', $data['action'] );
318
-		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data['description'] );
315
+		$this->assertEquals( 'recount_terms', $data[ 'id' ] );
316
+		$this->assertEquals( 'Term counts', $data[ 'name' ] );
317
+		$this->assertEquals( 'Recount terms', $data[ 'action' ] );
318
+		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data[ 'description' ] );
319 319
 
320 320
 		// Test for _fields query parameter.
321 321
 		$query_params = array(
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 
329 329
 		$this->assertEquals( 200, $response->get_status() );
330 330
 
331
-		$this->assertEquals( 'recount_terms', $data['id'] );
332
-		$this->assertEquals( 'Term counts', $data['name'] );
331
+		$this->assertEquals( 'recount_terms', $data[ 'id' ] );
332
+		$this->assertEquals( 'Term counts', $data[ 'name' ] );
333 333
 		$this->assertArrayNotHasKey( 'action', $data );
334 334
 		$this->assertArrayNotHasKey( 'description', $data );
335 335
 		// Links are part of links, not data in single items.
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 		$response = $this->server->dispatch( new WP_REST_Request( 'POST', '/wc/v4/system_status/tools/recount_terms' ) );
361 361
 		$data     = $response->get_data();
362 362
 
363
-		$this->assertEquals( 'recount_terms', $data['id'] );
364
-		$this->assertEquals( 'Term counts', $data['name'] );
365
-		$this->assertEquals( 'Recount terms', $data['action'] );
366
-		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data['description'] );
367
-		$this->assertTrue( $data['success'] );
363
+		$this->assertEquals( 'recount_terms', $data[ 'id' ] );
364
+		$this->assertEquals( 'Term counts', $data[ 'name' ] );
365
+		$this->assertEquals( 'Recount terms', $data[ 'action' ] );
366
+		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data[ 'description' ] );
367
+		$this->assertTrue( $data[ 'success' ] );
368 368
 		$this->assertEquals( 1, did_action( 'woocommerce_rest_insert_system_status_tool' ) );
369 369
 
370 370
 		$response = $this->server->dispatch( new WP_REST_Request( 'POST', '/wc/v4/system_status/tools/not_a_real_tool' ) );
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 		$data     = $response->get_data();
381 381
 
382 382
 		$this->assertEquals( 200, $response->get_status() );
383
-		$this->assertEquals( 'recount_terms', $data['id'] );
384
-		$this->assertTrue( $data['success'] );
383
+		$this->assertEquals( 'recount_terms', $data[ 'id' ] );
384
+		$this->assertTrue( $data[ 'success' ] );
385 385
 
386 386
 		// Fields that are not requested are not returned in response.
387 387
 		$this->assertArrayNotHasKey( 'action', $data );
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/system_status/tools' );
418 418
 		$response   = $this->server->dispatch( $request );
419 419
 		$data       = $response->get_data();
420
-		$properties = $data['schema']['properties'];
420
+		$properties = $data[ 'schema' ][ 'properties' ];
421 421
 
422 422
 		$this->assertEquals( 6, count( $properties ) );
423 423
 		$this->assertArrayHasKey( 'id', $properties );
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/Coupons.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
 			$this->assertArrayHasKey( $property, $response->data );
159 159
 		}
160 160
 
161
-		$this->assertEquals( $coupon->get_id(), $response->data['id'] );
162
-		$this->assertEquals( 'new-code', $response->data['code'] );
163
-		$this->assertEquals( 'new description', $response->data['description'] );
161
+		$this->assertEquals( $coupon->get_id(), $response->data[ 'id' ] );
162
+		$this->assertEquals( 'new-code', $response->data[ 'code' ] );
163
+		$this->assertEquals( 'new description', $response->data[ 'description' ] );
164 164
 	}
165 165
 
166 166
 	/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		);
273 273
 
274 274
 		$this->assertEquals( 400, $result->status );
275
-		$this->assertEquals( 'Invalid parameter(s): discount_type', $result->data['message'] );
275
+		$this->assertEquals( 'Invalid parameter(s): discount_type', $result->data[ 'message' ] );
276 276
 	}
277 277
 
278 278
 	/**
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
 			)
308 308
 		);
309 309
 
310
-		$this->assertEquals( '5.15', $result->data['update'][0]['amount'] );
311
-		$this->assertEquals( '11.00', $result->data['create'][0]['amount'] );
312
-		$this->assertEquals( 'new-coupon', $result->data['create'][0]['code'] );
313
-		$this->assertEquals( $coupon_2->get_id(), $result->data['delete'][0]['previous']['id'] );
314
-		$this->assertEquals( $coupon_3->get_id(), $result->data['delete'][1]['previous']['id'] );
310
+		$this->assertEquals( '5.15', $result->data[ 'update' ][ 0 ][ 'amount' ] );
311
+		$this->assertEquals( '11.00', $result->data[ 'create' ][ 0 ][ 'amount' ] );
312
+		$this->assertEquals( 'new-coupon', $result->data[ 'create' ][ 0 ][ 'code' ] );
313
+		$this->assertEquals( $coupon_2->get_id(), $result->data[ 'delete' ][ 0 ][ 'previous' ][ 'id' ] );
314
+		$this->assertEquals( $coupon_3->get_id(), $result->data[ 'delete' ][ 1 ][ 'previous' ][ 'id' ] );
315 315
 
316 316
 		$result = $this->do_request( '/wc/v4/coupons' );
317 317
 		$this->assertEquals( 3, count( $result->data ) );
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/Customers.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 		$this->assertEquals( 201, $response->get_status() );
245 245
 		$this->assertEquals(
246 246
 			array(
247
-				'id'                 => $data['id'],
248
-				'date_created'       => $data['date_created'],
249
-				'date_created_gmt'   => $data['date_created_gmt'],
250
-				'date_modified'      => $data['date_modified'],
251
-				'date_modified_gmt'  => $data['date_modified_gmt'],
247
+				'id'                 => $data[ 'id' ],
248
+				'date_created'       => $data[ 'date_created' ],
249
+				'date_created_gmt'   => $data[ 'date_created_gmt' ],
250
+				'date_modified'      => $data[ 'date_modified' ],
251
+				'date_modified_gmt'  => $data[ 'date_modified_gmt' ],
252 252
 				'email'              => '[email protected]',
253 253
 				'first_name'         => '',
254 254
 				'last_name'          => '',
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 				),
281 281
 				'is_paying_customer' => false,
282 282
 				'meta_data'          => array(),
283
-				'avatar_url'         => $data['avatar_url'],
283
+				'avatar_url'         => $data[ 'avatar_url' ],
284 284
 			),
285 285
 			$data
286 286
 		);
@@ -310,11 +310,11 @@  discard block
 block discarded – undo
310 310
 		$this->assertEquals( 201, $response->get_status() );
311 311
 		$this->assertEquals(
312 312
 			array(
313
-				'id'                 => $data['id'],
314
-				'date_created'       => $data['date_created'],
315
-				'date_created_gmt'   => $data['date_created_gmt'],
316
-				'date_modified'      => $data['date_modified'],
317
-				'date_modified_gmt'  => $data['date_modified_gmt'],
313
+				'id'                 => $data[ 'id' ],
314
+				'date_created'       => $data[ 'date_created' ],
315
+				'date_created_gmt'   => $data[ 'date_created_gmt' ],
316
+				'date_modified'      => $data[ 'date_modified' ],
317
+				'date_modified_gmt'  => $data[ 'date_modified_gmt' ],
318 318
 				'email'              => '[email protected]',
319 319
 				'first_name'         => 'Test',
320 320
 				'last_name'          => 'McTestFace',
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 				),
347 347
 				'is_paying_customer' => false,
348 348
 				'meta_data'          => array(),
349
-				'avatar_url'         => $data['avatar_url'],
349
+				'avatar_url'         => $data[ 'avatar_url' ],
350 350
 			),
351 351
 			$data
352 352
 		);
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 
398 398
 		$this->assertEquals(
399 399
 			array(
400
-				'id'                 => $data['id'],
401
-				'date_created'       => $data['date_created'],
402
-				'date_created_gmt'   => $data['date_created_gmt'],
403
-				'date_modified'      => $data['date_modified'],
404
-				'date_modified_gmt'  => $data['date_modified_gmt'],
400
+				'id'                 => $data[ 'id' ],
401
+				'date_created'       => $data[ 'date_created' ],
402
+				'date_created_gmt'   => $data[ 'date_created_gmt' ],
403
+				'date_modified'      => $data[ 'date_modified' ],
404
+				'date_modified_gmt'  => $data[ 'date_modified_gmt' ],
405 405
 				'email'              => '[email protected]',
406 406
 				'first_name'         => 'Justin',
407 407
 				'billing'            => array(
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 				'last_name'          => '',
434 434
 				'role'               => 'customer',
435 435
 				'username'           => 'get_customer_test',
436
-				'avatar_url'         => $data['avatar_url'],
436
+				'avatar_url'         => $data[ 'avatar_url' ],
437 437
 			),
438 438
 			$data
439 439
 		);
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
 
472 472
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/customers/' . $customer->get_id() ) );
473 473
 		$data     = $response->get_data();
474
-		$this->assertEquals( 'update_customer_test', $data['username'] );
475
-		$this->assertEquals( '[email protected]', $data['email'] );
474
+		$this->assertEquals( 'update_customer_test', $data[ 'username' ] );
475
+		$this->assertEquals( '[email protected]', $data[ 'email' ] );
476 476
 
477 477
 		$request = new WP_REST_Request( 'PUT', '/wc/v4/customers/' . $customer->get_id() );
478 478
 		$request->set_body_params(
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 		$response = $this->server->dispatch( $request );
485 485
 		$data     = $response->get_data();
486 486
 
487
-		$this->assertEquals( '[email protected]', $data['email'] );
488
-		$this->assertEquals( 'UpdatedTest', $data['first_name'] );
487
+		$this->assertEquals( '[email protected]', $data[ 'email' ] );
488
+		$this->assertEquals( 'UpdatedTest', $data[ 'first_name' ] );
489 489
 	}
490 490
 
491 491
 	/**
@@ -586,11 +586,11 @@  discard block
 block discarded – undo
586 586
 		$response = $this->server->dispatch( $request );
587 587
 		$data     = $response->get_data();
588 588
 
589
-		$this->assertEquals( 'McTest', $data['update'][0]['last_name'] );
590
-		$this->assertEquals( 'newuser', $data['create'][0]['username'] );
591
-		$this->assertEmpty( $data['create'][0]['last_name'] );
592
-		$this->assertEquals( $customer_2->get_id(), $data['delete'][0]['id'] );
593
-		$this->assertEquals( $customer_3->get_id(), $data['delete'][1]['id'] );
589
+		$this->assertEquals( 'McTest', $data[ 'update' ][ 0 ][ 'last_name' ] );
590
+		$this->assertEquals( 'newuser', $data[ 'create' ][ 0 ][ 'username' ] );
591
+		$this->assertEmpty( $data[ 'create' ][ 0 ][ 'last_name' ] );
592
+		$this->assertEquals( $customer_2->get_id(), $data[ 'delete' ][ 0 ][ 'id' ] );
593
+		$this->assertEquals( $customer_3->get_id(), $data[ 'delete' ][ 1 ][ 'id' ] );
594 594
 
595 595
 		$request  = new WP_REST_Request( 'GET', '/wc/v4/customers' );
596 596
 		$response = $this->server->dispatch( $request );
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/customers' );
609 609
 		$response   = $this->server->dispatch( $request );
610 610
 		$data       = $response->get_data();
611
-		$properties = $data['schema']['properties'];
611
+		$properties = $data[ 'schema' ][ 'properties' ];
612 612
 
613 613
 		$this->assertEquals( 16, count( $properties ) );
614 614
 		$this->assertArrayHasKey( 'id', $properties );
@@ -624,26 +624,26 @@  discard block
 block discarded – undo
624 624
 		$this->assertArrayHasKey( 'password', $properties );
625 625
 		$this->assertArrayHasKey( 'avatar_url', $properties );
626 626
 		$this->assertArrayHasKey( 'billing', $properties );
627
-		$this->assertArrayHasKey( 'first_name', $properties['billing']['properties'] );
628
-		$this->assertArrayHasKey( 'last_name', $properties['billing']['properties'] );
629
-		$this->assertArrayHasKey( 'company', $properties['billing']['properties'] );
630
-		$this->assertArrayHasKey( 'address_1', $properties['billing']['properties'] );
631
-		$this->assertArrayHasKey( 'address_2', $properties['billing']['properties'] );
632
-		$this->assertArrayHasKey( 'city', $properties['billing']['properties'] );
633
-		$this->assertArrayHasKey( 'state', $properties['billing']['properties'] );
634
-		$this->assertArrayHasKey( 'postcode', $properties['billing']['properties'] );
635
-		$this->assertArrayHasKey( 'country', $properties['billing']['properties'] );
636
-		$this->assertArrayHasKey( 'email', $properties['billing']['properties'] );
637
-		$this->assertArrayHasKey( 'phone', $properties['billing']['properties'] );
627
+		$this->assertArrayHasKey( 'first_name', $properties[ 'billing' ][ 'properties' ] );
628
+		$this->assertArrayHasKey( 'last_name', $properties[ 'billing' ][ 'properties' ] );
629
+		$this->assertArrayHasKey( 'company', $properties[ 'billing' ][ 'properties' ] );
630
+		$this->assertArrayHasKey( 'address_1', $properties[ 'billing' ][ 'properties' ] );
631
+		$this->assertArrayHasKey( 'address_2', $properties[ 'billing' ][ 'properties' ] );
632
+		$this->assertArrayHasKey( 'city', $properties[ 'billing' ][ 'properties' ] );
633
+		$this->assertArrayHasKey( 'state', $properties[ 'billing' ][ 'properties' ] );
634
+		$this->assertArrayHasKey( 'postcode', $properties[ 'billing' ][ 'properties' ] );
635
+		$this->assertArrayHasKey( 'country', $properties[ 'billing' ][ 'properties' ] );
636
+		$this->assertArrayHasKey( 'email', $properties[ 'billing' ][ 'properties' ] );
637
+		$this->assertArrayHasKey( 'phone', $properties[ 'billing' ][ 'properties' ] );
638 638
 		$this->assertArrayHasKey( 'shipping', $properties );
639
-		$this->assertArrayHasKey( 'first_name', $properties['shipping']['properties'] );
640
-		$this->assertArrayHasKey( 'last_name', $properties['shipping']['properties'] );
641
-		$this->assertArrayHasKey( 'company', $properties['shipping']['properties'] );
642
-		$this->assertArrayHasKey( 'address_1', $properties['shipping']['properties'] );
643
-		$this->assertArrayHasKey( 'address_2', $properties['shipping']['properties'] );
644
-		$this->assertArrayHasKey( 'city', $properties['shipping']['properties'] );
645
-		$this->assertArrayHasKey( 'state', $properties['shipping']['properties'] );
646
-		$this->assertArrayHasKey( 'postcode', $properties['shipping']['properties'] );
647
-		$this->assertArrayHasKey( 'country', $properties['shipping']['properties'] );
639
+		$this->assertArrayHasKey( 'first_name', $properties[ 'shipping' ][ 'properties' ] );
640
+		$this->assertArrayHasKey( 'last_name', $properties[ 'shipping' ][ 'properties' ] );
641
+		$this->assertArrayHasKey( 'company', $properties[ 'shipping' ][ 'properties' ] );
642
+		$this->assertArrayHasKey( 'address_1', $properties[ 'shipping' ][ 'properties' ] );
643
+		$this->assertArrayHasKey( 'address_2', $properties[ 'shipping' ][ 'properties' ] );
644
+		$this->assertArrayHasKey( 'city', $properties[ 'shipping' ][ 'properties' ] );
645
+		$this->assertArrayHasKey( 'state', $properties[ 'shipping' ][ 'properties' ] );
646
+		$this->assertArrayHasKey( 'postcode', $properties[ 'shipping' ][ 'properties' ] );
647
+		$this->assertArrayHasKey( 'country', $properties[ 'shipping' ][ 'properties' ] );
648 648
 	}
649 649
 }
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/ShippingZones.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		$zone->set_locations( $locations );
65 65
 		$zone->save();
66 66
 
67
-		$this->zones[] = $zone;
67
+		$this->zones[ ] = $zone;
68 68
 
69 69
 		return $zone;
70 70
 	}
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 		$this->assertEquals( count( $data ), 1 );
98 98
 		$this->assertContains(
99 99
 			array(
100
-				'id'     => $data[0]['id'],
100
+				'id'     => $data[ 0 ][ 'id' ],
101 101
 				'name'   => 'Locations not covered by your other zones',
102 102
 				'order'  => 0,
103 103
 				'_links' => array(
104 104
 					'self'        => array(
105 105
 						array(
106
-							'href' => rest_url( '/wc/v4/shipping/zones/' . $data[0]['id'] ),
106
+							'href' => rest_url( '/wc/v4/shipping/zones/' . $data[ 0 ][ 'id' ] ),
107 107
 						),
108 108
 					),
109 109
 					'collection'  => array(
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 					),
114 114
 					'describedby' => array(
115 115
 						array(
116
-							'href' => rest_url( '/wc/v4/shipping/zones/' . $data[0]['id'] . '/locations' ),
116
+							'href' => rest_url( '/wc/v4/shipping/zones/' . $data[ 0 ][ 'id' ] . '/locations' ),
117 117
 						),
118 118
 					),
119 119
 				),
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 		$this->assertEquals( count( $data ), 2 );
132 132
 		$this->assertContains(
133 133
 			array(
134
-				'id'     => $data[1]['id'],
134
+				'id'     => $data[ 1 ][ 'id' ],
135 135
 				'name'   => 'Zone 1',
136 136
 				'order'  => 0,
137 137
 				'_links' => array(
138 138
 					'self'        => array(
139 139
 						array(
140
-							'href' => rest_url( '/wc/v4/shipping/zones/' . $data[1]['id'] ),
140
+							'href' => rest_url( '/wc/v4/shipping/zones/' . $data[ 1 ][ 'id' ] ),
141 141
 						),
142 142
 					),
143 143
 					'collection'  => array(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 					),
148 148
 					'describedby' => array(
149 149
 						array(
150
-							'href' => rest_url( '/wc/v4/shipping/zones/' . $data[1]['id'] . '/locations' ),
150
+							'href' => rest_url( '/wc/v4/shipping/zones/' . $data[ 1 ][ 'id' ] . '/locations' ),
151 151
 						),
152 152
 					),
153 153
 				),
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/shipping/zones' );
192 192
 		$response   = $this->server->dispatch( $request );
193 193
 		$data       = $response->get_data();
194
-		$properties = $data['schema']['properties'];
194
+		$properties = $data[ 'schema' ][ 'properties' ];
195 195
 		$this->assertEquals( 3, count( $properties ) );
196 196
 		$this->assertArrayHasKey( 'id', $properties );
197
-		$this->assertTrue( $properties['id']['readonly'] );
197
+		$this->assertTrue( $properties[ 'id' ][ 'readonly' ] );
198 198
 		$this->assertArrayHasKey( 'name', $properties );
199 199
 		$this->assertArrayHasKey( 'order', $properties );
200 200
 	}
@@ -218,13 +218,13 @@  discard block
 block discarded – undo
218 218
 		$this->assertEquals( 201, $response->get_status() );
219 219
 		$this->assertEquals(
220 220
 			array(
221
-				'id'     => $data['id'],
221
+				'id'     => $data[ 'id' ],
222 222
 				'name'   => 'Test Zone',
223 223
 				'order'  => 1,
224 224
 				'_links' => array(
225 225
 					'self'        => array(
226 226
 						array(
227
-							'href' => rest_url( '/wc/v4/shipping/zones/' . $data['id'] ),
227
+							'href' => rest_url( '/wc/v4/shipping/zones/' . $data[ 'id' ] ),
228 228
 						),
229 229
 					),
230 230
 					'collection'  => array(
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 					),
235 235
 					'describedby' => array(
236 236
 						array(
237
-							'href' => rest_url( '/wc/v4/shipping/zones/' . $data['id'] . '/locations' ),
237
+							'href' => rest_url( '/wc/v4/shipping/zones/' . $data[ 'id' ] . '/locations' ),
238 238
 						),
239 239
 					),
240 240
 				),
@@ -591,16 +591,16 @@  discard block
 block discarded – undo
591 591
 		foreach ( $method->get_instance_form_fields() as $id => $field ) {
592 592
 			$data = array(
593 593
 				'id'          => $id,
594
-				'label'       => $field['title'],
595
-				'description' => ( empty( $field['description'] ) ? '' : $field['description'] ),
596
-				'type'        => $field['type'],
594
+				'label'       => $field[ 'title' ],
595
+				'description' => ( empty( $field[ 'description' ] ) ? '' : $field[ 'description' ] ),
596
+				'type'        => $field[ 'type' ],
597 597
 				'value'       => $method->instance_settings[ $id ],
598
-				'default'     => ( empty( $field['default'] ) ? '' : $field['default'] ),
599
-				'tip'         => ( empty( $field['description'] ) ? '' : $field['description'] ),
600
-				'placeholder' => ( empty( $field['placeholder'] ) ? '' : $field['placeholder'] ),
598
+				'default'     => ( empty( $field[ 'default' ] ) ? '' : $field[ 'default' ] ),
599
+				'tip'         => ( empty( $field[ 'description' ] ) ? '' : $field[ 'description' ] ),
600
+				'placeholder' => ( empty( $field[ 'placeholder' ] ) ? '' : $field[ 'placeholder' ] ),
601 601
 			);
602
-			if ( ! empty( $field['options'] ) ) {
603
-				$data['options'] = $field['options'];
602
+			if ( ! empty( $field[ 'options' ] ) ) {
603
+				$data[ 'options' ] = $field[ 'options' ];
604 604
 			}
605 605
 			$settings[ $id ] = $data;
606 606
 		}
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 		$expected = array(
611 611
 			'id'                 => $instance_id,
612 612
 			'instance_id'        => $instance_id,
613
-			'title'              => $method->instance_settings['title'],
613
+			'title'              => $method->instance_settings[ 'title' ],
614 614
 			'order'              => $method->method_order,
615 615
 			'enabled'            => ( 'yes' === $method->enabled ),
616 616
 			'method_id'          => $method->id,
@@ -690,12 +690,12 @@  discard block
 block discarded – undo
690 690
 		$response = $this->server->dispatch( $request );
691 691
 		$data     = $response->get_data();
692 692
 
693
-		$this->assertArrayHasKey( 'title', $data['settings'] );
694
-		$this->assertEquals( 'Flat rate', $data['settings']['title']['value'] );
695
-		$this->assertArrayHasKey( 'tax_status', $data['settings'] );
696
-		$this->assertEquals( 'taxable', $data['settings']['tax_status']['value'] );
697
-		$this->assertArrayHasKey( 'cost', $data['settings'] );
698
-		$this->assertEquals( '0', $data['settings']['cost']['value'] );
693
+		$this->assertArrayHasKey( 'title', $data[ 'settings' ] );
694
+		$this->assertEquals( 'Flat rate', $data[ 'settings' ][ 'title' ][ 'value' ] );
695
+		$this->assertArrayHasKey( 'tax_status', $data[ 'settings' ] );
696
+		$this->assertEquals( 'taxable', $data[ 'settings' ][ 'tax_status' ][ 'value' ] );
697
+		$this->assertArrayHasKey( 'cost', $data[ 'settings' ] );
698
+		$this->assertEquals( '0', $data[ 'settings' ][ 'cost' ][ 'value' ] );
699 699
 
700 700
 		// Update a single value
701 701
 		$request = new WP_REST_Request( 'POST', '/wc/v4/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
@@ -709,12 +709,12 @@  discard block
 block discarded – undo
709 709
 		$response = $this->server->dispatch( $request );
710 710
 		$data     = $response->get_data();
711 711
 
712
-		$this->assertArrayHasKey( 'title', $data['settings'] );
713
-		$this->assertEquals( 'Flat rate', $data['settings']['title']['value'] );
714
-		$this->assertArrayHasKey( 'tax_status', $data['settings'] );
715
-		$this->assertEquals( 'taxable', $data['settings']['tax_status']['value'] );
716
-		$this->assertArrayHasKey( 'cost', $data['settings'] );
717
-		$this->assertEquals( '5', $data['settings']['cost']['value'] );
712
+		$this->assertArrayHasKey( 'title', $data[ 'settings' ] );
713
+		$this->assertEquals( 'Flat rate', $data[ 'settings' ][ 'title' ][ 'value' ] );
714
+		$this->assertArrayHasKey( 'tax_status', $data[ 'settings' ] );
715
+		$this->assertEquals( 'taxable', $data[ 'settings' ][ 'tax_status' ][ 'value' ] );
716
+		$this->assertArrayHasKey( 'cost', $data[ 'settings' ] );
717
+		$this->assertEquals( '5', $data[ 'settings' ][ 'cost' ][ 'value' ] );
718 718
 
719 719
 		// Test multiple settings
720 720
 		$request = new WP_REST_Request( 'POST', '/wc/v4/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
@@ -729,12 +729,12 @@  discard block
 block discarded – undo
729 729
 		$response = $this->server->dispatch( $request );
730 730
 		$data     = $response->get_data();
731 731
 
732
-		$this->assertArrayHasKey( 'title', $data['settings'] );
733
-		$this->assertEquals( 'Flat rate', $data['settings']['title']['value'] );
734
-		$this->assertArrayHasKey( 'tax_status', $data['settings'] );
735
-		$this->assertEquals( 'none', $data['settings']['tax_status']['value'] );
736
-		$this->assertArrayHasKey( 'cost', $data['settings'] );
737
-		$this->assertEquals( '10', $data['settings']['cost']['value'] );
732
+		$this->assertArrayHasKey( 'title', $data[ 'settings' ] );
733
+		$this->assertEquals( 'Flat rate', $data[ 'settings' ][ 'title' ][ 'value' ] );
734
+		$this->assertArrayHasKey( 'tax_status', $data[ 'settings' ] );
735
+		$this->assertEquals( 'none', $data[ 'settings' ][ 'tax_status' ][ 'value' ] );
736
+		$this->assertArrayHasKey( 'cost', $data[ 'settings' ] );
737
+		$this->assertEquals( '10', $data[ 'settings' ][ 'cost' ][ 'value' ] );
738 738
 
739 739
 		// Test bogus
740 740
 		$request = new WP_REST_Request( 'POST', '/wc/v4/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
@@ -750,8 +750,8 @@  discard block
 block discarded – undo
750 750
 		$this->assertEquals( 400, $response->get_status() );
751 751
 
752 752
 		// Test other parameters
753
-		$this->assertTrue( $data['enabled'] );
754
-		$this->assertEquals( 1, $data['order'] );
753
+		$this->assertTrue( $data[ 'enabled' ] );
754
+		$this->assertEquals( 1, $data[ 'order' ] );
755 755
 
756 756
 		$request = new WP_REST_Request( 'POST', '/wc/v4/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
757 757
 		$request->set_body_params(
@@ -763,10 +763,10 @@  discard block
 block discarded – undo
763 763
 		$response = $this->server->dispatch( $request );
764 764
 		$data     = $response->get_data();
765 765
 
766
-		$this->assertFalse( $data['enabled'] );
767
-		$this->assertEquals( 2, $data['order'] );
768
-		$this->assertArrayHasKey( 'cost', $data['settings'] );
769
-		$this->assertEquals( '10', $data['settings']['cost']['value'] );
766
+		$this->assertFalse( $data[ 'enabled' ] );
767
+		$this->assertEquals( 2, $data[ 'order' ] );
768
+		$this->assertArrayHasKey( 'cost', $data[ 'settings' ] );
769
+		$this->assertEquals( '10', $data[ 'settings' ][ 'cost' ][ 'value' ] );
770 770
 	}
771 771
 
772 772
 	/**
@@ -787,10 +787,10 @@  discard block
 block discarded – undo
787 787
 		$response = $this->server->dispatch( $request );
788 788
 		$data     = $response->get_data();
789 789
 
790
-		$this->assertFalse( $data['enabled'] );
791
-		$this->assertEquals( 2, $data['order'] );
792
-		$this->assertArrayHasKey( 'cost', $data['settings'] );
793
-		$this->assertEquals( '0', $data['settings']['cost']['value'] );
790
+		$this->assertFalse( $data[ 'enabled' ] );
791
+		$this->assertEquals( 2, $data[ 'order' ] );
792
+		$this->assertArrayHasKey( 'cost', $data[ 'settings' ] );
793
+		$this->assertEquals( '0', $data[ 'settings' ][ 'cost' ][ 'value' ] );
794 794
 	}
795 795
 
796 796
 	/**
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/PaymentGateways.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/payment_gateways/paypal' ) );
179 179
 		$paypal   = $response->get_data();
180 180
 
181
-		$this->assertEquals( 'PayPal', $paypal['settings']['title']['value'] );
182
-		$this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] );
183
-		$this->assertEquals( 'no', $paypal['settings']['testmode']['value'] );
181
+		$this->assertEquals( 'PayPal', $paypal[ 'settings' ][ 'title' ][ 'value' ] );
182
+		$this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] );
183
+		$this->assertEquals( 'no', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] );
184 184
 
185 185
 		// test updating single setting
186 186
 		$request = new WP_REST_Request( 'POST', '/wc/v4/payment_gateways/paypal' );
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 		$paypal   = $response->get_data();
196 196
 
197 197
 		$this->assertEquals( 200, $response->get_status() );
198
-		$this->assertEquals( 'PayPal', $paypal['settings']['title']['value'] );
199
-		$this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] );
200
-		$this->assertEquals( 'no', $paypal['settings']['testmode']['value'] );
198
+		$this->assertEquals( 'PayPal', $paypal[ 'settings' ][ 'title' ][ 'value' ] );
199
+		$this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] );
200
+		$this->assertEquals( 'no', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] );
201 201
 
202 202
 		// test updating multiple settings
203 203
 		$request = new WP_REST_Request( 'POST', '/wc/v4/payment_gateways/paypal' );
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 		$paypal   = $response->get_data();
214 214
 
215 215
 		$this->assertEquals( 200, $response->get_status() );
216
-		$this->assertEquals( 'PayPal - New Title', $paypal['settings']['title']['value'] );
217
-		$this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] );
218
-		$this->assertEquals( 'yes', $paypal['settings']['testmode']['value'] );
216
+		$this->assertEquals( 'PayPal - New Title', $paypal[ 'settings' ][ 'title' ][ 'value' ] );
217
+		$this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] );
218
+		$this->assertEquals( 'yes', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] );
219 219
 
220 220
 		// Test other parameters, and recheck settings
221 221
 		$request = new WP_REST_Request( 'POST', '/wc/v4/payment_gateways/paypal' );
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 		$response = $this->server->dispatch( $request );
229 229
 		$paypal   = $response->get_data();
230 230
 
231
-		$this->assertFalse( $paypal['enabled'] );
232
-		$this->assertEquals( 2, $paypal['order'] );
233
-		$this->assertEquals( 'PayPal - New Title', $paypal['settings']['title']['value'] );
234
-		$this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] );
235
-		$this->assertEquals( 'yes', $paypal['settings']['testmode']['value'] );
231
+		$this->assertFalse( $paypal[ 'enabled' ] );
232
+		$this->assertEquals( 2, $paypal[ 'order' ] );
233
+		$this->assertEquals( 'PayPal - New Title', $paypal[ 'settings' ][ 'title' ][ 'value' ] );
234
+		$this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] );
235
+		$this->assertEquals( 'yes', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] );
236 236
 
237 237
 		// test bogus
238 238
 		$request = new WP_REST_Request( 'POST', '/wc/v4/payment_gateways/paypal' );
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		);
257 257
 		$response = $this->server->dispatch( $request );
258 258
 		$paypal   = $response->get_data();
259
-		$this->assertEquals( 'authorization', $paypal['settings']['paymentaction']['value'] );
259
+		$this->assertEquals( 'authorization', $paypal[ 'settings' ][ 'paymentaction' ][ 'value' ] );
260 260
 	}
261 261
 
262 262
 	/**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/payment_gateways' );
305 305
 		$response   = $this->server->dispatch( $request );
306 306
 		$data       = $response->get_data();
307
-		$properties = $data['schema']['properties'];
307
+		$properties = $data[ 'schema' ][ 'properties' ];
308 308
 
309 309
 		$this->assertEquals( 9, count( $properties ) );
310 310
 		$this->assertArrayHasKey( 'id', $properties );
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		$gateway->init_form_fields();
331 331
 		foreach ( $gateway->form_fields as $id => $field ) {
332 332
 			// Make sure we at least have a title and type
333
-			if ( empty( $field['title'] ) || empty( $field['type'] ) ) {
333
+			if ( empty( $field[ 'title' ] ) || empty( $field[ 'type' ] ) ) {
334 334
 				continue;
335 335
 			}
336 336
 			// Ignore 'enabled' and 'description', to be in line with \WC_REST_Payment_Gateways_Controller::get_settings.
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 			}
340 340
 			$data = array(
341 341
 				'id'          => $id,
342
-				'label'       => empty( $field['label'] ) ? $field['title'] : $field['label'],
343
-				'description' => empty( $field['description'] ) ? '' : $field['description'],
344
-				'type'        => $field['type'],
342
+				'label'       => empty( $field[ 'label' ] ) ? $field[ 'title' ] : $field[ 'label' ],
343
+				'description' => empty( $field[ 'description' ] ) ? '' : $field[ 'description' ],
344
+				'type'        => $field[ 'type' ],
345 345
 				'value'       => $gateway->settings[ $id ],
346
-				'default'     => empty( $field['default'] ) ? '' : $field['default'],
347
-				'tip'         => empty( $field['description'] ) ? '' : $field['description'],
348
-				'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'],
346
+				'default'     => empty( $field[ 'default' ] ) ? '' : $field[ 'default' ],
347
+				'tip'         => empty( $field[ 'description' ] ) ? '' : $field[ 'description' ],
348
+				'placeholder' => empty( $field[ 'placeholder' ] ) ? '' : $field[ 'placeholder' ],
349 349
 			);
350
-			if ( ! empty( $field['options'] ) ) {
351
-				$data['options'] = $field['options'];
350
+			if ( ! empty( $field[ 'options' ] ) ) {
351
+				$data[ 'options' ] = $field[ 'options' ];
352 352
 			}
353 353
 			$settings[ $id ] = $data;
354 354
 		}
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/Products.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 		$this->assertEquals( 200, $response->get_status() );
75 75
 
76 76
 		$this->assertEquals( 2, count( $products ) );
77
-		$this->assertEquals( 'Dummy Product', $products[0]['name'] );
78
-		$this->assertEquals( 'DUMMY SKU', $products[0]['sku'] );
79
-		$this->assertEquals( 'Dummy External Product', $products[1]['name'] );
80
-		$this->assertEquals( 'DUMMY EXTERNAL SKU', $products[1]['sku'] );
77
+		$this->assertEquals( 'Dummy Product', $products[ 0 ][ 'name' ] );
78
+		$this->assertEquals( 'DUMMY SKU', $products[ 0 ][ 'sku' ] );
79
+		$this->assertEquals( 'Dummy External Product', $products[ 1 ][ 'name' ] );
80
+		$this->assertEquals( 'DUMMY EXTERNAL SKU', $products[ 1 ][ 'sku' ] );
81 81
 	}
82 82
 
83 83
 	/**
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
 		$data         = $response->get_data();
186 186
 		$date_created = date( 'Y-m-d\TH:i:s', current_time( 'timestamp' ) );
187 187
 
188
-		$this->assertEquals( 'DUMMY SKU', $data['sku'] );
189
-		$this->assertEquals( 10, $data['regular_price'] );
190
-		$this->assertEmpty( $data['sale_price'] );
188
+		$this->assertEquals( 'DUMMY SKU', $data[ 'sku' ] );
189
+		$this->assertEquals( 10, $data[ 'regular_price' ] );
190
+		$this->assertEmpty( $data[ 'sale_price' ] );
191 191
 
192 192
 		$request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() );
193 193
 		$request->set_body_params(
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 		$response = $this->server->dispatch( $request );
209 209
 		$data     = $response->get_data();
210 210
 
211
-		$this->assertContains( 'Testing', $data['description'] );
212
-		$this->assertEquals( '8', $data['price'] );
213
-		$this->assertEquals( '8', $data['sale_price'] );
214
-		$this->assertEquals( '10', $data['regular_price'] );
215
-		$this->assertEquals( 'FIXED-SKU', $data['sku'] );
216
-		$this->assertEquals( $date_created, $data['date_created'] );
217
-		$this->assertContains( 'Dr1Bczxq4q', $data['images'][0]['src'] );
218
-		$this->assertContains( 'test upload image', $data['images'][0]['alt'] );
211
+		$this->assertContains( 'Testing', $data[ 'description' ] );
212
+		$this->assertEquals( '8', $data[ 'price' ] );
213
+		$this->assertEquals( '8', $data[ 'sale_price' ] );
214
+		$this->assertEquals( '10', $data[ 'regular_price' ] );
215
+		$this->assertEquals( 'FIXED-SKU', $data[ 'sku' ] );
216
+		$this->assertEquals( $date_created, $data[ 'date_created' ] );
217
+		$this->assertContains( 'Dr1Bczxq4q', $data[ 'images' ][ 0 ][ 'src' ] );
218
+		$this->assertContains( 'test upload image', $data[ 'images' ][ 0 ][ 'alt' ] );
219 219
 		$product->delete( true );
220 220
 
221 221
 		// test variable product (variations are tested in product-variations.php).
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		$data     = $response->get_data();
225 225
 
226 226
 		foreach ( array( 'small', 'large' ) as $term_name ) {
227
-			$this->assertContains( $term_name, $data['attributes'][0]['options'] );
227
+			$this->assertContains( $term_name, $data[ 'attributes' ][ 0 ][ 'options' ] );
228 228
 		}
229 229
 
230 230
 		$request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() );
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 		$response = $this->server->dispatch( $request );
257 257
 		$data     = $response->get_data();
258 258
 
259
-		$this->assertEquals( array( 'small' ), $data['attributes'][0]['options'] );
259
+		$this->assertEquals( array( 'small' ), $data[ 'attributes' ][ 0 ][ 'options' ] );
260 260
 
261 261
 		foreach ( array( 'red', 'yellow' ) as $term_name ) {
262
-			$this->assertContains( $term_name, $data['attributes'][1]['options'] );
262
+			$this->assertContains( $term_name, $data[ 'attributes' ][ 1 ][ 'options' ] );
263 263
 		}
264 264
 
265 265
 		$product->delete( true );
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() ) );
270 270
 		$data     = $response->get_data();
271 271
 
272
-		$this->assertEquals( 'Buy external product', $data['button_text'] );
273
-		$this->assertEquals( 'http://woocommerce.com', $data['external_url'] );
272
+		$this->assertEquals( 'Buy external product', $data[ 'button_text' ] );
273
+		$this->assertEquals( 'http://woocommerce.com', $data[ 'external_url' ] );
274 274
 
275 275
 		$request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() );
276 276
 		$request->set_body_params(
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
 		$response = $this->server->dispatch( $request );
283 283
 		$data     = $response->get_data();
284 284
 
285
-		$this->assertEquals( 'Test API Update', $data['button_text'] );
286
-		$this->assertEquals( 'http://automattic.com', $data['external_url'] );
285
+		$this->assertEquals( 'Test API Update', $data[ 'button_text' ] );
286
+		$this->assertEquals( 'http://automattic.com', $data[ 'external_url' ] );
287 287
 	}
288 288
 
289 289
 	/**
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		);
336 336
 		$response          = $this->server->dispatch( $request );
337 337
 		$data              = $response->get_data();
338
-		$shipping_class_id = $data['id'];
338
+		$shipping_class_id = $data[ 'id' ];
339 339
 
340 340
 		// Create simple.
341 341
 		$request = new WP_REST_Request( 'POST', '/wc/v4/products' );
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
 		$response = $this->server->dispatch( $request );
352 352
 		$data     = $response->get_data();
353 353
 
354
-		$this->assertEquals( '10', $data['price'] );
355
-		$this->assertEquals( '10', $data['regular_price'] );
356
-		$this->assertTrue( $data['purchasable'] );
357
-		$this->assertEquals( 'DUMMY SKU SIMPLE API', $data['sku'] );
358
-		$this->assertEquals( 'Test Simple Product', $data['name'] );
359
-		$this->assertEquals( 'simple', $data['type'] );
360
-		$this->assertEquals( $shipping_class_id, $data['shipping_class_id'] );
354
+		$this->assertEquals( '10', $data[ 'price' ] );
355
+		$this->assertEquals( '10', $data[ 'regular_price' ] );
356
+		$this->assertTrue( $data[ 'purchasable' ] );
357
+		$this->assertEquals( 'DUMMY SKU SIMPLE API', $data[ 'sku' ] );
358
+		$this->assertEquals( 'Test Simple Product', $data[ 'name' ] );
359
+		$this->assertEquals( 'simple', $data[ 'type' ] );
360
+		$this->assertEquals( $shipping_class_id, $data[ 'shipping_class_id' ] );
361 361
 
362 362
 		// Create external.
363 363
 		$request = new WP_REST_Request( 'POST', '/wc/v4/products' );
@@ -374,14 +374,14 @@  discard block
 block discarded – undo
374 374
 		$response = $this->server->dispatch( $request );
375 375
 		$data     = $response->get_data();
376 376
 
377
-		$this->assertEquals( '10', $data['price'] );
378
-		$this->assertEquals( '10', $data['regular_price'] );
379
-		$this->assertFalse( $data['purchasable'] );
380
-		$this->assertEquals( 'DUMMY SKU EXTERNAL API', $data['sku'] );
381
-		$this->assertEquals( 'Test External Product', $data['name'] );
382
-		$this->assertEquals( 'external', $data['type'] );
383
-		$this->assertEquals( 'Test Button', $data['button_text'] );
384
-		$this->assertEquals( 'https://wordpress.org', $data['external_url'] );
377
+		$this->assertEquals( '10', $data[ 'price' ] );
378
+		$this->assertEquals( '10', $data[ 'regular_price' ] );
379
+		$this->assertFalse( $data[ 'purchasable' ] );
380
+		$this->assertEquals( 'DUMMY SKU EXTERNAL API', $data[ 'sku' ] );
381
+		$this->assertEquals( 'Test External Product', $data[ 'name' ] );
382
+		$this->assertEquals( 'external', $data[ 'type' ] );
383
+		$this->assertEquals( 'Test Button', $data[ 'button_text' ] );
384
+		$this->assertEquals( 'https://wordpress.org', $data[ 'external_url' ] );
385 385
 
386 386
 		// Create variable.
387 387
 		$request = new WP_REST_Request( 'POST', '/wc/v4/products' );
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
 		$response = $this->server->dispatch( $request );
408 408
 		$data     = $response->get_data();
409 409
 
410
-		$this->assertEquals( 'DUMMY SKU VARIABLE API', $data['sku'] );
411
-		$this->assertEquals( 'Test Variable Product', $data['name'] );
412
-		$this->assertEquals( 'variable', $data['type'] );
413
-		$this->assertEquals( array( 'small', 'medium' ), $data['attributes'][0]['options'] );
410
+		$this->assertEquals( 'DUMMY SKU VARIABLE API', $data[ 'sku' ] );
411
+		$this->assertEquals( 'Test Variable Product', $data[ 'name' ] );
412
+		$this->assertEquals( 'variable', $data[ 'type' ] );
413
+		$this->assertEquals( array( 'small', 'medium' ), $data[ 'attributes' ][ 0 ][ 'options' ] );
414 414
 
415 415
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/products' ) );
416 416
 		$products = $response->get_data();
@@ -476,13 +476,13 @@  discard block
 block discarded – undo
476 476
 		$response = $this->server->dispatch( $request );
477 477
 		$data     = $response->get_data();
478 478
 
479
-		$this->assertContains( 'Updated description.', $data['update'][0]['description'] );
480
-		$this->assertEquals( 'DUMMY SKU BATCH TEST 1', $data['create'][0]['sku'] );
481
-		$this->assertEquals( 'DUMMY SKU BATCH TEST 2', $data['create'][1]['sku'] );
482
-		$this->assertEquals( 'Test Button', $data['create'][0]['button_text'] );
483
-		$this->assertEquals( 'external', $data['create'][0]['type'] );
484
-		$this->assertEquals( 'simple', $data['create'][1]['type'] );
485
-		$this->assertEquals( $product_2->get_id(), $data['delete'][0]['previous']['id'] );
479
+		$this->assertContains( 'Updated description.', $data[ 'update' ][ 0 ][ 'description' ] );
480
+		$this->assertEquals( 'DUMMY SKU BATCH TEST 1', $data[ 'create' ][ 0 ][ 'sku' ] );
481
+		$this->assertEquals( 'DUMMY SKU BATCH TEST 2', $data[ 'create' ][ 1 ][ 'sku' ] );
482
+		$this->assertEquals( 'Test Button', $data[ 'create' ][ 0 ][ 'button_text' ] );
483
+		$this->assertEquals( 'external', $data[ 'create' ][ 0 ][ 'type' ] );
484
+		$this->assertEquals( 'simple', $data[ 'create' ][ 1 ][ 'type' ] );
485
+		$this->assertEquals( $product_2->get_id(), $data[ 'delete' ][ 0 ][ 'previous' ][ 'id' ] );
486 486
 
487 487
 		$request  = new WP_REST_Request( 'GET', '/wc/v4/products' );
488 488
 		$response = $this->server->dispatch( $request );
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 
519 519
 		$this->assertEquals( 4, count( $products ) );
520 520
 		foreach ( $products as $product ) {
521
-			$this->assertEquals( 'publish', $product['status'] );
521
+			$this->assertEquals( 'publish', $product[ 'status' ] );
522 522
 		}
523 523
 
524 524
 		// Test filtering with status=draft.
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 
530 530
 		$this->assertEquals( 4, count( $products ) );
531 531
 		foreach ( $products as $product ) {
532
-			$this->assertEquals( 'draft', $product['status'] );
532
+			$this->assertEquals( 'draft', $product[ 'status' ] );
533 533
 		}
534 534
 
535 535
 		// Test filtering with no filters - which should return 'any' (all 8).
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/products/' . $product->get_id() );
551 551
 		$response   = $this->server->dispatch( $request );
552 552
 		$data       = $response->get_data();
553
-		$properties = $data['schema']['properties'];
553
+		$properties = $data[ 'schema' ][ 'properties' ];
554 554
 		$this->assertEquals( 65, count( $properties ) );
555 555
 	}
556 556
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 		$category = wp_insert_term( 'Some Category', 'product_cat' );
565 565
 
566 566
 		$product = new \WC_Product_Simple();
567
-		$product->set_category_ids( array( $category['term_id'] ) );
567
+		$product->set_category_ids( array( $category[ 'term_id' ] ) );
568 568
 		$product->save();
569 569
 
570 570
 		// Create one product without category, i.e. Uncategorized.
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 
574 574
 		// Test product assigned to a single category.
575 575
 		$query_params = array(
576
-			'category' => (string) $category['term_id'],
576
+			'category' => (string) $category[ 'term_id' ],
577 577
 		);
578 578
 		$request      = new WP_REST_Request( 'GET', '/wc/v4/products' );
579 579
 		$request->set_query_params( $query_params );
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 
583 583
 		$this->assertEquals( 200, $response->get_status() );
584 584
 		foreach ( $response_products as $response_product ) {
585
-			$this->assertEquals( $product->get_id(), $response_product['id'] );
586
-			$this->assertEquals( $product->get_category_ids(), wp_list_pluck( $response_product['categories'], 'id' ) );
585
+			$this->assertEquals( $product->get_id(), $response_product[ 'id' ] );
586
+			$this->assertEquals( $product->get_category_ids(), wp_list_pluck( $response_product[ 'categories' ], 'id' ) );
587 587
 		}
588 588
 
589 589
 		// Test product without categories.
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 		$response_product = $response->get_data();
593 593
 
594 594
 		$this->assertEquals( 200, $response->get_status() );
595
-		$this->assertCount( 1, $response_product['categories'], print_r( $response_product, true ) );
596
-		$this->assertEquals( 'uncategorized', $response_product['categories'][0]['slug'] );
595
+		$this->assertCount( 1, $response_product[ 'categories' ], print_r( $response_product, true ) );
596
+		$this->assertEquals( 'uncategorized', $response_product[ 'categories' ][ 0 ][ 'slug' ] );
597 597
 
598 598
 	}
599 599
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		);
617 617
 
618 618
 		foreach ( $grouped->get_children() as $additional_product ) {
619
-			$product_ids_for_type['simple'][] = $additional_product;
619
+			$product_ids_for_type[ 'simple' ][ ] = $additional_product;
620 620
 		}
621 621
 
622 622
 		foreach ( $product_ids_for_type as $product_type => $product_ids ) {
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 			$this->assertEquals( 200, $response->get_status() );
632 632
 			$this->assertEquals( count( $product_ids ), count( $response_products ) );
633 633
 			foreach ( $response_products as $response_product ) {
634
-				$this->assertContains( $response_product['id'], $product_ids_for_type[ $product_type ], 'REST API: ' . $product_type . ' not found correctly' );
634
+				$this->assertContains( $response_product[ 'id' ], $product_ids_for_type[ $product_type ], 'REST API: ' . $product_type . ' not found correctly' );
635 635
 			}
636 636
 		}
637 637
 	}
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 
662 662
 		$this->assertEquals( 200, $response->get_status() );
663 663
 		foreach ( $response_products as $response_product ) {
664
-			$this->assertEquals( $feat_product->get_id(), $response_product['id'], 'REST API: Featured product not found correctly' );
664
+			$this->assertEquals( $feat_product->get_id(), $response_product[ 'id' ], 'REST API: Featured product not found correctly' );
665 665
 		}
666 666
 
667 667
 		$query_params = array(
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 
675 675
 		$this->assertEquals( 200, $response->get_status() );
676 676
 		foreach ( $response_products as $response_product ) {
677
-			$this->assertEquals( $nonfeat_product->get_id(), $response_product['id'], 'REST API: Featured product not found correctly' );
677
+			$this->assertEquals( $nonfeat_product->get_id(), $response_product[ 'id' ], 'REST API: Featured product not found correctly' );
678 678
 		}
679 679
 	}
680 680
 
@@ -687,11 +687,11 @@  discard block
 block discarded – undo
687 687
 		$shipping_class_1 = wp_insert_term( 'Bulky', 'product_shipping_class' );
688 688
 
689 689
 		$product_1 = new \WC_Product_Simple();
690
-		$product_1->set_shipping_class_id( $shipping_class_1['term_id'] );
690
+		$product_1->set_shipping_class_id( $shipping_class_1[ 'term_id' ] );
691 691
 		$product_1->save();
692 692
 
693 693
 		$query_params = array(
694
-			'shipping_class' => (string) $shipping_class_1['term_id'],
694
+			'shipping_class' => (string) $shipping_class_1[ 'term_id' ],
695 695
 		);
696 696
 		$request      = new WP_REST_Request( 'GET', '/wc/v4/products' );
697 697
 		$request->set_query_params( $query_params );
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 
701 701
 		$this->assertEquals( 200, $response->get_status() );
702 702
 		foreach ( $response_products as $response_product ) {
703
-			$this->assertEquals( $product_1->get_id(), $response_product['id'] );
703
+			$this->assertEquals( $product_1->get_id(), $response_product[ 'id' ] );
704 704
 		}
705 705
 	}
706 706
 
@@ -714,14 +714,14 @@  discard block
 block discarded – undo
714 714
 
715 715
 		// Product with a tag.
716 716
 		$product = ProductHelper::create_simple_product();
717
-		$product->set_tag_ids( array( $test_tag_1['term_id'] ) );
717
+		$product->set_tag_ids( array( $test_tag_1[ 'term_id' ] ) );
718 718
 		$product->save();
719 719
 
720 720
 		// Product without a tag.
721 721
 		$product_2 = ProductHelper::create_simple_product();
722 722
 
723 723
 		$query_params = array(
724
-			'tag' => (string) $test_tag_1['term_id'],
724
+			'tag' => (string) $test_tag_1[ 'term_id' ],
725 725
 		);
726 726
 		$request      = new WP_REST_Request( 'GET', '/wc/v4/products' );
727 727
 		$request->set_query_params( $query_params );
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 
731 731
 		$this->assertEquals( 200, $response->get_status() );
732 732
 		foreach ( $response_products as $response_product ) {
733
-			$this->assertEquals( $product->get_id(), $response_product['id'] );
733
+			$this->assertEquals( $product->get_id(), $response_product[ 'id' ] );
734 734
 		}
735 735
 	}
736 736
 
@@ -772,11 +772,11 @@  discard block
 block discarded – undo
772 772
 			$variable_product->get_id(),
773 773
 			$product_2->get_id(),
774 774
 		);
775
-		$query_params         = array(
775
+		$query_params = array(
776 776
 			'attribute'      => 'pa_size',
777 777
 			'attribute_term' => (string) $term_large->term_id,
778 778
 		);
779
-		$request              = new WP_REST_Request( 'GET', '/wc/v4/products' );
779
+		$request = new WP_REST_Request( 'GET', '/wc/v4/products' );
780 780
 		$request->set_query_params( $query_params );
781 781
 		$response          = $this->server->dispatch( $request );
782 782
 		$response_products = $response->get_data();
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 		$this->assertEquals( 200, $response->get_status() );
785 785
 		$this->assertEquals( count( $expected_product_ids ), count( $response_products ) );
786 786
 		foreach ( $response_products as $response_product ) {
787
-			$this->assertContains( $response_product['id'], $expected_product_ids );
787
+			$this->assertContains( $response_product[ 'id' ], $expected_product_ids );
788 788
 		}
789 789
 
790 790
 		// Products with attribute size == small.
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 			'attribute'      => 'pa_size',
796 796
 			'attribute_term' => (string) $term_small->term_id,
797 797
 		);
798
-		$request              = new WP_REST_Request( 'GET', '/wc/v4/products' );
798
+		$request = new WP_REST_Request( 'GET', '/wc/v4/products' );
799 799
 		$request->set_query_params( $query_params );
800 800
 		$response          = $this->server->dispatch( $request );
801 801
 		$response_products = $response->get_data();
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 		$this->assertEquals( 200, $response->get_status() );
804 804
 		$this->assertEquals( count( $expected_product_ids ), count( $response_products ) );
805 805
 		foreach ( $response_products as $response_product ) {
806
-			$this->assertContains( $response_product['id'], $expected_product_ids );
806
+			$this->assertContains( $response_product[ 'id' ], $expected_product_ids );
807 807
 		}
808 808
 	}
809 809
 
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/products/' . $product->get_id() );
816 816
 		$response   = $this->server->dispatch( $request );
817 817
 		$data       = $response->get_data();
818
-		$properties = $data['schema']['properties'];
818
+		$properties = $data[ 'schema' ][ 'properties' ];
819 819
 
820 820
 		$properties_to_embed = array(
821 821
 			'id',
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 
830 830
 		foreach ( $properties as $property_key => $property ) {
831 831
 			if ( in_array( $property_key, $properties_to_embed, true ) ) {
832
-				$this->assertEquals( array( 'view', 'edit', 'embed' ), $property['context'] );
832
+				$this->assertEquals( array( 'view', 'edit', 'embed' ), $property[ 'context' ] );
833 833
 			}
834 834
 		}
835 835
 
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/ProductVariations.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 		$variations = $response->get_data();
68 68
 		$this->assertEquals( 200, $response->get_status() );
69 69
 		$this->assertEquals( 2, count( $variations ) );
70
-		$this->assertEquals( 'DUMMY SKU VARIABLE LARGE', $variations[0]['sku'] );
71
-		$this->assertEquals( 'size', $variations[0]['attributes'][0]['name'] );
70
+		$this->assertEquals( 'DUMMY SKU VARIABLE LARGE', $variations[ 0 ][ 'sku' ] );
71
+		$this->assertEquals( 'size', $variations[ 0 ][ 'attributes' ][ 0 ][ 'name' ] );
72 72
 	}
73 73
 
74 74
 	/**
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 	public function test_get_variation() {
92 92
 		$product      = ProductHelper::create_variation_product();
93 93
 		$children     = $product->get_children();
94
-		$variation_id = $children[0];
94
+		$variation_id = $children[ 0 ];
95 95
 
96 96
 		$response  = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ) );
97 97
 		$variation = $response->get_data();
98 98
 
99 99
 		$this->assertEquals( 200, $response->get_status() );
100
-		$this->assertEquals( $variation_id, $variation['id'] );
101
-		$this->assertEquals( 'size', $variation['attributes'][0]['name'] );
100
+		$this->assertEquals( $variation_id, $variation[ 'id' ] );
101
+		$this->assertEquals( 'size', $variation[ 'attributes' ][ 0 ][ 'name' ] );
102 102
 	}
103 103
 
104 104
 	/**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		wp_set_current_user( 0 );
111 111
 		$product      = ProductHelper::create_variation_product();
112 112
 		$children     = $product->get_children();
113
-		$variation_id = $children[0];
113
+		$variation_id = $children[ 0 ];
114 114
 		$response     = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ) );
115 115
 		$this->assertEquals( 401, $response->get_status() );
116 116
 	}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	public function test_delete_variation() {
124 124
 		$product      = ProductHelper::create_variation_product();
125 125
 		$children     = $product->get_children();
126
-		$variation_id = $children[0];
126
+		$variation_id = $children[ 0 ];
127 127
 
128 128
 		$request = new WP_REST_Request( 'DELETE', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id );
129 129
 		$request->set_param( 'force', true );
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		wp_set_current_user( 0 );
145 145
 		$product      = ProductHelper::create_variation_product();
146 146
 		$children     = $product->get_children();
147
-		$variation_id = $children[0];
147
+		$variation_id = $children[ 0 ];
148 148
 
149 149
 		$request = new WP_REST_Request( 'DELETE', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id );
150 150
 		$request->set_param( 'force', true );
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
 	public function test_update_variation() {
175 175
 		$product      = ProductHelper::create_variation_product();
176 176
 		$children     = $product->get_children();
177
-		$variation_id = $children[0];
177
+		$variation_id = $children[ 0 ];
178 178
 
179 179
 		$response  = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ) );
180 180
 		$variation = $response->get_data();
181 181
 
182
-		$this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variation['sku'] );
183
-		$this->assertEquals( 10, $variation['regular_price'] );
184
-		$this->assertEmpty( $variation['sale_price'] );
185
-		$this->assertEquals( 'small', $variation['attributes'][0]['option'] );
182
+		$this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variation[ 'sku' ] );
183
+		$this->assertEquals( 10, $variation[ 'regular_price' ] );
184
+		$this->assertEmpty( $variation[ 'sale_price' ] );
185
+		$this->assertEquals( 'small', $variation[ 'attributes' ][ 0 ][ 'option' ] );
186 186
 
187 187
 		$request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id );
188 188
 		$request->set_body_params(
@@ -206,15 +206,15 @@  discard block
 block discarded – undo
206 206
 		$response  = $this->server->dispatch( $request );
207 207
 		$variation = $response->get_data();
208 208
 
209
-		$this->assertTrue( isset( $variation['description'] ), print_r( $variation, true ) );
210
-		$this->assertContains( 'O_O', $variation['description'], print_r( $variation, true ) );
211
-		$this->assertEquals( '8', $variation['price'], print_r( $variation, true ) );
212
-		$this->assertEquals( '8', $variation['sale_price'], print_r( $variation, true ) );
213
-		$this->assertEquals( '10', $variation['regular_price'], print_r( $variation, true ) );
214
-		$this->assertEquals( 'FIXED-\'SKU', $variation['sku'], print_r( $variation, true ) );
215
-		$this->assertEquals( 'medium', $variation['attributes'][0]['option'], print_r( $variation, true ) );
216
-		$this->assertContains( 'Dr1Bczxq4q', $variation['image']['src'], print_r( $variation, true ) );
217
-		$this->assertContains( 'test upload image', $variation['image']['alt'], print_r( $variation, true ) );
209
+		$this->assertTrue( isset( $variation[ 'description' ] ), print_r( $variation, true ) );
210
+		$this->assertContains( 'O_O', $variation[ 'description' ], print_r( $variation, true ) );
211
+		$this->assertEquals( '8', $variation[ 'price' ], print_r( $variation, true ) );
212
+		$this->assertEquals( '8', $variation[ 'sale_price' ], print_r( $variation, true ) );
213
+		$this->assertEquals( '10', $variation[ 'regular_price' ], print_r( $variation, true ) );
214
+		$this->assertEquals( 'FIXED-\'SKU', $variation[ 'sku' ], print_r( $variation, true ) );
215
+		$this->assertEquals( 'medium', $variation[ 'attributes' ][ 0 ][ 'option' ], print_r( $variation, true ) );
216
+		$this->assertContains( 'Dr1Bczxq4q', $variation[ 'image' ][ 'src' ], print_r( $variation, true ) );
217
+		$this->assertContains( 'test upload image', $variation[ 'image' ][ 'alt' ], print_r( $variation, true ) );
218 218
 	}
219 219
 
220 220
 	/**
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		wp_set_current_user( 0 );
227 227
 		$product      = ProductHelper::create_variation_product();
228 228
 		$children     = $product->get_children();
229
-		$variation_id = $children[0];
229
+		$variation_id = $children[ 0 ];
230 230
 
231 231
 		$request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id );
232 232
 		$request->set_body_params(
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 		$response  = $this->server->dispatch( $request );
285 285
 		$variation = $response->get_data();
286 286
 
287
-		$this->assertContains( 'A medium size.', $variation['description'] );
288
-		$this->assertEquals( '12', $variation['price'] );
289
-		$this->assertEquals( '12', $variation['regular_price'] );
290
-		$this->assertTrue( $variation['purchasable'] );
291
-		$this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $variation['sku'] );
292
-		$this->assertEquals( 'medium', $variation['attributes'][0]['option'] );
287
+		$this->assertContains( 'A medium size.', $variation[ 'description' ] );
288
+		$this->assertEquals( '12', $variation[ 'price' ] );
289
+		$this->assertEquals( '12', $variation[ 'regular_price' ] );
290
+		$this->assertTrue( $variation[ 'purchasable' ] );
291
+		$this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $variation[ 'sku' ] );
292
+		$this->assertEquals( 'medium', $variation[ 'attributes' ][ 0 ][ 'option' ] );
293 293
 
294 294
 		$response   = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() . '/variations' ) );
295 295
 		$variations = $response->get_data();
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 			array(
337 337
 				'update' => array(
338 338
 					array(
339
-						'id'          => $children[0],
339
+						'id'          => $children[ 0 ],
340 340
 						'description' => 'Updated description.',
341 341
 						'image'       => array(
342 342
 							'position' => 0,
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 					),
347 347
 				),
348 348
 				'delete' => array(
349
-					$children[1],
349
+					$children[ 1 ],
350 350
 				),
351 351
 				'create' => array(
352 352
 					array(
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 		$response = $this->server->dispatch( $request );
367 367
 		$data     = $response->get_data();
368 368
 
369
-		$this->assertContains( 'Updated description.', $data['update'][0]['description'] );
370
-		$this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $data['create'][0]['sku'] );
371
-		$this->assertEquals( 'medium', $data['create'][0]['attributes'][0]['option'] );
372
-		$this->assertEquals( $children[1], $data['delete'][0]['previous']['id'] );
369
+		$this->assertContains( 'Updated description.', $data[ 'update' ][ 0 ][ 'description' ] );
370
+		$this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $data[ 'create' ][ 0 ][ 'sku' ] );
371
+		$this->assertEquals( 'medium', $data[ 'create' ][ 0 ][ 'attributes' ][ 0 ][ 'option' ] );
372
+		$this->assertEquals( $children[ 1 ], $data[ 'delete' ][ 0 ][ 'previous' ][ 'id' ] );
373 373
 
374 374
 		$request  = new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() . '/variations' );
375 375
 		$response = $this->server->dispatch( $request );
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/products/' . $product->get_id() . '/variations' );
389 389
 		$response   = $this->server->dispatch( $request );
390 390
 		$data       = $response->get_data();
391
-		$properties = $data['schema']['properties'];
391
+		$properties = $data[ 'schema' ][ 'properties' ];
392 392
 
393 393
 		$this->assertEquals( 40, count( $properties ) );
394 394
 		$this->assertArrayHasKey( 'id', $properties );
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 		$product->save();
439 439
 
440 440
 		$children     = $product->get_children();
441
-		$variation_id = $children[0];
441
+		$variation_id = $children[ 0 ];
442 442
 
443 443
 		// Set stock to true.
444 444
 		$request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id );
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 		$variation = $response->get_data();
453 453
 
454 454
 		$this->assertEquals( 200, $response->get_status() );
455
-		$this->assertEquals( true, $variation['manage_stock'] );
455
+		$this->assertEquals( true, $variation[ 'manage_stock' ] );
456 456
 
457 457
 		// Set stock to false.
458 458
 		$request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id );
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 		$variation = $response->get_data();
467 467
 
468 468
 		$this->assertEquals( 200, $response->get_status() );
469
-		$this->assertEquals( false, $variation['manage_stock'] );
469
+		$this->assertEquals( false, $variation[ 'manage_stock' ] );
470 470
 
471 471
 		// Set stock to false but parent is managing stock.
472 472
 		$product->set_manage_stock( true );
@@ -482,6 +482,6 @@  discard block
 block discarded – undo
482 482
 		$variation = $response->get_data();
483 483
 
484 484
 		$this->assertEquals( 200, $response->get_status() );
485
-		$this->assertEquals( 'parent', $variation['manage_stock'] );
485
+		$this->assertEquals( 'parent', $variation[ 'manage_stock' ] );
486 486
 	}
487 487
 }
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/Data.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
 		$this->assertEquals( 200, $response->get_status() );
61 61
 		$this->assertEquals( 4, count( $data ) );
62
-		$this->assertEquals( 'download-ips', $data[3]['slug'] );
62
+		$this->assertEquals( 'download-ips', $data[ 3 ][ 'slug' ] );
63 63
 	}
64 64
 
65 65
 	/**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		$this->assertEquals( 200, $response->get_status() );
128 128
 		$this->assertEquals( 2, count( $addresses ) );
129 129
 
130
-		$this->assertEquals( '54.2.1.3', $addresses[0]['user_ip_address'] );
131
-		$this->assertEquals( '54.5.1.7', $addresses[1]['user_ip_address'] );
130
+		$this->assertEquals( '54.2.1.3', $addresses[ 0 ][ 'user_ip_address' ] );
131
+		$this->assertEquals( '54.5.1.7', $addresses[ 1 ][ 'user_ip_address' ] );
132 132
 	}
133 133
 }
Please login to merge, or discard this patch.