Passed
Pull Request — master (#3)
by Rodrigo
03:28
created
unit-tests/Tests/Version3/orders.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Create 10 orders.
52 52
 		for ( $i = 0; $i < 10; $i++ ) {
53
-			$this->orders[] = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order( $this->user );
53
+			$this->orders[ ] = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order( $this->user );
54 54
 		}
55 55
 
56 56
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/orders' ) );
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function test_get_items_without_permission() {
69 69
 		wp_set_current_user( 0 );
70
-		$this->orders[] = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order();
70
+		$this->orders[ ] = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order();
71 71
 		$response       = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/orders' ) );
72 72
 		$this->assertEquals( 401, $response->get_status() );
73 73
 	}
@@ -82,18 +82,18 @@  discard block
 block discarded – undo
82 82
 		$order->add_meta_data( 'key', 'value' );
83 83
 		$order->add_meta_data( 'key2', 'value2' );
84 84
 		$order->save();
85
-		$this->orders[] = $order;
85
+		$this->orders[ ] = $order;
86 86
 		$response       = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/orders/' . $order->get_id() ) );
87 87
 		$data           = $response->get_data();
88 88
 
89 89
 		$this->assertEquals( 200, $response->get_status() );
90
-		$this->assertEquals( $order->get_id(), $data['id'] );
90
+		$this->assertEquals( $order->get_id(), $data[ 'id' ] );
91 91
 
92 92
 		// Test meta data is set.
93
-		$this->assertEquals( 'key', $data['meta_data'][0]->key );
94
-		$this->assertEquals( 'value', $data['meta_data'][0]->value );
95
-		$this->assertEquals( 'key2', $data['meta_data'][1]->key );
96
-		$this->assertEquals( 'value2', $data['meta_data'][1]->value );
93
+		$this->assertEquals( 'key', $data[ 'meta_data' ][ 0 ]->key );
94
+		$this->assertEquals( 'value', $data[ 'meta_data' ][ 0 ]->value );
95
+		$this->assertEquals( 'key2', $data[ 'meta_data' ][ 1 ]->key );
96
+		$this->assertEquals( 'value2', $data[ 'meta_data' ][ 1 ]->value );
97 97
 	}
98 98
 
