@@ -158,9 +158,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 ) ); |
@@ -185,22 +185,22 @@ discard block |
||
| 185 | 185 | ), |
| 186 | 186 | ]; |
| 187 | 187 | $response = $this->do_request( '/wc/v4/orders', 'POST', $data ); |
| 188 | - $order = wc_get_order( $response->data['id'] ); |
|
| 188 | + $order = wc_get_order( $response->data[ 'id' ] ); |
|
| 189 | 189 | $this->assertExpectedResponse( $response, 201 ); |
| 190 | - $this->assertEquals( $order->get_payment_method(), $response->data['payment_method'] ); |
|
| 190 | + $this->assertEquals( $order->get_payment_method(), $response->data[ 'payment_method' ] ); |
|
| 191 | 191 | $this->assertEquals( $order->get_payment_method_title(), 'Sanitize this' ); |
| 192 | 192 | |
| 193 | 193 | // Test when updating order. |
| 194 | 194 | $response = $this->do_request( |
| 195 | - '/wc/v4/orders/' . $response->data['id'], |
|
| 195 | + '/wc/v4/orders/' . $response->data[ 'id' ], |
|
| 196 | 196 | 'POST', [ |
| 197 | 197 | 'payment_method' => 'bacs', |
| 198 | 198 | 'payment_method_title' => '<h1>Sanitize this too <script>alert(1);</script></h1>', |
| 199 | 199 | ] |
| 200 | 200 | ); |
| 201 | - $order = wc_get_order( $response->data['id'] ); |
|
| 201 | + $order = wc_get_order( $response->data[ 'id' ] ); |
|
| 202 | 202 | $this->assertExpectedResponse( $response, 200 ); |
| 203 | - $this->assertEquals( $order->get_payment_method(), $response->data['payment_method'] ); |
|
| 203 | + $this->assertEquals( $order->get_payment_method(), $response->data[ 'payment_method' ] ); |
|
| 204 | 204 | $this->assertEquals( $order->get_payment_method_title(), 'Sanitize this too' ); |
| 205 | 205 | } |
| 206 | 206 | |
@@ -259,25 +259,25 @@ discard block |
||
| 259 | 259 | * Test read. |
| 260 | 260 | */ |
| 261 | 261 | public function test_read() { |
| 262 | - $product = ProductHelper::create_simple_product(); |
|
| 262 | + $product = ProductHelper::create_simple_product(); |
|
| 263 | 263 | $product->set_regular_price( 10.95 ); |
| 264 | 264 | $product->set_sale_price( false ); |
| 265 | 265 | $product->save(); |
| 266 | 266 | $customer = CustomerHelper::create_customer(); |
| 267 | - $orders = []; |
|
| 268 | - $orders[] = OrderHelper::create_order( $customer->get_id(), $product ); |
|
| 267 | + $orders = [ ]; |
|
| 268 | + $orders[ ] = OrderHelper::create_order( $customer->get_id(), $product ); |
|
| 269 | 269 | |
| 270 | 270 | // Create orders. |
| 271 | 271 | for ( $i = 0; $i < 9; $i++ ) { |
| 272 | - $orders[] = OrderHelper::create_order( $this->user ); |
|
| 272 | + $orders[ ] = OrderHelper::create_order( $this->user ); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - $orders[5]->set_status( 'on-hold' ); |
|
| 276 | - $orders[5]->save(); |
|
| 277 | - $orders[6]->set_status( 'on-hold' ); |
|
| 278 | - $orders[6]->save(); |
|
| 279 | - $orders[0]->calculate_totals(); |
|
| 280 | - $orders[0]->save(); |
|
| 275 | + $orders[ 5 ]->set_status( 'on-hold' ); |
|
| 276 | + $orders[ 5 ]->save(); |
|
| 277 | + $orders[ 6 ]->set_status( 'on-hold' ); |
|
| 278 | + $orders[ 6 ]->save(); |
|
| 279 | + $orders[ 0 ]->calculate_totals(); |
|
| 280 | + $orders[ 0 ]->save(); |
|
| 281 | 281 | |
| 282 | 282 | // Collection. |
| 283 | 283 | $response = $this->do_request( '/wc/v4/orders', 'GET' ); |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $this->assertExpectedResponse( $response, 200 ); |
| 290 | 290 | $this->assertEquals( 2, count( $response->data ) ); |
| 291 | 291 | |
| 292 | - $response = $this->do_request( '/wc/v4/orders', 'GET', [ 'number' => (string) $orders[0]->get_id() ] ); |
|
| 292 | + $response = $this->do_request( '/wc/v4/orders', 'GET', [ 'number' => (string) $orders[ 0 ]->get_id() ] ); |
|
| 293 | 293 | $this->assertExpectedResponse( $response, 200 ); |
| 294 | 294 | $this->assertEquals( 1, count( $response->data ) ); |
| 295 | 295 | |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | $this->assertEquals( 1, count( $response->data ) ); |
| 303 | 303 | |
| 304 | 304 | // Single collection args. |
| 305 | - $response = $this->do_request( '/wc/v4/orders/' . $orders[0]->get_id(), 'GET', [ 'dp' => 0 ] ); |
|
| 306 | - $this->assertEquals( '54', $response->data['total'] ); |
|
| 307 | - $response = $this->do_request( '/wc/v4/orders/' . $orders[0]->get_id(), 'GET', [ 'dp' => 2 ] ); |
|
| 308 | - $this->assertEquals( '53.80', $response->data['total'] ); |
|
| 305 | + $response = $this->do_request( '/wc/v4/orders/' . $orders[ 0 ]->get_id(), 'GET', [ 'dp' => 0 ] ); |
|
| 306 | + $this->assertEquals( '54', $response->data[ 'total' ] ); |
|
| 307 | + $response = $this->do_request( '/wc/v4/orders/' . $orders[ 0 ]->get_id(), 'GET', [ 'dp' => 2 ] ); |
|
| 308 | + $this->assertEquals( '53.80', $response->data[ 'total' ] ); |
|
| 309 | 309 | |
| 310 | 310 | // Single. |
| 311 | - $response = $this->do_request( '/wc/v4/orders/' . $orders[0]->get_id(), 'GET' ); |
|
| 311 | + $response = $this->do_request( '/wc/v4/orders/' . $orders[ 0 ]->get_id(), 'GET' ); |
|
| 312 | 312 | $this->assertExpectedResponse( $response, 200 ); |
| 313 | 313 | |
| 314 | 314 | foreach ( $this->get_properties( 'view' ) as $property ) { |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | ] |
| 481 | 481 | ); |
| 482 | 482 | $this->assertEquals( 400, $response->status ); |
| 483 | - $this->assertEquals( 'Invalid parameter(s): status', $response->data['message'] ); |
|
| 483 | + $this->assertEquals( 'Invalid parameter(s): status', $response->data[ 'message' ] ); |
|
| 484 | 484 | |
| 485 | 485 | $response = $this->do_request( |
| 486 | 486 | '/wc/v4/orders/' . $order->get_id(), |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | ] |
| 491 | 491 | ); |
| 492 | 492 | $this->assertEquals( 400, $response->status ); |
| 493 | - $this->assertEquals( 'Invalid parameter(s): currency', $response->data['message'] ); |
|
| 493 | + $this->assertEquals( 'Invalid parameter(s): currency', $response->data[ 'message' ] ); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |
@@ -517,9 +517,9 @@ discard block |
||
| 517 | 517 | ), |
| 518 | 518 | ) |
| 519 | 519 | ); |
| 520 | - $this->assertEquals( 'updated', $result->data['update'][0]['payment_method'] ); |
|
| 521 | - $this->assertEquals( $order2->get_id(), $result->data['delete'][0]['previous']['id'] ); |
|
| 522 | - $this->assertEquals( $order3->get_id(), $result->data['delete'][1]['previous']['id'] ); |
|
| 520 | + $this->assertEquals( 'updated', $result->data[ 'update' ][ 0 ][ 'payment_method' ] ); |
|
| 521 | + $this->assertEquals( $order2->get_id(), $result->data[ 'delete' ][ 0 ][ 'previous' ][ 'id' ] ); |
|
| 522 | + $this->assertEquals( $order3->get_id(), $result->data[ 'delete' ][ 1 ][ 'previous' ][ 'id' ] ); |
|
| 523 | 523 | |
| 524 | 524 | $result = $this->do_request( '/wc/v4/orders' ); |
| 525 | 525 | $this->assertEquals( 1, count( $result->data ) ); |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | ] |
| 559 | 559 | ); |
| 560 | 560 | $this->assertEquals( 200, $response->status ); |
| 561 | - $this->assertTrue( empty( $response->data['fee_lines'] ) ); |
|
| 561 | + $this->assertTrue( empty( $response->data[ 'fee_lines' ] ) ); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | /** |
@@ -585,8 +585,8 @@ discard block |
||
| 585 | 585 | ] |
| 586 | 586 | ); |
| 587 | 587 | $this->assertEquals( 200, $response->status ); |
| 588 | - $this->assertCount( 1, $response->data['coupon_lines'] ); |
|
| 589 | - $this->assertEquals( '45.00', $response->data['total'] ); |
|
| 588 | + $this->assertCount( 1, $response->data[ 'coupon_lines' ] ); |
|
| 589 | + $this->assertEquals( '45.00', $response->data[ 'total' ] ); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | /** |
@@ -627,8 +627,8 @@ discard block |
||
| 627 | 627 | ] |
| 628 | 628 | ); |
| 629 | 629 | $this->assertEquals( 200, $response->status ); |
| 630 | - $this->assertTrue( empty( $response->data['coupon_lines'] ) ); |
|
| 631 | - $this->assertEquals( '50.00', $response->data['total'] ); |
|
| 630 | + $this->assertTrue( empty( $response->data[ 'coupon_lines' ] ) ); |
|
| 631 | + $this->assertEquals( '50.00', $response->data[ 'total' ] ); |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | /** |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | ] |
| 651 | 651 | ); |
| 652 | 652 | $this->assertEquals( 400, $response->status ); |
| 653 | - $this->assertEquals( 'woocommerce_rest_invalid_coupon', $response->data['code'] ); |
|
| 654 | - $this->assertEquals( 'Coupon "non_existing_coupon" does not exist!', $response->data['message'] ); |
|
| 653 | + $this->assertEquals( 'woocommerce_rest_invalid_coupon', $response->data[ 'code' ] ); |
|
| 654 | + $this->assertEquals( 'Coupon "non_existing_coupon" does not exist!', $response->data[ 'message' ] ); |
|
| 655 | 655 | } |
| 656 | 656 | } |
@@ -244,11 +244,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | /** |
@@ -178,9 +178,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -74,10 +74,10 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -67,8 +67,8 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v4/settings' ); |
| 143 | 143 | $response = $this->server->dispatch( $request ); |
| 144 | 144 | $data = $response->get_data(); |
| 145 | - $properties = $data['schema']['properties']; |
|
| 145 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 146 | 146 | $this->assertEquals( 5, count( $properties ) ); |
| 147 | 147 | $this->assertArrayHasKey( 'id', $properties ); |
| 148 | 148 | $this->assertArrayHasKey( 'parent_id', $properties ); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v4/settings/test/woocommerce_shop_page_display' ); |
| 161 | 161 | $response = $this->server->dispatch( $request ); |
| 162 | 162 | $data = $response->get_data(); |
| 163 | - $properties = $data['schema']['properties']; |
|
| 163 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 164 | 164 | $this->assertEquals( 10, count( $properties ) ); |
| 165 | 165 | $this->assertArrayHasKey( 'id', $properties ); |
| 166 | 166 | $this->assertArrayHasKey( 'label', $properties ); |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test' ) ); |
| 197 | 197 | $data = $response->get_data(); |
| 198 | 198 | $this->assertEquals( 1, count( $data ) ); |
| 199 | - $this->assertEquals( 'woocommerce_shop_page_display', $data[0]['id'] ); |
|
| 200 | - $this->assertEmpty( $data[0]['value'] ); |
|
| 199 | + $this->assertEquals( 'woocommerce_shop_page_display', $data[ 0 ][ 'id' ] ); |
|
| 200 | + $this->assertEmpty( $data[ 0 ][ 'value' ] ); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | // test defaults first |
| 222 | 222 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test/woocommerce_shop_page_display' ) ); |
| 223 | 223 | $data = $response->get_data(); |
| 224 | - $this->assertEquals( '', $data['value'] ); |
|
| 224 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
| 225 | 225 | |
| 226 | 226 | // test updating shop display setting |
| 227 | 227 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $response = $this->server->dispatch( $request ); |
| 234 | 234 | $data = $response->get_data(); |
| 235 | 235 | |
| 236 | - $this->assertEquals( 'both', $data['value'] ); |
|
| 236 | + $this->assertEquals( 'both', $data[ 'value' ] ); |
|
| 237 | 237 | $this->assertEquals( 'both', get_option( 'woocommerce_shop_page_display' ) ); |
| 238 | 238 | |
| 239 | 239 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $response = $this->server->dispatch( $request ); |
| 246 | 246 | $data = $response->get_data(); |
| 247 | 247 | |
| 248 | - $this->assertEquals( 'subcategories', $data['value'] ); |
|
| 248 | + $this->assertEquals( 'subcategories', $data[ 'value' ] ); |
|
| 249 | 249 | $this->assertEquals( 'subcategories', get_option( 'woocommerce_shop_page_display' ) ); |
| 250 | 250 | |
| 251 | 251 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $response = $this->server->dispatch( $request ); |
| 258 | 258 | $data = $response->get_data(); |
| 259 | 259 | |
| 260 | - $this->assertEquals( '', $data['value'] ); |
|
| 260 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
| 261 | 261 | $this->assertEquals( '', get_option( 'woocommerce_shop_page_display' ) ); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | // test defaults first |
| 271 | 271 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test' ) ); |
| 272 | 272 | $data = $response->get_data(); |
| 273 | - $this->assertEquals( '', $data[0]['value'] ); |
|
| 273 | + $this->assertEquals( '', $data[ 0 ][ 'value' ] ); |
|
| 274 | 274 | |
| 275 | 275 | // test setting both at once |
| 276 | 276 | $request = new WP_REST_Request( 'POST', '/wc/v4/settings/test/batch' ); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $response = $this->server->dispatch( $request ); |
| 288 | 288 | $data = $response->get_data(); |
| 289 | 289 | |
| 290 | - $this->assertEquals( 'both', $data['update'][0]['value'] ); |
|
| 290 | + $this->assertEquals( 'both', $data[ 'update' ][ 0 ][ 'value' ] ); |
|
| 291 | 291 | $this->assertEquals( 'both', get_option( 'woocommerce_shop_page_display' ) ); |
| 292 | 292 | |
| 293 | 293 | // test updating one, but making sure the other value stays the same |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | ); |
| 305 | 305 | $response = $this->server->dispatch( $request ); |
| 306 | 306 | $data = $response->get_data(); |
| 307 | - $this->assertEquals( 'subcategories', $data['update'][0]['value'] ); |
|
| 307 | + $this->assertEquals( 'subcategories', $data[ 'update' ][ 0 ][ 'value' ] ); |
|
| 308 | 308 | $this->assertEquals( 'subcategories', get_option( 'woocommerce_shop_page_display' ) ); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -330,11 +330,11 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | $this->assertEquals( 200, $response->get_status() ); |
| 332 | 332 | |
| 333 | - $this->assertEquals( 'woocommerce_shop_page_display', $data['id'] ); |
|
| 334 | - $this->assertEquals( 'Shop page display', $data['label'] ); |
|
| 335 | - $this->assertEquals( '', $data['default'] ); |
|
| 336 | - $this->assertEquals( 'select', $data['type'] ); |
|
| 337 | - $this->assertEquals( '', $data['value'] ); |
|
| 333 | + $this->assertEquals( 'woocommerce_shop_page_display', $data[ 'id' ] ); |
|
| 334 | + $this->assertEquals( 'Shop page display', $data[ 'label' ] ); |
|
| 335 | + $this->assertEquals( '', $data[ 'default' ] ); |
|
| 336 | + $this->assertEquals( 'select', $data[ 'type' ] ); |
|
| 337 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/products/woocommerce_dimension_unit' ) ); |
| 492 | 492 | $data = $response->get_data(); |
| 493 | 493 | |
| 494 | - $this->assertEquals( 'cm', $data['default'] ); |
|
| 494 | + $this->assertEquals( 'cm', $data[ 'default' ] ); |
|
| 495 | 495 | |
| 496 | 496 | // test update |
| 497 | 497 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'products', 'woocommerce_dimension_unit' ) ); |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | $response = $this->server->dispatch( $request ); |
| 504 | 504 | $data = $response->get_data(); |
| 505 | 505 | |
| 506 | - $this->assertEquals( 'yd', $data['value'] ); |
|
| 506 | + $this->assertEquals( 'yd', $data[ 'value' ] ); |
|
| 507 | 507 | $this->assertEquals( 'yd', get_option( 'woocommerce_dimension_unit' ) ); |
| 508 | 508 | } |
| 509 | 509 | |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | $response = $this->server->dispatch( $request ); |
| 591 | 591 | $setting = $response->get_data(); |
| 592 | 592 | |
| 593 | - $this->assertEmpty( $setting['value'] ); |
|
| 593 | + $this->assertEmpty( $setting[ 'value' ] ); |
|
| 594 | 594 | |
| 595 | 595 | // test update |
| 596 | 596 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'email_customer_new_account', 'subject' ) ); |
@@ -602,13 +602,13 @@ discard block |
||
| 602 | 602 | $response = $this->server->dispatch( $request ); |
| 603 | 603 | $setting = $response->get_data(); |
| 604 | 604 | |
| 605 | - $this->assertEquals( 'This is my new subject', $setting['value'] ); |
|
| 605 | + $this->assertEquals( 'This is my new subject', $setting[ 'value' ] ); |
|
| 606 | 606 | |
| 607 | 607 | // make sure the other is what we left it |
| 608 | 608 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/email_new_order/subject' ) ); |
| 609 | 609 | $setting = $response->get_data(); |
| 610 | 610 | |
| 611 | - $this->assertEquals( 'This is my subject', $setting['value'] ); |
|
| 611 | + $this->assertEquals( 'This is my subject', $setting[ 'value' ] ); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /** |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | public function test_validation_multiselect() { |
| 684 | 684 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', sprintf( '/wc/v4/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries' ) ) ); |
| 685 | 685 | $setting = $response->get_data(); |
| 686 | - $this->assertEmpty( $setting['value'] ); |
|
| 686 | + $this->assertEmpty( $setting[ 'value' ] ); |
|
| 687 | 687 | |
| 688 | 688 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries' ) ); |
| 689 | 689 | $request->set_body_params( |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | ); |
| 694 | 694 | $response = $this->server->dispatch( $request ); |
| 695 | 695 | $setting = $response->get_data(); |
| 696 | - $this->assertEquals( array( 'AX', 'DZ' ), $setting['value'] ); |
|
| 696 | + $this->assertEquals( array( 'AX', 'DZ' ), $setting[ 'value' ] ); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | /** |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | public function test_validation_select() { |
| 705 | 705 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', sprintf( '/wc/v4/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) ) ); |
| 706 | 706 | $setting = $response->get_data(); |
| 707 | - $this->assertEquals( 'kg', $setting['value'] ); |
|
| 707 | + $this->assertEquals( 'kg', $setting[ 'value' ] ); |
|
| 708 | 708 | |
| 709 | 709 | // invalid |
| 710 | 710 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) ); |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | ); |
| 726 | 726 | $response = $this->server->dispatch( $request ); |
| 727 | 727 | $setting = $response->get_data(); |
| 728 | - $this->assertEquals( 'lbs', $setting['value'] ); |
|
| 728 | + $this->assertEquals( 'lbs', $setting[ 'value' ] ); |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | /** |
@@ -739,9 +739,9 @@ discard block |
||
| 739 | 739 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_default_country' ) ); |
| 740 | 740 | $setting = $response->get_data(); |
| 741 | 741 | |
| 742 | - $this->assertEquals( 'select', $setting['type'] ); |
|
| 743 | - $this->assertArrayHasKey( 'GB', $setting['options'] ); |
|
| 744 | - $this->assertArrayHasKey( 'US:OR', $setting['options'] ); |
|
| 742 | + $this->assertEquals( 'select', $setting[ 'type' ] ); |
|
| 743 | + $this->assertArrayHasKey( 'GB', $setting[ 'options' ] ); |
|
| 744 | + $this->assertArrayHasKey( 'US:OR', $setting[ 'options' ] ); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | /** |
@@ -752,10 +752,10 @@ discard block |
||
| 752 | 752 | public function test_woocommerce_store_address() { |
| 753 | 753 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_address' ) ); |
| 754 | 754 | $setting = $response->get_data(); |
| 755 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 755 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 756 | 756 | |
| 757 | 757 | // Repalce the old value with something uniquely new |
| 758 | - $old_value = $setting['value']; |
|
| 758 | + $old_value = $setting[ 'value' ]; |
|
| 759 | 759 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 760 | 760 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address' ); |
| 761 | 761 | $request->set_body_params( |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | ); |
| 766 | 766 | $response = $this->server->dispatch( $request ); |
| 767 | 767 | $setting = $response->get_data(); |
| 768 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 768 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 769 | 769 | |
| 770 | 770 | // Put the original value back |
| 771 | 771 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address' ); |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | ); |
| 777 | 777 | $response = $this->server->dispatch( $request ); |
| 778 | 778 | $setting = $response->get_data(); |
| 779 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 779 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
@@ -787,10 +787,10 @@ discard block |
||
| 787 | 787 | public function test_woocommerce_store_address_2() { |
| 788 | 788 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_address_2' ) ); |
| 789 | 789 | $setting = $response->get_data(); |
| 790 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 790 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 791 | 791 | |
| 792 | 792 | // Repalce the old value with something uniquely new |
| 793 | - $old_value = $setting['value']; |
|
| 793 | + $old_value = $setting[ 'value' ]; |
|
| 794 | 794 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 795 | 795 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address_2' ); |
| 796 | 796 | $request->set_body_params( |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | ); |
| 801 | 801 | $response = $this->server->dispatch( $request ); |
| 802 | 802 | $setting = $response->get_data(); |
| 803 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 803 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 804 | 804 | |
| 805 | 805 | // Put the original value back |
| 806 | 806 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address_2' ); |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | ); |
| 812 | 812 | $response = $this->server->dispatch( $request ); |
| 813 | 813 | $setting = $response->get_data(); |
| 814 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 814 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | /** |
@@ -822,10 +822,10 @@ discard block |
||
| 822 | 822 | public function test_woocommerce_store_city() { |
| 823 | 823 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_city' ) ); |
| 824 | 824 | $setting = $response->get_data(); |
| 825 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 825 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 826 | 826 | |
| 827 | 827 | // Repalce the old value with something uniquely new |
| 828 | - $old_value = $setting['value']; |
|
| 828 | + $old_value = $setting[ 'value' ]; |
|
| 829 | 829 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 830 | 830 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_city' ); |
| 831 | 831 | $request->set_body_params( |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | ); |
| 836 | 836 | $response = $this->server->dispatch( $request ); |
| 837 | 837 | $setting = $response->get_data(); |
| 838 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 838 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 839 | 839 | |
| 840 | 840 | // Put the original value back |
| 841 | 841 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_city' ); |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | ); |
| 847 | 847 | $response = $this->server->dispatch( $request ); |
| 848 | 848 | $setting = $response->get_data(); |
| 849 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 849 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | /** |
@@ -857,10 +857,10 @@ discard block |
||
| 857 | 857 | public function test_woocommerce_store_postcode() { |
| 858 | 858 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_postcode' ) ); |
| 859 | 859 | $setting = $response->get_data(); |
| 860 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 860 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 861 | 861 | |
| 862 | 862 | // Repalce the old value with something uniquely new |
| 863 | - $old_value = $setting['value']; |
|
| 863 | + $old_value = $setting[ 'value' ]; |
|
| 864 | 864 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 865 | 865 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_postcode' ); |
| 866 | 866 | $request->set_body_params( |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | ); |
| 871 | 871 | $response = $this->server->dispatch( $request ); |
| 872 | 872 | $setting = $response->get_data(); |
| 873 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 873 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 874 | 874 | |
| 875 | 875 | // Put the original value back |
| 876 | 876 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_postcode' ); |
@@ -881,6 +881,6 @@ discard block |
||
| 881 | 881 | ); |
| 882 | 882 | $response = $this->server->dispatch( $request ); |
| 883 | 883 | $setting = $response->get_data(); |
| 884 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 884 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 885 | 885 | } |
| 886 | 886 | } |