99 99
 	/**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	public function test_get_item_without_permission() {
104 104
 		wp_set_current_user( 0 );
105 105
 		$order          = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order();
106
-		$this->orders[] = $order;
106
+		$this->orders[ ] = $order;
107 107
 		$response       = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/orders/' . $order->get_id() ) );
108 108
 		$this->assertEquals( 401, $response->get_status() );
109 109
 	}
@@ -186,32 +186,32 @@  discard block
 block discarded – undo
186 186
 		);
187 187
 		$response = $this->server->dispatch( $request );
188 188
 		$data     = $response->get_data();
189
-		$order    = wc_get_order( $data['id'] );
189
+		$order    = wc_get_order( $data[ 'id' ] );
190 190
 		$this->assertEquals( 201, $response->get_status() );
191
-		$this->assertEquals( $order->get_payment_method(), $data['payment_method'] );
192
-		$this->assertEquals( $order->get_payment_method_title(), $data['payment_method_title'] );
193
-		$this->assertEquals( $order->get_billing_first_name(), $data['billing']['first_name'] );
194
-		$this->assertEquals( $order->get_billing_last_name(), $data['billing']['last_name'] );
195
-		$this->assertEquals( '', $data['billing']['company'] );
196
-		$this->assertEquals( $order->get_billing_address_1(), $data['billing']['address_1'] );
197
-		$this->assertEquals( $order->get_billing_address_2(), $data['billing']['address_2'] );
198
-		$this->assertEquals( $order->get_billing_city(), $data['billing']['city'] );
199
-		$this->assertEquals( $order->get_billing_state(), $data['billing']['state'] );
200
-		$this->assertEquals( $order->get_billing_postcode(), $data['billing']['postcode'] );
201
-		$this->assertEquals( $order->get_billing_country(), $data['billing']['country'] );
202
-		$this->assertEquals( $order->get_billing_email(), $data['billing']['email'] );
203
-		$this->assertEquals( $order->get_billing_phone(), $data['billing']['phone'] );
204
-		$this->assertEquals( $order->get_shipping_first_name(), $data['shipping']['first_name'] );
205
-		$this->assertEquals( $order->get_shipping_last_name(), $data['shipping']['last_name'] );
206
-		$this->assertEquals( '', $data['shipping']['company'] );
207
-		$this->assertEquals( $order->get_shipping_address_1(), $data['shipping']['address_1'] );
208
-		$this->assertEquals( $order->get_shipping_address_2(), $data['shipping']['address_2'] );
209
-		$this->assertEquals( $order->get_shipping_city(), $data['shipping']['city'] );
210
-		$this->assertEquals( $order->get_shipping_state(), $data['shipping']['state'] );
211
-		$this->assertEquals( $order->get_shipping_postcode(), $data['shipping']['postcode'] );
212
-		$this->assertEquals( $order->get_shipping_country(), $data['shipping']['country'] );
213
-		$this->assertEquals( 1, count( $data['line_items'] ) );
214
-		$this->assertEquals( 1, count( $data['shipping_lines'] ) );
191
+		$this->assertEquals( $order->get_payment_method(), $data[ 'payment_method' ] );
192
+		$this->assertEquals( $order->get_payment_method_title(), $data[ 'payment_method_title' ] );
193
+		$this->assertEquals( $order->get_billing_first_name(), $data[ 'billing' ][ 'first_name' ] );
194
+		$this->assertEquals( $order->get_billing_last_name(), $data[ 'billing' ][ 'last_name' ] );
195
+		$this->assertEquals( '', $data[ 'billing' ][ 'company' ] );
196
+		$this->assertEquals( $order->get_billing_address_1(), $data[ 'billing' ][ 'address_1' ] );
197
+		$this->assertEquals( $order->get_billing_address_2(), $data[ 'billing' ][ 'address_2' ] );
198
+		$this->assertEquals( $order->get_billing_city(), $data[ 'billing' ][ 'city' ] );
199
+		$this->assertEquals( $order->get_billing_state(), $data[ 'billing' ][ 'state' ] );
200
+		$this->assertEquals( $order->get_billing_postcode(), $data[ 'billing' ][ 'postcode' ] );
201
+		$this->assertEquals( $order->get_billing_country(), $data[ 'billing' ][ 'country' ] );
202
+		$this->assertEquals( $order->get_billing_email(), $data[ 'billing' ][ 'email' ] );
203
+		$this->assertEquals( $order->get_billing_phone(), $data[ 'billing' ][ 'phone' ] );
204
+		$this->assertEquals( $order->get_shipping_first_name(), $data[ 'shipping' ][ 'first_name' ] );
205
+		$this->assertEquals( $order->get_shipping_last_name(), $data[ 'shipping' ][ 'last_name' ] );
206
+		$this->assertEquals( '', $data[ 'shipping' ][ 'company' ] );
207
+		$this->assertEquals( $order->get_shipping_address_1(), $data[ 'shipping' ][ 'address_1' ] );
208
+		$this->assertEquals( $order->get_shipping_address_2(), $data[ 'shipping' ][ 'address_2' ] );
209
+		$this->assertEquals( $order->get_shipping_city(), $data[ 'shipping' ][ 'city' ] );
210
+		$this->assertEquals( $order->get_shipping_state(), $data[ 'shipping' ][ 'state' ] );
211
+		$this->assertEquals( $order->get_shipping_postcode(), $data[ 'shipping' ][ 'postcode' ] );
212
+		$this->assertEquals( $order->get_shipping_country(), $data[ 'shipping' ][ 'country' ] );
213
+		$this->assertEquals( 1, count( $data[ 'line_items' ] ) );
214
+		$this->assertEquals( 1, count( $data[ 'shipping_lines' ] ) );
215 215
 	}
216 216
 
217 217
 	/**
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
 		);
270 270
 		$response = $this->server->dispatch( $request );
271 271
 		$data     = $response->get_data();
272
-		$order    = wc_get_order( $data['id'] );
272
+		$order    = wc_get_order( $data[ 'id' ] );
273 273
 		$this->assertEquals( 201, $response->get_status() );
274
-		$this->assertEquals( $order->get_payment_method(), $data['payment_method'] );
274
+		$this->assertEquals( $order->get_payment_method(), $data[ 'payment_method' ] );
275 275
 		$this->assertEquals( $order->get_payment_method_title(), 'Sanitize this' );
276 276
 
277 277
 		// Test when updating order.
278
-		$request = new WP_REST_Request( 'PUT', '/wc/v3/orders/' . $data['id'] );
278
+		$request = new WP_REST_Request( 'PUT', '/wc/v3/orders/' . $data[ 'id' ] );
279 279
 		$request->set_body_params(
280 280
 			array(
281 281
 				'payment_method'       => 'bacs',
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 		);
285 285
 		$response = $this->server->dispatch( $request );
286 286
 		$data     = $response->get_data();
287
-		$order    = wc_get_order( $data['id'] );
287
+		$order    = wc_get_order( $data[ 'id' ] );
288 288
 		$this->assertEquals( 200, $response->get_status() );
289
-		$this->assertEquals( $order->get_payment_method(), $data['payment_method'] );
289
+		$this->assertEquals( $order->get_payment_method(), $data[ 'payment_method' ] );
290 290
 		$this->assertEquals( $order->get_payment_method_title(), 'Sanitize this too' );
291 291
 	}
292 292
 
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
 		$data     = $response->get_data();
371 371
 
372 372
 		$this->assertEquals( 200, $response->get_status() );
373
-		$this->assertEquals( 'test-update', $data['payment_method'] );
374
-		$this->assertEquals( 'Fish', $data['billing']['first_name'] );
375
-		$this->assertEquals( 'Face', $data['billing']['last_name'] );
373
+		$this->assertEquals( 'test-update', $data[ 'payment_method' ] );
374
+		$this->assertEquals( 'Fish', $data[ 'billing' ][ 'first_name' ] );
375
+		$this->assertEquals( 'Face', $data[ 'billing' ][ 'last_name' ] );
376 376
 	}
377 377
 
378 378
 	/**
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 		$data     = $response->get_data();
413 413
 
414 414
 		$this->assertEquals( 200, $response->get_status() );
415
-		$this->assertTrue( empty( $data['fee_lines'] ) );
415
+		$this->assertTrue( empty( $data[ 'fee_lines' ] ) );
416 416
 	}
417 417
 
418 418
 	/**
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 		$data     = $response->get_data();
444 444
 
445 445
 		$this->assertEquals( 200, $response->get_status() );
446
-		$this->assertCount( 1, $data['coupon_lines'] );
447
-		$this->assertEquals( '45.00', $data['total'] );
446
+		$this->assertCount( 1, $data[ 'coupon_lines' ] );
447
+		$this->assertEquals( '45.00', $data[ 'total' ] );
448 448
 	}
449 449
 
450 450
 	/**
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 		$data     = $response->get_data();
491 491
 
492 492
 		$this->assertEquals( 200, $response->get_status() );
493
-		$this->assertTrue( empty( $data['coupon_lines'] ) );
494
-		$this->assertEquals( '50.00', $data['total'] );
493
+		$this->assertTrue( empty( $data[ 'coupon_lines' ] ) );
494
+		$this->assertEquals( '50.00', $data[ 'total' ] );
495 495
 	}
496 496
 
497 497
 	/**
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 		$data     = $response->get_data();
518 518
 
519 519
 		$this->assertEquals( 400, $response->get_status() );
520
-		$this->assertEquals( 'woocommerce_rest_invalid_coupon', $data['code'] );
521
-		$this->assertEquals( 'Coupon "non_existing_coupon" does not exist!', $data['message'] );
520
+		$this->assertEquals( 'woocommerce_rest_invalid_coupon', $data[ 'code' ] );
521
+		$this->assertEquals( 'Coupon "non_existing_coupon" does not exist!', $data[ 'message' ] );
522 522
 	}
523 523
 
524 524
 	/**
@@ -636,9 +636,9 @@  discard block
 block discarded – undo
636 636
 		$response = $this->server->dispatch( $request );
637 637
 		$data     = $response->get_data();
638 638
 
639
-		$this->assertEquals( 'updated', $data['update'][0]['payment_method'] );
640
-		$this->assertEquals( $order2->get_id(), $data['delete'][0]['id'] );
641
-		$this->assertEquals( $order3->get_id(), $data['delete'][1]['id'] );
639
+		$this->assertEquals( 'updated', $data[ 'update' ][ 0 ][ 'payment_method' ] );
640
+		$this->assertEquals( $order2->get_id(), $data[ 'delete' ][ 0 ][ 'id' ] );
641
+		$this->assertEquals( $order3->get_id(), $data[ 'delete' ][ 1 ][ 'id' ] );
642 642
 
643 643
 		$request  = new WP_REST_Request( 'GET', '/wc/v3/orders' );
644 644
 		$response = $this->server->dispatch( $request );
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v3/orders/' . $order->get_id() );
658 658
 		$response   = $this->server->dispatch( $request );
659 659
 		$data       = $response->get_data();
660
-		$properties = $data['schema']['properties'];
660
+		$properties = $data[ 'schema' ][ 'properties' ];
661 661
 
662 662
 		$this->assertEquals( 42, count( $properties ) );
663 663
 		$this->assertArrayHasKey( 'id', $properties );
Please login to merge, or discard this patch.
unit-tests/Tests/Version3/product-reviews.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 		$this->assertContains(
54 54
 			array(
55 55
 				'id'                   => $review_id,
56
-				'date_created'         => $product_reviews[0]['date_created'],
57
-				'date_created_gmt'     => $product_reviews[0]['date_created_gmt'],
56
+				'date_created'         => $product_reviews[ 0 ][ 'date_created' ],
57
+				'date_created_gmt'     => $product_reviews[ 0 ][ 'date_created_gmt' ],
58 58
 				'product_id'           => $product->get_id(),
59 59
 				'status'               => 'approved',
60 60
 				'reviewer'             => 'admin',
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 				'review'               => "<p>Review content here</p>\n",
63 63
 				'rating'               => 0,
64 64
 				'verified'             => false,
65
-				'reviewer_avatar_urls' => $product_reviews[0]['reviewer_avatar_urls'],
65
+				'reviewer_avatar_urls' => $product_reviews[ 0 ][ 'reviewer_avatar_urls' ],
66 66
 				'_links'               => array(
67 67
 					'self'       => array(
68 68
 						array(
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 		$this->assertEquals(
126 126
 			array(
127 127
 				'id'                   => $product_review_id,
128
-				'date_created'         => $data['date_created'],
129
-				'date_created_gmt'     => $data['date_created_gmt'],
128
+				'date_created'         => $data[ 'date_created' ],
129
+				'date_created_gmt'     => $data[ 'date_created_gmt' ],
130 130
 				'product_id'           => $product->get_id(),
131 131
 				'status'               => 'approved',
132 132
 				'reviewer'             => 'admin',
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 				'review'               => "<p>Review content here</p>\n",
135 135
 				'rating'               => 0,
136 136
 				'verified'             => false,
137
-				'reviewer_avatar_urls' => $data['reviewer_avatar_urls'],
137
+				'reviewer_avatar_urls' => $data[ 'reviewer_avatar_urls' ],
138 138
 			),
139 139
 			$data
140 140
 		);
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 		$this->assertEquals( 201, $response->get_status() );
190 190
 		$this->assertEquals(
191 191
 			array(
192
-				'id'                   => $data['id'],
193
-				'date_created'         => $data['date_created'],
194
-				'date_created_gmt'     => $data['date_created_gmt'],
192
+				'id'                   => $data[ 'id' ],
193
+				'date_created'         => $data[ 'date_created' ],
194
+				'date_created_gmt'     => $data[ 'date_created_gmt' ],
195 195
 				'product_id'           => $product->get_id(),
196 196
 				'status'               => 'approved',
197 197
 				'reviewer'             => 'Admin',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				'review'               => 'Hello world.',
200 200
 				'rating'               => 5,
201 201
 				'verified'             => false,
202
-				'reviewer_avatar_urls' => $data['reviewer_avatar_urls'],
202
+				'reviewer_avatar_urls' => $data[ 'reviewer_avatar_urls' ],
203 203
 			),
204 204
 			$data
205 205
 		);
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 
267 267
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/products/reviews/' . $product_review_id ) );
268 268
 		$data     = $response->get_data();
269
-		$this->assertEquals( "<p>Review content here</p>\n", $data['review'] );
270
-		$this->assertEquals( 'admin', $data['reviewer'] );
271
-		$this->assertEquals( '[email protected]', $data['reviewer_email'] );
272
-		$this->assertEquals( 0, $data['rating'] );
269
+		$this->assertEquals( "<p>Review content here</p>\n", $data[ 'review' ] );
270
+		$this->assertEquals( 'admin', $data[ 'reviewer' ] );
271
+		$this->assertEquals( '[email protected]', $data[ 'reviewer_email' ] );
272
+		$this->assertEquals( 0, $data[ 'rating' ] );
273 273
 
274 274
 		$request = new WP_REST_Request( 'PUT', '/wc/v3/products/reviews/' . $product_review_id );
275 275
 		$request->set_body_params(
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
 		);
283 283
 		$response = $this->server->dispatch( $request );
284 284
 		$data     = $response->get_data();
285
-		$this->assertEquals( 'Hello world - updated.', $data['review'] );
286
-		$this->assertEquals( 'Justin', $data['reviewer'] );
287
-		$this->assertEquals( '[email protected]', $data['reviewer_email'] );
288
-		$this->assertEquals( 3, $data['rating'] );
285
+		$this->assertEquals( 'Hello world - updated.', $data[ 'review' ] );
286
+		$this->assertEquals( 'Justin', $data[ 'reviewer' ] );
287
+		$this->assertEquals( '[email protected]', $data[ 'reviewer_email' ] );
288
+		$this->assertEquals( 3, $data[ 'rating' ] );
289 289
 	}
290 290
 
291 291
 	/**
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 		$response = $this->server->dispatch( $request );
425 425
 		$data     = $response->get_data();
426 426
 
427
-		$this->assertEquals( 'Updated review.', $data['update'][0]['review'] );
428
-		$this->assertEquals( 'New review.', $data['create'][0]['review'] );
429
-		$this->assertEquals( $review_2_id, $data['delete'][0]['previous']['id'] );
430
-		$this->assertEquals( $review_3_id, $data['delete'][1]['previous']['id'] );
427
+		$this->assertEquals( 'Updated review.', $data[ 'update' ][ 0 ][ 'review' ] );
428
+		$this->assertEquals( 'New review.', $data[ 'create' ][ 0 ][ 'review' ] );
429
+		$this->assertEquals( $review_2_id, $data[ 'delete' ][ 0 ][ 'previous' ][ 'id' ] );
430
+		$this->assertEquals( $review_3_id, $data[ 'delete' ][ 1 ][ 'previous' ][ 'id' ] );
431 431
 
432 432
 		$request = new WP_REST_Request( 'GET', '/wc/v3/products/reviews' );
433 433
 		$request->set_param( 'product', $product->get_id() );
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v3/products/reviews' );
450 450
 		$response   = $this->server->dispatch( $request );
451 451
 		$data       = $response->get_data();
452
-		$properties = $data['schema']['properties'];
452
+		$properties = $data[ 'schema' ][ 'properties' ];
453 453
 
454 454
 		$this->assertEquals( 11, count( $properties ) );
455 455
 		$this->assertArrayHasKey( 'id', $properties );
Please login to merge, or discard this patch.
unit-tests/Tests/Version3/customers.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
 		$this->assertEquals( 201, $response->get_status() );
221 221
 		$this->assertEquals(
222 222
 			array(
223
-				'id'                 => $data['id'],
224
-				'date_created'       => $data['date_created'],
225
-				'date_created_gmt'   => $data['date_created_gmt'],
226
-				'date_modified'      => $data['date_modified'],
227
-				'date_modified_gmt'  => $data['date_modified_gmt'],
223
+				'id'                 => $data[ 'id' ],
224
+				'date_created'       => $data[ 'date_created' ],
225
+				'date_created_gmt'   => $data[ 'date_created_gmt' ],
226
+				'date_modified'      => $data[ 'date_modified' ],
227
+				'date_modified_gmt'  => $data[ 'date_modified_gmt' ],
228 228
 				'email'              => '[email protected]',
229 229
 				'first_name'         => '',
230 230
 				'last_name'          => '',
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 				),
257 257
 				'is_paying_customer' => false,
258 258
 				'meta_data'          => array(),
259
-				'avatar_url'         => $data['avatar_url'],
259
+				'avatar_url'         => $data[ 'avatar_url' ],
260 260
 			),
261 261
 			$data
262 262
 		);
@@ -286,11 +286,11 @@  discard block
 block discarded – undo
286 286
 		$this->assertEquals( 201, $response->get_status() );
287 287
 		$this->assertEquals(
288 288
 			array(
289
-				'id'                 => $data['id'],
290
-				'date_created'       => $data['date_created'],
291
-				'date_created_gmt'   => $data['date_created_gmt'],
292
-				'date_modified'      => $data['date_modified'],
293
-				'date_modified_gmt'  => $data['date_modified_gmt'],
289
+				'id'                 => $data[ 'id' ],
290
+				'date_created'       => $data[ 'date_created' ],
291
+				'date_created_gmt'   => $data[ 'date_created_gmt' ],
292
+				'date_modified'      => $data[ 'date_modified' ],
293
+				'date_modified_gmt'  => $data[ 'date_modified_gmt' ],
294 294
 				'email'              => '[email protected]',
295 295
 				'first_name'         => 'Test',
296 296
 				'last_name'          => 'McTestFace',
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 				),
323 323
 				'is_paying_customer' => false,
324 324
 				'meta_data'          => array(),
325
-				'avatar_url'         => $data['avatar_url'],
325
+				'avatar_url'         => $data[ 'avatar_url' ],
326 326
 			),
327 327
 			$data
328 328
 		);
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
 
375 375
 		$this->assertEquals(
376 376
 			array(
377
-				'id'                 => $data['id'],
378
-				'date_created'       => $data['date_created'],
379
-				'date_created_gmt'   => $data['date_created_gmt'],
380
-				'date_modified'      => $data['date_modified'],
381
-				'date_modified_gmt'  => $data['date_modified_gmt'],
377
+				'id'                 => $data[ 'id' ],
378
+				'date_created'       => $data[ 'date_created' ],
379
+				'date_created_gmt'   => $data[ 'date_created_gmt' ],
380
+				'date_modified'      => $data[ 'date_modified' ],
381
+				'date_modified_gmt'  => $data[ 'date_modified_gmt' ],
382 382
 				'email'              => '[email protected]',
383 383
 				'first_name'         => 'Justin',
384 384
 				'billing'            => array(
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 				'last_name'          => '',
411 411
 				'role'               => 'customer',
412 412
 				'username'           => 'get_customer_test',
413
-				'avatar_url'         => $data['avatar_url'],
413
+				'avatar_url'         => $data[ 'avatar_url' ],
414 414
 			),
415 415
 			$data
416 416
 		);
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
 
451 451
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/customers/' . $customer->get_id() ) );
452 452
 		$data     = $response->get_data();
453
-		$this->assertEquals( 'update_customer_test', $data['username'] );
454
-		$this->assertEquals( '[email protected]', $data['email'] );
453
+		$this->assertEquals( 'update_customer_test', $data[ 'username' ] );
454
+		$this->assertEquals( '[email protected]', $data[ 'email' ] );
455 455
 
456 456
 		$request = new WP_REST_Request( 'PUT', '/wc/v3/customers/' . $customer->get_id() );
457 457
 		$request->set_body_params(
@@ -463,8 +463,8 @@  discard block
 block discarded – undo
463 463
 		$response = $this->server->dispatch( $request );
464 464
 		$data     = $response->get_data();
465 465
 
466
-		$this->assertEquals( '[email protected]', $data['email'] );
467
-		$this->assertEquals( 'UpdatedTest', $data['first_name'] );
466
+		$this->assertEquals( '[email protected]', $data[ 'email' ] );
467
+		$this->assertEquals( 'UpdatedTest', $data[ 'first_name' ] );
468 468
 	}
469 469
 
470 470
 	/**
@@ -570,11 +570,11 @@  discard block
 block discarded – undo
570 570
 		$response = $this->server->dispatch( $request );
571 571
 		$data     = $response->get_data();
572 572
 
573
-		$this->assertEquals( 'McTest', $data['update'][0]['last_name'] );
574
-		$this->assertEquals( 'newuser', $data['create'][0]['username'] );
575
-		$this->assertEmpty( $data['create'][0]['last_name'] );
576
-		$this->assertEquals( $customer_2->get_id(), $data['delete'][0]['id'] );
577
-		$this->assertEquals( $customer_3->get_id(), $data['delete'][1]['id'] );
573
+		$this->assertEquals( 'McTest', $data[ 'update' ][ 0 ][ 'last_name' ] );
574
+		$this->assertEquals( 'newuser', $data[ 'create' ][ 0 ][ 'username' ] );
575
+		$this->assertEmpty( $data[ 'create' ][ 0 ][ 'last_name' ] );
576
+		$this->assertEquals( $customer_2->get_id(), $data[ 'delete' ][ 0 ][ 'id' ] );
577
+		$this->assertEquals( $customer_3->get_id(), $data[ 'delete' ][ 1 ][ 'id' ] );
578 578
 
579 579
 		$request  = new WP_REST_Request( 'GET', '/wc/v3/customers' );
580 580
 		$response = $this->server->dispatch( $request );
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v3/customers' );
594 594
 		$response   = $this->server->dispatch( $request );
595 595
 		$data       = $response->get_data();
596
-		$properties = $data['schema']['properties'];
596
+		$properties = $data[ 'schema' ][ 'properties' ];
597 597
 
598 598
 		$this->assertEquals( 16, count( $properties ) );
599 599
 		$this->assertArrayHasKey( 'id', $properties );
@@ -609,26 +609,26 @@  discard block
 block discarded – undo
609 609
 		$this->assertArrayHasKey( 'password', $properties );
610 610
 		$this->assertArrayHasKey( 'avatar_url', $properties );
611 611
 		$this->assertArrayHasKey( 'billing', $properties );
612
-		$this->assertArrayHasKey( 'first_name', $properties['billing']['properties'] );
613
-		$this->assertArrayHasKey( 'last_name', $properties['billing']['properties'] );
614
-		$this->assertArrayHasKey( 'company', $properties['billing']['properties'] );
615
-		$this->assertArrayHasKey( 'address_1', $properties['billing']['properties'] );
616
-		$this->assertArrayHasKey( 'address_2', $properties['billing']['properties'] );
617
-		$this->assertArrayHasKey( 'city', $properties['billing']['properties'] );
618
-		$this->assertArrayHasKey( 'state', $properties['billing']['properties'] );
619
-		$this->assertArrayHasKey( 'postcode', $properties['billing']['properties'] );
620
-		$this->assertArrayHasKey( 'country', $properties['billing']['properties'] );
621
-		$this->assertArrayHasKey( 'email', $properties['billing']['properties'] );
622
-		$this->assertArrayHasKey( 'phone', $properties['billing']['properties'] );
612
+		$this->assertArrayHasKey( 'first_name', $properties[ 'billing' ][ 'properties' ] );
613
+		$this->assertArrayHasKey( 'last_name', $properties[ 'billing' ][ 'properties' ] );
614
+		$this->assertArrayHasKey( 'company', $properties[ 'billing' ][ 'properties' ] );
615
+		$this->assertArrayHasKey( 'address_1', $properties[ 'billing' ][ 'properties' ] );
616
+		$this->assertArrayHasKey( 'address_2', $properties[ 'billing' ][ 'properties' ] );
617
+		$this->assertArrayHasKey( 'city', $properties[ 'billing' ][ 'properties' ] );
618
+		$this->assertArrayHasKey( 'state', $properties[ 'billing' ][ 'properties' ] );
619
+		$this->assertArrayHasKey( 'postcode', $properties[ 'billing' ][ 'properties' ] );
620
+		$this->assertArrayHasKey( 'country', $properties[ 'billing' ][ 'properties' ] );
621
+		$this->assertArrayHasKey( 'email', $properties[ 'billing' ][ 'properties' ] );
622
+		$this->assertArrayHasKey( 'phone', $properties[ 'billing' ][ 'properties' ] );
623 623
 		$this->assertArrayHasKey( 'shipping', $properties );
624
-		$this->assertArrayHasKey( 'first_name', $properties['shipping']['properties'] );
625
-		$this->assertArrayHasKey( 'last_name', $properties['shipping']['properties'] );
626
-		$this->assertArrayHasKey( 'company', $properties['shipping']['properties'] );
627
-		$this->assertArrayHasKey( 'address_1', $properties['shipping']['properties'] );
628
-		$this->assertArrayHasKey( 'address_2', $properties['shipping']['properties'] );
629
-		$this->assertArrayHasKey( 'city', $properties['shipping']['properties'] );
630
-		$this->assertArrayHasKey( 'state', $properties['shipping']['properties'] );
631
-		$this->assertArrayHasKey( 'postcode', $properties['shipping']['properties'] );
632
-		$this->assertArrayHasKey( 'country', $properties['shipping']['properties'] );
624
+		$this->assertArrayHasKey( 'first_name', $properties[ 'shipping' ][ 'properties' ] );
625
+		$this->assertArrayHasKey( 'last_name', $properties[ 'shipping' ][ 'properties' ] );
626
+		$this->assertArrayHasKey( 'company', $properties[ 'shipping' ][ 'properties' ] );
627
+		$this->assertArrayHasKey( 'address_1', $properties[ 'shipping' ][ 'properties' ] );
628
+		$this->assertArrayHasKey( 'address_2', $properties[ 'shipping' ][ 'properties' ] );
629
+		$this->assertArrayHasKey( 'city', $properties[ 'shipping' ][ 'properties' ] );
630
+		$this->assertArrayHasKey( 'state', $properties[ 'shipping' ][ 'properties' ] );
631
+		$this->assertArrayHasKey( 'postcode', $properties[ 'shipping' ][ 'properties' ] );
632
+		$this->assertArrayHasKey( 'country', $properties[ 'shipping' ][ 'properties' ] );
633 633
 	}
634 634
 }
Please login to merge, or discard this patch.
unit-tests/Tests/Version3/functions.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 		$this->http_responder = array( $this, 'mock_http_responses' );
37 37
 
38 38
 		$upload_dir_info       = wp_upload_dir();
39
-		$this->upload_dir_path = $upload_dir_info['path'];
40
-		$this->upload_dir_url  = $upload_dir_info['url'];
39
+		$this->upload_dir_path = $upload_dir_info[ 'path' ];
40
+		$this->upload_dir_url  = $upload_dir_info[ 'url' ];
41 41
 		$this->file_name       = 'Dr1Bczxq4q.png';
42 42
 	}
43 43
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 			'url'  => $this->upload_dir_url . '/' . $this->file_name,
109 109
 			'type' => 'image/png',
110 110
 		);
111
-		$result          = wc_rest_upload_image_from_url( 'http://somedomain.com/' . $this->file_name );
111
+		$result = wc_rest_upload_image_from_url( 'http://somedomain.com/' . $this->file_name );
112 112
 
113 113
 		$this->assertEquals( $expected_result, $result );
114 114
 	}
@@ -232,14 +232,14 @@  discard block
 block discarded – undo
232 232
 		} elseif ( 'http://somedomain.com/invalid-image-2.png' === $url ) {
233 233
 			// image with an unsupported mime type.
234 234
 			// we need to manually copy the file as we are mocking the request. without this an empty file is created.
235
-			copy( Automattic\WooCommerce\RestApi\UnitTests\Bootstrap::instance()->get_dir() . '/data/file.txt', $request['filename'] );
235
+			copy( Automattic\WooCommerce\RestApi\UnitTests\Bootstrap::instance()->get_dir() . '/data/file.txt', $request[ 'filename' ] );
236 236
 
237 237
 			$mocked_response = array(
238 238
 				'response' => array( 'code' => 200 ),
239 239
 			);
240 240
 		} elseif ( 'http://somedomain.com/' . $this->file_name === $url ) {
241 241
 			// we need to manually copy the file as we are mocking the request. without this an empty file is created.
242
-			copy( Automattic\WooCommerce\RestApi\UnitTests\Bootstrap::instance()->get_dir() . '/data/Dr1Bczxq4q.png', $request['filename'] );
242
+			copy( Automattic\WooCommerce\RestApi\UnitTests\Bootstrap::instance()->get_dir() . '/data/Dr1Bczxq4q.png', $request[ 'filename' ] );
243 243
 
244 244
 			$mocked_response = array(
245 245
 				'response' => array( 'code' => 200 ),
Please login to merge, or discard this patch.
unit-tests/Tests/Version3/products.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 		$this->assertEquals( 200, $response->get_status() );
53 53
 
54 54
 		$this->assertEquals( 2, count( $products ) );
55
-		$this->assertEquals( 'Dummy Product', $products[0]['name'] );
56
-		$this->assertEquals( 'DUMMY SKU', $products[0]['sku'] );
57
-		$this->assertEquals( 'Dummy External Product', $products[1]['name'] );
58
-		$this->assertEquals( 'DUMMY EXTERNAL SKU', $products[1]['sku'] );
55
+		$this->assertEquals( 'Dummy Product', $products[ 0 ][ 'name' ] );
56
+		$this->assertEquals( 'DUMMY SKU', $products[ 0 ][ 'sku' ] );
57
+		$this->assertEquals( 'Dummy External Product', $products[ 1 ][ 'name' ] );
58
+		$this->assertEquals( 'DUMMY EXTERNAL SKU', $products[ 1 ][ 'sku' ] );
59 59
 	}
60 60
 
61 61
 	/**
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 		$data         = $response->get_data();
168 168
 		$date_created = date( 'Y-m-d\TH:i:s', current_time( 'timestamp' ) );
169 169
 
170
-		$this->assertEquals( 'DUMMY SKU', $data['sku'] );
171
-		$this->assertEquals( 10, $data['regular_price'] );
172
-		$this->assertEmpty( $data['sale_price'] );
170
+		$this->assertEquals( 'DUMMY SKU', $data[ 'sku' ] );
171
+		$this->assertEquals( 10, $data[ 'regular_price' ] );
172
+		$this->assertEmpty( $data[ 'sale_price' ] );
173 173
 
174 174
 		$request = new WP_REST_Request( 'PUT', '/wc/v3/products/' . $product->get_id() );
175 175
 		$request->set_body_params(
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 		$response = $this->server->dispatch( $request );
191 191
 		$data     = $response->get_data();
192 192
 
193
-		$this->assertContains( 'Testing', $data['description'] );
194
-		$this->assertEquals( '8', $data['price'] );
195
-		$this->assertEquals( '8', $data['sale_price'] );
196
-		$this->assertEquals( '10', $data['regular_price'] );
197
-		$this->assertEquals( 'FIXED-SKU', $data['sku'] );
198
-		$this->assertEquals( $date_created, $data['date_created'] );
199
-		$this->assertContains( 'Dr1Bczxq4q', $data['images'][0]['src'] );
200
-		$this->assertContains( 'test upload image', $data['images'][0]['alt'] );
193
+		$this->assertContains( 'Testing', $data[ 'description' ] );
194
+		$this->assertEquals( '8', $data[ 'price' ] );
195
+		$this->assertEquals( '8', $data[ 'sale_price' ] );
196
+		$this->assertEquals( '10', $data[ 'regular_price' ] );
197
+		$this->assertEquals( 'FIXED-SKU', $data[ 'sku' ] );
198
+		$this->assertEquals( $date_created, $data[ 'date_created' ] );
199
+		$this->assertContains( 'Dr1Bczxq4q', $data[ 'images' ][ 0 ][ 'src' ] );
200
+		$this->assertContains( 'test upload image', $data[ 'images' ][ 0 ][ 'alt' ] );
201 201
 		$product->delete( true );
202 202
 
203 203
 		// test variable product (variations are tested in product-variations.php).
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		$data     = $response->get_data();
207 207
 
208 208
 		foreach ( array( 'small', 'large' ) as $term_name ) {
209
-			$this->assertContains( $term_name, $data['attributes'][0]['options'] );
209
+			$this->assertContains( $term_name, $data[ 'attributes' ][ 0 ][ 'options' ] );
210 210
 		}
211 211
 
212 212
 		$request = new WP_REST_Request( 'PUT', '/wc/v3/products/' . $product->get_id() );
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 		$response = $this->server->dispatch( $request );
239 239
 		$data     = $response->get_data();
240 240
 
241
-		$this->assertEquals( array( 'small' ), $data['attributes'][0]['options'] );
241
+		$this->assertEquals( array( 'small' ), $data[ 'attributes' ][ 0 ][ 'options' ] );
242 242
 
243 243
 		foreach ( array( 'red', 'yellow' ) as $term_name ) {
244
-			$this->assertContains( $term_name, $data['attributes'][1]['options'] );
244
+			$this->assertContains( $term_name, $data[ 'attributes' ][ 1 ][ 'options' ] );
245 245
 		}
246 246
 
247 247
 		$product->delete( true );
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/products/' . $product->get_id() ) );
252 252
 		$data     = $response->get_data();
253 253
 
254
-		$this->assertEquals( 'Buy external product', $data['button_text'] );
255
-		$this->assertEquals( 'http://woocommerce.com', $data['external_url'] );
254
+		$this->assertEquals( 'Buy external product', $data[ 'button_text' ] );
255
+		$this->assertEquals( 'http://woocommerce.com', $data[ 'external_url' ] );
256 256
 
257 257
 		$request = new WP_REST_Request( 'PUT', '/wc/v3/products/' . $product->get_id() );
258 258
 		$request->set_body_params(
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 		$response = $this->server->dispatch( $request );
265 265
 		$data     = $response->get_data();
266 266
 
267
-		$this->assertEquals( 'Test API Update', $data['button_text'] );
268
-		$this->assertEquals( 'http://automattic.com', $data['external_url'] );
267
+		$this->assertEquals( 'Test API Update', $data[ 'button_text' ] );
268
+		$this->assertEquals( 'http://automattic.com', $data[ 'external_url' ] );
269 269
 	}
270 270
 
271 271
 	/**
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		);
320 320
 		$response          = $this->server->dispatch( $request );
321 321
 		$data              = $response->get_data();
322
-		$shipping_class_id = $data['id'];
322
+		$shipping_class_id = $data[ 'id' ];
323 323
 
324 324
 		// Create simple.
325 325
 		$request = new WP_REST_Request( 'POST', '/wc/v3/products' );
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
 		$response = $this->server->dispatch( $request );
336 336
 		$data     = $response->get_data();
337 337
 
338
-		$this->assertEquals( '10', $data['price'] );
339
-		$this->assertEquals( '10', $data['regular_price'] );
340
-		$this->assertTrue( $data['purchasable'] );
341
-		$this->assertEquals( 'DUMMY SKU SIMPLE API', $data['sku'] );
342
-		$this->assertEquals( 'Test Simple Product', $data['name'] );
343
-		$this->assertEquals( 'simple', $data['type'] );
344
-		$this->assertEquals( $shipping_class_id, $data['shipping_class_id'] );
338
+		$this->assertEquals( '10', $data[ 'price' ] );
339
+		$this->assertEquals( '10', $data[ 'regular_price' ] );
340
+		$this->assertTrue( $data[ 'purchasable' ] );
341
+		$this->assertEquals( 'DUMMY SKU SIMPLE API', $data[ 'sku' ] );
342
+		$this->assertEquals( 'Test Simple Product', $data[ 'name' ] );
343
+		$this->assertEquals( 'simple', $data[ 'type' ] );
344
+		$this->assertEquals( $shipping_class_id, $data[ 'shipping_class_id' ] );
345 345
 
346 346
 		// Create external.
347 347
 		$request = new WP_REST_Request( 'POST', '/wc/v3/products' );
@@ -358,14 +358,14 @@  discard block
 block discarded – undo
358 358
 		$response = $this->server->dispatch( $request );
359 359
 		$data     = $response->get_data();
360 360
 
361
-		$this->assertEquals( '10', $data['price'] );
362
-		$this->assertEquals( '10', $data['regular_price'] );
363
-		$this->assertFalse( $data['purchasable'] );
364
-		$this->assertEquals( 'DUMMY SKU EXTERNAL API', $data['sku'] );
365
-		$this->assertEquals( 'Test External Product', $data['name'] );
366
-		$this->assertEquals( 'external', $data['type'] );
367
-		$this->assertEquals( 'Test Button', $data['button_text'] );
368
-		$this->assertEquals( 'https://wordpress.org', $data['external_url'] );
361
+		$this->assertEquals( '10', $data[ 'price' ] );
362
+		$this->assertEquals( '10', $data[ 'regular_price' ] );
363
+		$this->assertFalse( $data[ 'purchasable' ] );
364
+		$this->assertEquals( 'DUMMY SKU EXTERNAL API', $data[ 'sku' ] );
365
+		$this->assertEquals( 'Test External Product', $data[ 'name' ] );
366
+		$this->assertEquals( 'external', $data[ 'type' ] );
367
+		$this->assertEquals( 'Test Button', $data[ 'button_text' ] );
368
+		$this->assertEquals( 'https://wordpress.org', $data[ 'external_url' ] );
369 369
 
370 370
 		// Create variable.
371 371
 		$request = new WP_REST_Request( 'POST', '/wc/v3/products' );
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 		$response = $this->server->dispatch( $request );
392 392
 		$data     = $response->get_data();
393 393
 
394
-		$this->assertEquals( 'DUMMY SKU VARIABLE API', $data['sku'] );
395
-		$this->assertEquals( 'Test Variable Product', $data['name'] );
396
-		$this->assertEquals( 'variable', $data['type'] );
397
-		$this->assertEquals( array( 'small', 'medium' ), $data['attributes'][0]['options'] );
394
+		$this->assertEquals( 'DUMMY SKU VARIABLE API', $data[ 'sku' ] );
395
+		$this->assertEquals( 'Test Variable Product', $data[ 'name' ] );
396
+		$this->assertEquals( 'variable', $data[ 'type' ] );
397
+		$this->assertEquals( array( 'small', 'medium' ), $data[ 'attributes' ][ 0 ][ 'options' ] );
398 398
 
399 399
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/products' ) );
400 400
 		$products = $response->get_data();
@@ -461,13 +461,13 @@  discard block
 block discarded – undo
461 461
 		$response = $this->server->dispatch( $request );
462 462
 		$data     = $response->get_data();
463 463
 
464
-		$this->assertContains( 'Updated description.', $data['update'][0]['description'] );
465
-		$this->assertEquals( 'DUMMY SKU BATCH TEST 1', $data['create'][0]['sku'] );
466
-		$this->assertEquals( 'DUMMY SKU BATCH TEST 2', $data['create'][1]['sku'] );
467
-		$this->assertEquals( 'Test Button', $data['create'][0]['button_text'] );
468
-		$this->assertEquals( 'external', $data['create'][0]['type'] );
469
-		$this->assertEquals( 'simple', $data['create'][1]['type'] );
470
-		$this->assertEquals( $product_2->get_id(), $data['delete'][0]['id'] );
464
+		$this->assertContains( 'Updated description.', $data[ 'update' ][ 0 ][ 'description' ] );
465
+		$this->assertEquals( 'DUMMY SKU BATCH TEST 1', $data[ 'create' ][ 0 ][ 'sku' ] );
466
+		$this->assertEquals( 'DUMMY SKU BATCH TEST 2', $data[ 'create' ][ 1 ][ 'sku' ] );
467
+		$this->assertEquals( 'Test Button', $data[ 'create' ][ 0 ][ 'button_text' ] );
468
+		$this->assertEquals( 'external', $data[ 'create' ][ 0 ][ 'type' ] );
469
+		$this->assertEquals( 'simple', $data[ 'create' ][ 1 ][ 'type' ] );
470
+		$this->assertEquals( $product_2->get_id(), $data[ 'delete' ][ 0 ][ 'id' ] );
471 471
 
472 472
 		$request  = new WP_REST_Request( 'GET', '/wc/v3/products' );
473 473
 		$response = $this->server->dispatch( $request );
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 
505 505
 		$this->assertEquals( 4, count( $products ) );
506 506
 		foreach ( $products as $product ) {
507
-			$this->assertEquals( 'publish', $product['status'] );
507
+			$this->assertEquals( 'publish', $product[ 'status' ] );
508 508
 		}
509 509
 
510 510
 		// Test filtering with status=draft.
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 
516 516
 		$this->assertEquals( 4, count( $products ) );
517 517
 		foreach ( $products as $product ) {
518
-			$this->assertEquals( 'draft', $product['status'] );
518
+			$this->assertEquals( 'draft', $product[ 'status' ] );
519 519
 		}
520 520
 
521 521
 		// Test filtering with no filters - which should return 'any' (all 8).
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v3/products/' . $product->get_id() );
538 538
 		$response   = $this->server->dispatch( $request );
539 539
 		$data       = $response->get_data();
540
-		$properties = $data['schema']['properties'];
540
+		$properties = $data[ 'schema' ][ 'properties' ];
541 541
 		$this->assertEquals( 65, count( $properties ) );
542 542
 	}
543 543
 
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 		$category = wp_insert_term( 'Some Category', 'product_cat' );
554 554
 
555 555
 		$product = new WC_Product_Simple();
556
-		$product->set_category_ids( array( $category['term_id'] ) );
556
+		$product->set_category_ids( array( $category[ 'term_id' ] ) );
557 557
 		$product->save();
558 558
 
559 559
 		// Create one product without category, i.e. Uncategorized.
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 
563 563
 		// Test product assigned to a single category.
564 564
 		$query_params = array(
565
-			'category' => (string) $category['term_id'],
565
+			'category' => (string) $category[ 'term_id' ],
566 566
 		);
567 567
 		$request      = new WP_REST_Request( 'GET', '/wc/v2/products' );
568 568
 		$request->set_query_params( $query_params );
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
 
572 572
 		$this->assertEquals( 200, $response->get_status() );
573 573
 		foreach ( $response_products as $response_product ) {
574
-			$this->assertEquals( $product->get_id(), $response_product['id'] );
575
-			$this->assertEquals( $product->get_category_ids(), wp_list_pluck( $response_product['categories'], 'id' ) );
574
+			$this->assertEquals( $product->get_id(), $response_product[ 'id' ] );
575
+			$this->assertEquals( $product->get_category_ids(), wp_list_pluck( $response_product[ 'categories' ], 'id' ) );
576 576
 		}
577 577
 
578 578
 		// Test product without categories.
@@ -581,8 +581,8 @@  discard block
 block discarded – undo
581 581
 		$response_product = $response->get_data();
582 582
 
583 583
 		$this->assertEquals( 200, $response->get_status() );
584
-		$this->assertCount( 1, $response_product['categories'], print_r( $response_product, true ) );
585
-		$this->assertEquals( 'uncategorized', $response_product['categories'][0]['slug'] );
584
+		$this->assertCount( 1, $response_product[ 'categories' ], print_r( $response_product, true ) );
585
+		$this->assertEquals( 'uncategorized', $response_product[ 'categories' ][ 0 ][ 'slug' ] );
586 586
 
587 587
 	}
588 588
 
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 		);
608 608
 
609 609
 		foreach ( $grouped->get_children() as $additional_product ) {
610
-			$product_ids_for_type['simple'][] = $additional_product;
610
+			$product_ids_for_type[ 'simple' ][ ] = $additional_product;
611 611
 		}
612 612
 
613 613
 		foreach ( $product_ids_for_type as $product_type => $product_ids ) {
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 			$this->assertEquals( 200, $response->get_status() );
623 623
 			$this->assertEquals( count( $product_ids ), count( $response_products ) );
624 624
 			foreach ( $response_products as $response_product ) {
625
-				$this->assertContains( $response_product['id'], $product_ids_for_type[ $product_type ], 'REST API: ' . $product_type . ' not found correctly' );
625
+				$this->assertContains( $response_product[ 'id' ], $product_ids_for_type[ $product_type ], 'REST API: ' . $product_type . ' not found correctly' );
626 626
 			}
627 627
 		}
628 628
 	}
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 
655 655
 		$this->assertEquals( 200, $response->get_status() );
656 656
 		foreach ( $response_products as $response_product ) {
657
-			$this->assertEquals( $feat_product->get_id(), $response_product['id'], 'REST API: Featured product not found correctly' );
657
+			$this->assertEquals( $feat_product->get_id(), $response_product[ 'id' ], 'REST API: Featured product not found correctly' );
658 658
 		}
659 659
 
660 660
 		$query_params = array(
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 
668 668
 		$this->assertEquals( 200, $response->get_status() );
669 669
 		foreach ( $response_products as $response_product ) {
670
-			$this->assertEquals( $nonfeat_product->get_id(), $response_product['id'], 'REST API: Featured product not found correctly' );
670
+			$this->assertEquals( $nonfeat_product->get_id(), $response_product[ 'id' ], 'REST API: Featured product not found correctly' );
671 671
 		}
672 672
 	}
673 673
 
@@ -682,11 +682,11 @@  discard block
 block discarded – undo
682 682
 		$shipping_class_1 = wp_insert_term( 'Bulky', 'product_shipping_class' );
683 683
 
684 684
 		$product_1 = new WC_Product_Simple();
685
-		$product_1->set_shipping_class_id( $shipping_class_1['term_id'] );
685
+		$product_1->set_shipping_class_id( $shipping_class_1[ 'term_id' ] );
686 686
 		$product_1->save();
687 687
 
688 688
 		$query_params = array(
689
-			'shipping_class' => (string) $shipping_class_1['term_id'],
689
+			'shipping_class' => (string) $shipping_class_1[ 'term_id' ],
690 690
 		);
691 691
 		$request      = new WP_REST_Request( 'GET', '/wc/v2/products' );
692 692
 		$request->set_query_params( $query_params );
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 
696 696
 		$this->assertEquals( 200, $response->get_status() );
697 697
 		foreach ( $response_products as $response_product ) {
698
-			$this->assertEquals( $product_1->get_id(), $response_product['id'] );
698
+			$this->assertEquals( $product_1->get_id(), $response_product[ 'id' ] );
699 699
 		}
700 700
 	}
701 701
 
@@ -711,14 +711,14 @@  discard block
 block discarded – undo
711 711
 
712 712
 		// Product with a tag.
713 713
 		$product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_simple_product();
714
-		$product->set_tag_ids( array( $test_tag_1['term_id'] ) );
714
+		$product->set_tag_ids( array( $test_tag_1[ 'term_id' ] ) );
715 715
 		$product->save();
716 716
 
717 717
 		// Product without a tag.
718 718
 		$product_2 = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_simple_product();
719 719
 
720 720
 		$query_params = array(
721
-			'tag' => (string) $test_tag_1['term_id'],
721
+			'tag' => (string) $test_tag_1[ 'term_id' ],
722 722
 		);
723 723
 		$request      = new WP_REST_Request( 'GET', '/wc/v2/products' );
724 724
 		$request->set_query_params( $query_params );
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 
728 728
 		$this->assertEquals( 200, $response->get_status() );
729 729
 		foreach ( $response_products as $response_product ) {
730
-			$this->assertEquals( $product->get_id(), $response_product['id'] );
730
+			$this->assertEquals( $product->get_id(), $response_product[ 'id' ] );
731 731
 		}
732 732
 	}
733 733
 
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 			$variable_product->get_id(),
771 771
 			$product_2->get_id(),
772 772
 		);
773
-		$query_params         = array(
773
+		$query_params = array(
774 774
 			'attribute'      => 'pa_size',
775 775
 			'attribute_term' => (string) $term_large->term_id,
776 776
 		);
777
-		$request              = new WP_REST_Request( 'GET', '/wc/v2/products' );
777
+		$request = new WP_REST_Request( 'GET', '/wc/v2/products' );
778 778
 		$request->set_query_params( $query_params );
779 779
 		$response          = $this->server->dispatch( $request );
780 780
 		$response_products = $response->get_data();
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 		$this->assertEquals( 200, $response->get_status() );
783 783
 		$this->assertEquals( count( $expected_product_ids ), count( $response_products ) );
784 784
 		foreach ( $response_products as $response_product ) {
785
-			$this->assertContains( $response_product['id'], $expected_product_ids );
785
+			$this->assertContains( $response_product[ 'id' ], $expected_product_ids );
786 786
 		}
787 787
 
788 788
 		// Products with attribute size == small.
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 			'attribute'      => 'pa_size',
794 794
 			'attribute_term' => (string) $term_small->term_id,
795 795
 		);
796
-		$request              = new WP_REST_Request( 'GET', '/wc/v2/products' );
796
+		$request = new WP_REST_Request( 'GET', '/wc/v2/products' );
797 797
 		$request->set_query_params( $query_params );
798 798
 		$response          = $this->server->dispatch( $request );
799 799
 		$response_products = $response->get_data();
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 		$this->assertEquals( 200, $response->get_status() );
802 802
 		$this->assertEquals( count( $expected_product_ids ), count( $response_products ) );
803 803
 		foreach ( $response_products as $response_product ) {
804
-			$this->assertContains( $response_product['id'], $expected_product_ids );
804
+			$this->assertContains( $response_product[ 'id' ], $expected_product_ids );
805 805
 		}
806 806
 	}
807 807
 }
Please login to merge, or discard this patch.
unit-tests/Tests/Version3/payment-gateways.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/payment_gateways/paypal' ) );
163 163
 		$paypal   = $response->get_data();
164 164
 
165
-		$this->assertEquals( 'PayPal', $paypal['settings']['title']['value'] );
166
-		$this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] );
167
-		$this->assertEquals( 'no', $paypal['settings']['testmode']['value'] );
165
+		$this->assertEquals( 'PayPal', $paypal[ 'settings' ][ 'title' ][ 'value' ] );
166
+		$this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] );
167
+		$this->assertEquals( 'no', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] );
168 168
 
169 169
 		// test updating single setting
170 170
 		$request = new WP_REST_Request( 'POST', '/wc/v3/payment_gateways/paypal' );
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 		$paypal   = $response->get_data();
180 180
 
181 181
 		$this->assertEquals( 200, $response->get_status() );
182
-		$this->assertEquals( 'PayPal', $paypal['settings']['title']['value'] );
183
-		$this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] );
184
-		$this->assertEquals( 'no', $paypal['settings']['testmode']['value'] );
182
+		$this->assertEquals( 'PayPal', $paypal[ 'settings' ][ 'title' ][ 'value' ] );
183
+		$this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] );
184
+		$this->assertEquals( 'no', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] );
185 185
 
186 186
 		// test updating multiple settings
187 187
 		$request = new WP_REST_Request( 'POST', '/wc/v3/payment_gateways/paypal' );
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 		$paypal   = $response->get_data();
198 198
 
199 199
 		$this->assertEquals( 200, $response->get_status() );
200
-		$this->assertEquals( 'PayPal - New Title', $paypal['settings']['title']['value'] );
201
-		$this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] );
202
-		$this->assertEquals( 'yes', $paypal['settings']['testmode']['value'] );
200
+		$this->assertEquals( 'PayPal - New Title', $paypal[ 'settings' ][ 'title' ][ 'value' ] );
201
+		$this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] );
202
+		$this->assertEquals( 'yes', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] );
203 203
 
204 204
 		// Test other parameters, and recheck settings
205 205
 		$request = new WP_REST_Request( 'POST', '/wc/v3/payment_gateways/paypal' );
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 		$response = $this->server->dispatch( $request );
213 213
 		$paypal   = $response->get_data();
214 214
 
215
-		$this->assertFalse( $paypal['enabled'] );
216
-		$this->assertEquals( 2, $paypal['order'] );
217
-		$this->assertEquals( 'PayPal - New Title', $paypal['settings']['title']['value'] );
218
-		$this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] );
219
-		$this->assertEquals( 'yes', $paypal['settings']['testmode']['value'] );
215
+		$this->assertFalse( $paypal[ 'enabled' ] );
216
+		$this->assertEquals( 2, $paypal[ 'order' ] );
217
+		$this->assertEquals( 'PayPal - New Title', $paypal[ 'settings' ][ 'title' ][ 'value' ] );
218
+		$this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] );
219
+		$this->assertEquals( 'yes', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] );
220 220
 
221 221
 		// test bogus
222 222
 		$request = new WP_REST_Request( 'POST', '/wc/v3/payment_gateways/paypal' );
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		);
241 241
 		$response = $this->server->dispatch( $request );
242 242
 		$paypal   = $response->get_data();
243
-		$this->assertEquals( 'authorization', $paypal['settings']['paymentaction']['value'] );
243
+		$this->assertEquals( 'authorization', $paypal[ 'settings' ][ 'paymentaction' ][ 'value' ] );
244 244
 	}
245 245
 
246 246
 	/**
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v3/payment_gateways' );
292 292
 		$response   = $this->server->dispatch( $request );
293 293
 		$data       = $response->get_data();
294
-		$properties = $data['schema']['properties'];
294
+		$properties = $data[ 'schema' ][ 'properties' ];
295 295
 
296 296
 		$this->assertEquals( 9, count( $properties ) );
297 297
 		$this->assertArrayHasKey( 'id', $properties );
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		$gateway->init_form_fields();
318 318
 		foreach ( $gateway->form_fields as $id => $field ) {
319 319
 			// Make sure we at least have a title and type
320
-			if ( empty( $field['title'] ) || empty( $field['type'] ) ) {
320
+			if ( empty( $field[ 'title' ] ) || empty( $field[ 'type' ] ) ) {
321 321
 				continue;
322 322
 			}
323 323
 			// Ignore 'enabled' and 'description', to be in line with \WC_REST_Payment_Gateways_Controller::get_settings.
@@ -326,16 +326,16 @@  discard block
 block discarded – undo
326 326
 			}
327 327
 			$data = array(
328 328
 				'id'          => $id,
329
-				'label'       => empty( $field['label'] ) ? $field['title'] : $field['label'],
330
-				'description' => empty( $field['description'] ) ? '' : $field['description'],
331
-				'type'        => $field['type'],
329
+				'label'       => empty( $field[ 'label' ] ) ? $field[ 'title' ] : $field[ 'label' ],
330
+				'description' => empty( $field[ 'description' ] ) ? '' : $field[ 'description' ],
331
+				'type'        => $field[ 'type' ],
332 332
 				'value'       => $gateway->settings[ $id ],
333
-				'default'     => empty( $field['default'] ) ? '' : $field['default'],
334
-				'tip'         => empty( $field['description'] ) ? '' : $field['description'],
335
-				'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'],
333
+				'default'     => empty( $field[ 'default' ] ) ? '' : $field[ 'default' ],
334
+				'tip'         => empty( $field[ 'description' ] ) ? '' : $field[ 'description' ],
335
+				'placeholder' => empty( $field[ 'placeholder' ] ) ? '' : $field[ 'placeholder' ],
336 336
 			);
337
-			if ( ! empty( $field['options'] ) ) {
338
-				$data['options'] = $field['options'];
337
+			if ( ! empty( $field[ 'options' ] ) ) {
338
+				$data[ 'options' ] = $field[ 'options' ];
339 339
 			}
340 340
 			$settings[ $id ] = $data;
341 341
 		}
Please login to merge, or discard this patch.
unit-tests/Tests/Version3/shipping-methods.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@
 block discarded – undo
133 133
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v3/shipping_methods' );
134 134
 		$response   = $this->server->dispatch( $request );
135 135
 		$data       = $response->get_data();
136
-		$properties = $data['schema']['properties'];
136
+		$properties = $data[ 'schema' ][ 'properties' ];
137 137
 
138 138
 		$this->assertEquals( 3, count( $properties ) );
139 139
 		$this->assertArrayHasKey( 'id', $properties );
Please login to merge, or discard this patch.
unit-tests/Tests/Version3/system-status.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
 		wp_set_current_user( $this->user );
80 80
 		$response    = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/system_status' ) );
81 81
 		$data        = $response->get_data();
82
-		$environment = (array) $data['environment'];
82
+		$environment = (array) $data[ 'environment' ];
83 83
 
84 84
 		// Make sure all expected data is present.
85 85
 		$this->assertEquals( 32, count( $environment ) );
86 86
 
87 87
 		// Test some responses to make sure they match up.
88
-		$this->assertEquals( get_option( 'home' ), $environment['home_url'] );
89
-		$this->assertEquals( get_option( 'siteurl' ), $environment['site_url'] );
90
-		$this->assertEquals( WC()->version, $environment['version'] );
88
+		$this->assertEquals( get_option( 'home' ), $environment[ 'home_url' ] );
89
+		$this->assertEquals( get_option( 'siteurl' ), $environment[ 'site_url' ] );
90
+		$this->assertEquals( WC()->version, $environment[ 'version' ] );
91 91
 	}
92 92
 
93 93
 	/**
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 		wp_set_current_user( $this->user );
101 101
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/system_status' ) );
102 102
 		$data     = $response->get_data();
103
-		$database = (array) $data['database'];
103
+		$database = (array) $data[ 'database' ];
104 104
 
105
-		$this->assertEquals( get_option( 'woocommerce_db_version' ), $database['wc_database_version'] );
106
-		$this->assertEquals( $wpdb->prefix, $database['database_prefix'] );
107
-		$this->assertEquals( WC_Geolocation::get_local_database_path(), $database['maxmind_geoip_database'] );
108
-		$this->assertArrayHasKey( 'woocommerce', $database['database_tables'], wc_print_r( $database, true ) );
109
-		$this->assertArrayHasKey( $wpdb->prefix . 'woocommerce_payment_tokens', $database['database_tables']['woocommerce'], wc_print_r( $database, true ) );
105
+		$this->assertEquals( get_option( 'woocommerce_db_version' ), $database[ 'wc_database_version' ] );
106
+		$this->assertEquals( $wpdb->prefix, $database[ 'database_prefix' ] );
107
+		$this->assertEquals( WC_Geolocation::get_local_database_path(), $database[ 'maxmind_geoip_database' ] );
108
+		$this->assertArrayHasKey( 'woocommerce', $database[ 'database_tables' ], wc_print_r( $database, true ) );
109
+		$this->assertArrayHasKey( $wpdb->prefix . 'woocommerce_payment_tokens', $database[ 'database_tables' ][ 'woocommerce' ], wc_print_r( $database, true ) );
110 110
 	}
111 111
 
112 112
 	/**
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 		update_option( 'active_plugins', array() );
124 124
 
125 125
 		$data    = $response->get_data();
126
-		$plugins = (array) $data['active_plugins'];
126
+		$plugins = (array) $data[ 'active_plugins' ];
127 127
 
128 128
 		$this->assertEquals( 1, count( $plugins ) );
129
-		$this->assertEquals( 'Hello Dolly', $plugins[0]['name'] );
129
+		$this->assertEquals( 'Hello Dolly', $plugins[ 0 ][ 'name' ] );
130 130
 	}
131 131
 
132 132
 	/**
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 
141 141
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/system_status' ) );
142 142
 		$data     = $response->get_data();
143
-		$theme    = (array) $data['theme'];
143
+		$theme    = (array) $data[ 'theme' ];
144 144
 
145 145
 		$this->assertEquals( 13, count( $theme ) );
146
-		$this->assertEquals( $active_theme->Name, $theme['name'] ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
146
+		$this->assertEquals( $active_theme->Name, $theme[ 'name' ] ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
147 147
 	}
148 148
 
149 149
 	/**
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
 
163 163
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/system_status' ) );
164 164
 		$data     = $response->get_data();
165
-		$settings = (array) $data['settings'];
165
+		$settings = (array) $data[ 'settings' ];
166 166
 
167 167
 		$this->assertEquals( 12, count( $settings ) );
168
-		$this->assertEquals( ( 'yes' === get_option( 'woocommerce_api_enabled' ) ), $settings['api_enabled'] );
169
-		$this->assertEquals( get_woocommerce_currency(), $settings['currency'] );
170
-		$this->assertEquals( $term_response, $settings['taxonomies'] );
168
+		$this->assertEquals( ( 'yes' === get_option( 'woocommerce_api_enabled' ) ), $settings[ 'api_enabled' ] );
169
+		$this->assertEquals( get_woocommerce_currency(), $settings[ 'currency' ] );
170
+		$this->assertEquals( $term_response, $settings[ 'taxonomies' ] );
171 171
 	}
172 172
 
173 173
 	/**
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 
181 181
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/system_status' ) );
182 182
 		$data     = $response->get_data();
183
-		$settings = (array) $data['security'];
183
+		$settings = (array) $data[ 'security' ];
184 184
 
185 185
 		$this->assertEquals( 2, count( $settings ) );
186
-		$this->assertEquals( 'https' === substr( wc_get_page_permalink( 'shop' ), 0, 5 ), $settings['secure_connection'] );
187
-		$this->assertEquals( ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), $settings['hide_errors'] );
186
+		$this->assertEquals( 'https' === substr( wc_get_page_permalink( 'shop' ), 0, 5 ), $settings[ 'secure_connection' ] );
187
+		$this->assertEquals( ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), $settings[ 'hide_errors' ] );
188 188
 	}
189 189
 
190 190
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		wp_set_current_user( $this->user );
197 197
 		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/system_status' ) );
198 198
 		$data     = $response->get_data();
199
-		$pages    = $data['pages'];
199
+		$pages    = $data[ 'pages' ];
200 200
 		$this->assertEquals( 5, count( $pages ) );
201 201
 	}
202 202
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v3/system_status' );
210 210
 		$response   = $this->server->dispatch( $request );
211 211
 		$data       = $response->get_data();
212
-		$properties = $data['schema']['properties'];
212
+		$properties = $data[ 'schema' ][ 'properties' ];
213 213
 		$this->assertEquals( 9, count( $properties ) );
214 214
 		$this->assertArrayHasKey( 'environment', $properties );
215 215
 		$this->assertArrayHasKey( 'database', $properties );
@@ -307,17 +307,17 @@  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( 'GET', '/wc/v3/system_status/tools/recount_terms' ) );
313 313
 		$data     = $response->get_data();
314 314
 
315 315
 		$this->assertEquals( 200, $response->get_status() );
316 316
 
317
-		$this->assertEquals( 'recount_terms', $data['id'] );
318
-		$this->assertEquals( 'Term counts', $data['name'] );
319
-		$this->assertEquals( 'Recount terms', $data['action'] );
320
-		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data['description'] );
317
+		$this->assertEquals( 'recount_terms', $data[ 'id' ] );
318
+		$this->assertEquals( 'Term counts', $data[ 'name' ] );
319
+		$this->assertEquals( 'Recount terms', $data[ 'action' ] );
320
+		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data[ 'description' ] );
321 321
 
322 322
 		// Test for _fields query parameter.
323 323
 		$query_params = array(
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
 
331 331
 		$this->assertEquals( 200, $response->get_status() );
332 332
 
333
-		$this->assertEquals( 'recount_terms', $data['id'] );
334
-		$this->assertEquals( 'Term counts', $data['name'] );
333
+		$this->assertEquals( 'recount_terms', $data[ 'id' ] );
334
+		$this->assertEquals( 'Term counts', $data[ 'name' ] );
335 335
 		$this->assertArrayNotHasKey( 'action', $data );
336 336
 		$this->assertArrayNotHasKey( 'description', $data );
337 337
 		// Links are part of links, not data in single items.
@@ -363,16 +363,16 @@  discard block
 block discarded – undo
363 363
 
364 364
 		$tools_controller = new WC_REST_System_Status_Tools_Controller();
365 365
 		$raw_tools        = $tools_controller->get_tools();
366
-		$raw_tool         = $raw_tools['recount_terms'];
366
+		$raw_tool         = $raw_tools[ 'recount_terms' ];
367 367
 
368 368
 		$response = $this->server->dispatch( new WP_REST_Request( 'POST', '/wc/v3/system_status/tools/recount_terms' ) );
369 369
 		$data     = $response->get_data();
370 370
 
371
-		$this->assertEquals( 'recount_terms', $data['id'] );
372
-		$this->assertEquals( 'Term counts', $data['name'] );
373
-		$this->assertEquals( 'Recount terms', $data['action'] );
374
-		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data['description'] );
375
-		$this->assertTrue( $data['success'] );
371
+		$this->assertEquals( 'recount_terms', $data[ 'id' ] );
372
+		$this->assertEquals( 'Term counts', $data[ 'name' ] );
373
+		$this->assertEquals( 'Recount terms', $data[ 'action' ] );
374
+		$this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data[ 'description' ] );
375
+		$this->assertTrue( $data[ 'success' ] );
376 376
 		$this->assertEquals( 1, did_action( 'woocommerce_rest_insert_system_status_tool' ) );
377 377
 
378 378
 		$response = $this->server->dispatch( new WP_REST_Request( 'POST', '/wc/v3/system_status/tools/not_a_real_tool' ) );
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
 		$data     = $response->get_data();
389 389
 
390 390
 		$this->assertEquals( 200, $response->get_status() );
391
-		$this->assertEquals( 'recount_terms', $data['id'] );
392
-		$this->assertTrue( $data['success'] );
391
+		$this->assertEquals( 'recount_terms', $data[ 'id' ] );
392
+		$this->assertTrue( $data[ 'success' ] );
393 393
 
394 394
 		// Fields that are not requested are not returned in response.
395 395
 		$this->assertArrayNotHasKey( 'action', $data );
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v3/system_status/tools' );
426 426
 		$response   = $this->server->dispatch( $request );
427 427
 		$data       = $response->get_data();
428
-		$properties = $data['schema']['properties'];
428
+		$properties = $data[ 'schema' ][ 'properties' ];
429 429
 
430 430
 		$this->assertEquals( 6, count( $properties ) );
431 431
 		$this->assertArrayHasKey( 'id', $properties );
Please login to merge, or discard this patch.
unit-tests/Tests/Version3/reports-reviews-totals.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 		);
52 52
 
53 53
 		for ( $i = 1; $i <= 5; $i++ ) {
54
-			$query_data['meta_value'] = $i;
54
+			$query_data[ 'meta_value' ] = $i;
55 55
 
56
-			$data[] = array(
56
+			$data[ ] = array(
57 57
 				'slug'  => 'rated_' . $i . '_out_of_5',
58 58
 				/* translators: %s: average rating */
59 59
 				'name'  => sprintf( __( 'Rated %s out of 5', 'woocommerce' ), $i ),
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v3/reports/reviews/totals' );
89 89
 		$response   = $this->server->dispatch( $request );
90 90
 		$data       = $response->get_data();
91
-		$properties = $data['schema']['properties'];
91
+		$properties = $data[ 'schema' ][ 'properties' ];
92 92
 
93 93
 		$this->assertEquals( 3, count( $properties ) );
94 94
 		$this->assertArrayHasKey( 'slug', $properties );
Please login to merge, or discard this patch.