@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/settings' ); |
| 123 | 123 | $response = $this->server->dispatch( $request ); |
| 124 | 124 | $data = $response->get_data(); |
| 125 | - $properties = $data['schema']['properties']; |
|
| 125 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 126 | 126 | $this->assertEquals( 5, count( $properties ) ); |
| 127 | 127 | $this->assertArrayHasKey( 'id', $properties ); |
| 128 | 128 | $this->assertArrayHasKey( 'parent_id', $properties ); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/settings/test/woocommerce_shop_page_display' ); |
| 141 | 141 | $response = $this->server->dispatch( $request ); |
| 142 | 142 | $data = $response->get_data(); |
| 143 | - $properties = $data['schema']['properties']; |
|
| 143 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 144 | 144 | $this->assertEquals( 9, count( $properties ) ); |
| 145 | 145 | $this->assertArrayHasKey( 'id', $properties ); |
| 146 | 146 | $this->assertArrayHasKey( 'label', $properties ); |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/test' ) ); |
| 178 | 178 | $data = $response->get_data(); |
| 179 | 179 | $this->assertEquals( 1, count( $data ) ); |
| 180 | - $this->assertEquals( 'woocommerce_shop_page_display', $data[0]['id'] ); |
|
| 181 | - $this->assertEmpty( $data[0]['value'] ); |
|
| 180 | + $this->assertEquals( 'woocommerce_shop_page_display', $data[ 0 ][ 'id' ] ); |
|
| 181 | + $this->assertEmpty( $data[ 0 ][ 'value' ] ); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | // test defaults first |
| 205 | 205 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/test/woocommerce_shop_page_display' ) ); |
| 206 | 206 | $data = $response->get_data(); |
| 207 | - $this->assertEquals( '', $data['value'] ); |
|
| 207 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
| 208 | 208 | |
| 209 | 209 | // test updating shop display setting |
| 210 | 210 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v2/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $response = $this->server->dispatch( $request ); |
| 217 | 217 | $data = $response->get_data(); |
| 218 | 218 | |
| 219 | - $this->assertEquals( 'both', $data['value'] ); |
|
| 219 | + $this->assertEquals( 'both', $data[ 'value' ] ); |
|
| 220 | 220 | $this->assertEquals( 'both', get_option( 'woocommerce_shop_page_display' ) ); |
| 221 | 221 | |
| 222 | 222 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v2/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $response = $this->server->dispatch( $request ); |
| 229 | 229 | $data = $response->get_data(); |
| 230 | 230 | |
| 231 | - $this->assertEquals( 'subcategories', $data['value'] ); |
|
| 231 | + $this->assertEquals( 'subcategories', $data[ 'value' ] ); |
|
| 232 | 232 | $this->assertEquals( 'subcategories', get_option( 'woocommerce_shop_page_display' ) ); |
| 233 | 233 | |
| 234 | 234 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v2/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | $response = $this->server->dispatch( $request ); |
| 241 | 241 | $data = $response->get_data(); |
| 242 | 242 | |
| 243 | - $this->assertEquals( '', $data['value'] ); |
|
| 243 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
| 244 | 244 | $this->assertEquals( '', get_option( 'woocommerce_shop_page_display' ) ); |
| 245 | 245 | } |
| 246 | 246 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | // test defaults first |
| 256 | 256 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/test' ) ); |
| 257 | 257 | $data = $response->get_data(); |
| 258 | - $this->assertEquals( '', $data[0]['value'] ); |
|
| 258 | + $this->assertEquals( '', $data[ 0 ][ 'value' ] ); |
|
| 259 | 259 | |
| 260 | 260 | // test setting both at once |
| 261 | 261 | $request = new WP_REST_Request( 'POST', '/wc/v2/settings/test/batch' ); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $response = $this->server->dispatch( $request ); |
| 273 | 273 | $data = $response->get_data(); |
| 274 | 274 | |
| 275 | - $this->assertEquals( 'both', $data['update'][0]['value'] ); |
|
| 275 | + $this->assertEquals( 'both', $data[ 'update' ][ 0 ][ 'value' ] ); |
|
| 276 | 276 | $this->assertEquals( 'both', get_option( 'woocommerce_shop_page_display' ) ); |
| 277 | 277 | |
| 278 | 278 | // test updating one, but making sure the other value stays the same |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | ); |
| 290 | 290 | $response = $this->server->dispatch( $request ); |
| 291 | 291 | $data = $response->get_data(); |
| 292 | - $this->assertEquals( 'subcategories', $data['update'][0]['value'] ); |
|
| 292 | + $this->assertEquals( 'subcategories', $data[ 'update' ][ 0 ][ 'value' ] ); |
|
| 293 | 293 | $this->assertEquals( 'subcategories', get_option( 'woocommerce_shop_page_display' ) ); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -317,11 +317,11 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | $this->assertEquals( 200, $response->get_status() ); |
| 319 | 319 | |
| 320 | - $this->assertEquals( 'woocommerce_shop_page_display', $data['id'] ); |
|
| 321 | - $this->assertEquals( 'Shop page display', $data['label'] ); |
|
| 322 | - $this->assertEquals( '', $data['default'] ); |
|
| 323 | - $this->assertEquals( 'select', $data['type'] ); |
|
| 324 | - $this->assertEquals( '', $data['value'] ); |
|
| 320 | + $this->assertEquals( 'woocommerce_shop_page_display', $data[ 'id' ] ); |
|
| 321 | + $this->assertEquals( 'Shop page display', $data[ 'label' ] ); |
|
| 322 | + $this->assertEquals( '', $data[ 'default' ] ); |
|
| 323 | + $this->assertEquals( 'select', $data[ 'type' ] ); |
|
| 324 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/products/woocommerce_dimension_unit' ) ); |
| 485 | 485 | $data = $response->get_data(); |
| 486 | 486 | |
| 487 | - $this->assertEquals( 'cm', $data['default'] ); |
|
| 487 | + $this->assertEquals( 'cm', $data[ 'default' ] ); |
|
| 488 | 488 | |
| 489 | 489 | // test update |
| 490 | 490 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v2/settings/%s/%s', 'products', 'woocommerce_dimension_unit' ) ); |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | $response = $this->server->dispatch( $request ); |
| 497 | 497 | $data = $response->get_data(); |
| 498 | 498 | |
| 499 | - $this->assertEquals( 'yd', $data['value'] ); |
|
| 499 | + $this->assertEquals( 'yd', $data[ 'value' ] ); |
|
| 500 | 500 | $this->assertEquals( 'yd', get_option( 'woocommerce_dimension_unit' ) ); |
| 501 | 501 | } |
| 502 | 502 | |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | $response = $this->server->dispatch( $request ); |
| 584 | 584 | $setting = $response->get_data(); |
| 585 | 585 | |
| 586 | - $this->assertEmpty( $setting['value'] ); |
|
| 586 | + $this->assertEmpty( $setting[ 'value' ] ); |
|
| 587 | 587 | |
| 588 | 588 | // test update |
| 589 | 589 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v2/settings/%s/%s', 'email_customer_new_account', 'subject' ) ); |
@@ -595,13 +595,13 @@ discard block |
||
| 595 | 595 | $response = $this->server->dispatch( $request ); |
| 596 | 596 | $setting = $response->get_data(); |
| 597 | 597 | |
| 598 | - $this->assertEquals( 'This is my new subject', $setting['value'] ); |
|
| 598 | + $this->assertEquals( 'This is my new subject', $setting[ 'value' ] ); |
|
| 599 | 599 | |
| 600 | 600 | // make sure the other is what we left it |
| 601 | 601 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/email_new_order/subject' ) ); |
| 602 | 602 | $setting = $response->get_data(); |
| 603 | 603 | |
| 604 | - $this->assertEquals( 'This is my subject', $setting['value'] ); |
|
| 604 | + $this->assertEquals( 'This is my subject', $setting[ 'value' ] ); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /** |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | |
| 683 | 683 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', sprintf( '/wc/v2/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries' ) ) ); |
| 684 | 684 | $setting = $response->get_data(); |
| 685 | - $this->assertEmpty( $setting['value'] ); |
|
| 685 | + $this->assertEmpty( $setting[ 'value' ] ); |
|
| 686 | 686 | |
| 687 | 687 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v2/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries' ) ); |
| 688 | 688 | $request->set_body_params( |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | ); |
| 693 | 693 | $response = $this->server->dispatch( $request ); |
| 694 | 694 | $setting = $response->get_data(); |
| 695 | - $this->assertEquals( array( 'AX', 'DZ' ), $setting['value'] ); |
|
| 695 | + $this->assertEquals( array( 'AX', 'DZ' ), $setting[ 'value' ] ); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | /** |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', sprintf( '/wc/v2/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) ) ); |
| 707 | 707 | $setting = $response->get_data(); |
| 708 | - $this->assertEquals( 'kg', $setting['value'] ); |
|
| 708 | + $this->assertEquals( 'kg', $setting[ 'value' ] ); |
|
| 709 | 709 | |
| 710 | 710 | // invalid |
| 711 | 711 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v2/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) ); |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | ); |
| 727 | 727 | $response = $this->server->dispatch( $request ); |
| 728 | 728 | $setting = $response->get_data(); |
| 729 | - $this->assertEquals( 'lbs', $setting['value'] ); |
|
| 729 | + $this->assertEquals( 'lbs', $setting[ 'value' ] ); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | /** |
@@ -741,9 +741,9 @@ discard block |
||
| 741 | 741 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/general/woocommerce_default_country' ) ); |
| 742 | 742 | $setting = $response->get_data(); |
| 743 | 743 | |
| 744 | - $this->assertEquals( 'select', $setting['type'] ); |
|
| 745 | - $this->assertArrayHasKey( 'GB', $setting['options'] ); |
|
| 746 | - $this->assertArrayHasKey( 'US:OR', $setting['options'] ); |
|
| 744 | + $this->assertEquals( 'select', $setting[ 'type' ] ); |
|
| 745 | + $this->assertArrayHasKey( 'GB', $setting[ 'options' ] ); |
|
| 746 | + $this->assertArrayHasKey( 'US:OR', $setting[ 'options' ] ); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | /** |
@@ -755,10 +755,10 @@ discard block |
||
| 755 | 755 | wp_set_current_user( $this->user ); |
| 756 | 756 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/general/woocommerce_store_address' ) ); |
| 757 | 757 | $setting = $response->get_data(); |
| 758 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 758 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 759 | 759 | |
| 760 | 760 | // Repalce the old value with something uniquely new |
| 761 | - $old_value = $setting['value']; |
|
| 761 | + $old_value = $setting[ 'value' ]; |
|
| 762 | 762 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 763 | 763 | $request = new WP_REST_Request( 'PUT', '/wc/v2/settings/general/woocommerce_store_address' ); |
| 764 | 764 | $request->set_body_params( |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | ); |
| 769 | 769 | $response = $this->server->dispatch( $request ); |
| 770 | 770 | $setting = $response->get_data(); |
| 771 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 771 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 772 | 772 | |
| 773 | 773 | // Put the original value back |
| 774 | 774 | $request = new WP_REST_Request( 'PUT', '/wc/v2/settings/general/woocommerce_store_address' ); |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | ); |
| 780 | 780 | $response = $this->server->dispatch( $request ); |
| 781 | 781 | $setting = $response->get_data(); |
| 782 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 782 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | /** |
@@ -791,10 +791,10 @@ discard block |
||
| 791 | 791 | wp_set_current_user( $this->user ); |
| 792 | 792 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/general/woocommerce_store_address_2' ) ); |
| 793 | 793 | $setting = $response->get_data(); |
| 794 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 794 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 795 | 795 | |
| 796 | 796 | // Repalce the old value with something uniquely new |
| 797 | - $old_value = $setting['value']; |
|
| 797 | + $old_value = $setting[ 'value' ]; |
|
| 798 | 798 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 799 | 799 | $request = new WP_REST_Request( 'PUT', '/wc/v2/settings/general/woocommerce_store_address_2' ); |
| 800 | 800 | $request->set_body_params( |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | ); |
| 805 | 805 | $response = $this->server->dispatch( $request ); |
| 806 | 806 | $setting = $response->get_data(); |
| 807 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 807 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 808 | 808 | |
| 809 | 809 | // Put the original value back |
| 810 | 810 | $request = new WP_REST_Request( 'PUT', '/wc/v2/settings/general/woocommerce_store_address_2' ); |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | ); |
| 816 | 816 | $response = $this->server->dispatch( $request ); |
| 817 | 817 | $setting = $response->get_data(); |
| 818 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 818 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | /** |
@@ -827,10 +827,10 @@ discard block |
||
| 827 | 827 | wp_set_current_user( $this->user ); |
| 828 | 828 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/general/woocommerce_store_city' ) ); |
| 829 | 829 | $setting = $response->get_data(); |
| 830 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 830 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 831 | 831 | |
| 832 | 832 | // Repalce the old value with something uniquely new |
| 833 | - $old_value = $setting['value']; |
|
| 833 | + $old_value = $setting[ 'value' ]; |
|
| 834 | 834 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 835 | 835 | $request = new WP_REST_Request( 'PUT', '/wc/v2/settings/general/woocommerce_store_city' ); |
| 836 | 836 | $request->set_body_params( |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | ); |
| 841 | 841 | $response = $this->server->dispatch( $request ); |
| 842 | 842 | $setting = $response->get_data(); |
| 843 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 843 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 844 | 844 | |
| 845 | 845 | // Put the original value back |
| 846 | 846 | $request = new WP_REST_Request( 'PUT', '/wc/v2/settings/general/woocommerce_store_city' ); |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | ); |
| 852 | 852 | $response = $this->server->dispatch( $request ); |
| 853 | 853 | $setting = $response->get_data(); |
| 854 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 854 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |
@@ -863,10 +863,10 @@ discard block |
||
| 863 | 863 | wp_set_current_user( $this->user ); |
| 864 | 864 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/general/woocommerce_store_postcode' ) ); |
| 865 | 865 | $setting = $response->get_data(); |
| 866 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 866 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 867 | 867 | |
| 868 | 868 | // Repalce the old value with something uniquely new |
| 869 | - $old_value = $setting['value']; |
|
| 869 | + $old_value = $setting[ 'value' ]; |
|
| 870 | 870 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 871 | 871 | $request = new WP_REST_Request( 'PUT', '/wc/v2/settings/general/woocommerce_store_postcode' ); |
| 872 | 872 | $request->set_body_params( |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | ); |
| 877 | 877 | $response = $this->server->dispatch( $request ); |
| 878 | 878 | $setting = $response->get_data(); |
| 879 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 879 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 880 | 880 | |
| 881 | 881 | // Put the original value back |
| 882 | 882 | $request = new WP_REST_Request( 'PUT', '/wc/v2/settings/general/woocommerce_store_postcode' ); |
@@ -887,6 +887,6 @@ discard block |
||
| 887 | 887 | ); |
| 888 | 888 | $response = $this->server->dispatch( $request ); |
| 889 | 889 | $setting = $response->get_data(); |
| 890 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 890 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 891 | 891 | } |
| 892 | 892 | } |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | $variations = $response->get_data(); |
| 46 | 46 | $this->assertEquals( 200, $response->get_status() ); |
| 47 | 47 | $this->assertEquals( 2, count( $variations ) ); |
| 48 | - $this->assertEquals( 'DUMMY SKU VARIABLE LARGE', $variations[0]['sku'] ); |
|
| 49 | - $this->assertEquals( 'size', $variations[0]['attributes'][0]['name'] ); |
|
| 48 | + $this->assertEquals( 'DUMMY SKU VARIABLE LARGE', $variations[ 0 ][ 'sku' ] ); |
|
| 49 | + $this->assertEquals( 'size', $variations[ 0 ][ 'attributes' ][ 0 ][ 'name' ] ); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | wp_set_current_user( $this->user ); |
| 71 | 71 | $product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_variation_product(); |
| 72 | 72 | $children = $product->get_children(); |
| 73 | - $variation_id = $children[0]; |
|
| 73 | + $variation_id = $children[ 0 ]; |
|
| 74 | 74 | |
| 75 | 75 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id ) ); |
| 76 | 76 | $variation = $response->get_data(); |
| 77 | 77 | |
| 78 | 78 | $this->assertEquals( 200, $response->get_status() ); |
| 79 | - $this->assertEquals( $variation_id, $variation['id'] ); |
|
| 80 | - $this->assertEquals( 'size', $variation['attributes'][0]['name'] ); |
|
| 79 | + $this->assertEquals( $variation_id, $variation[ 'id' ] ); |
|
| 80 | + $this->assertEquals( 'size', $variation[ 'attributes' ][ 0 ][ 'name' ] ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | wp_set_current_user( 0 ); |
| 90 | 90 | $product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_variation_product(); |
| 91 | 91 | $children = $product->get_children(); |
| 92 | - $variation_id = $children[0]; |
|
| 92 | + $variation_id = $children[ 0 ]; |
|
| 93 | 93 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id ) ); |
| 94 | 94 | $this->assertEquals( 401, $response->get_status() ); |
| 95 | 95 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | wp_set_current_user( $this->user ); |
| 104 | 104 | $product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_variation_product(); |
| 105 | 105 | $children = $product->get_children(); |
| 106 | - $variation_id = $children[0]; |
|
| 106 | + $variation_id = $children[ 0 ]; |
|
| 107 | 107 | |
| 108 | 108 | $request = new WP_REST_Request( 'DELETE', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id ); |
| 109 | 109 | $request->set_param( 'force', true ); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | wp_set_current_user( 0 ); |
| 125 | 125 | $product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_variation_product(); |
| 126 | 126 | $children = $product->get_children(); |
| 127 | - $variation_id = $children[0]; |
|
| 127 | + $variation_id = $children[ 0 ]; |
|
| 128 | 128 | |
| 129 | 129 | $request = new WP_REST_Request( 'DELETE', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id ); |
| 130 | 130 | $request->set_param( 'force', true ); |
@@ -155,15 +155,15 @@ discard block |
||
| 155 | 155 | wp_set_current_user( $this->user ); |
| 156 | 156 | $product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_variation_product(); |
| 157 | 157 | $children = $product->get_children(); |
| 158 | - $variation_id = $children[0]; |
|
| 158 | + $variation_id = $children[ 0 ]; |
|
| 159 | 159 | |
| 160 | 160 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id ) ); |
| 161 | 161 | $variation = $response->get_data(); |
| 162 | 162 | |
| 163 | - $this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variation['sku'] ); |
|
| 164 | - $this->assertEquals( 10, $variation['regular_price'] ); |
|
| 165 | - $this->assertEmpty( $variation['sale_price'] ); |
|
| 166 | - $this->assertEquals( 'small', $variation['attributes'][0]['option'] ); |
|
| 163 | + $this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variation[ 'sku' ] ); |
|
| 164 | + $this->assertEquals( 10, $variation[ 'regular_price' ] ); |
|
| 165 | + $this->assertEmpty( $variation[ 'sale_price' ] ); |
|
| 166 | + $this->assertEquals( 'small', $variation[ 'attributes' ][ 0 ][ 'option' ] ); |
|
| 167 | 167 | |
| 168 | 168 | $request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id ); |
| 169 | 169 | $request->set_body_params( |
@@ -187,15 +187,15 @@ discard block |
||
| 187 | 187 | $response = $this->server->dispatch( $request ); |
| 188 | 188 | $variation = $response->get_data(); |
| 189 | 189 | |
| 190 | - $this->assertTrue( isset( $variation['description'] ), print_r( $variation, true ) ); |
|
| 191 | - $this->assertContains( 'O_O', $variation['description'], print_r( $variation, true ) ); |
|
| 192 | - $this->assertEquals( '8', $variation['price'], print_r( $variation, true ) ); |
|
| 193 | - $this->assertEquals( '8', $variation['sale_price'], print_r( $variation, true ) ); |
|
| 194 | - $this->assertEquals( '10', $variation['regular_price'], print_r( $variation, true ) ); |
|
| 195 | - $this->assertEquals( 'FIXED-SKU', $variation['sku'], print_r( $variation, true ) ); |
|
| 196 | - $this->assertEquals( 'medium', $variation['attributes'][0]['option'], print_r( $variation, true ) ); |
|
| 197 | - $this->assertContains( 'Dr1Bczxq4q', $variation['image']['src'], print_r( $variation, true ) ); |
|
| 198 | - $this->assertContains( 'test upload image', $variation['image']['alt'], print_r( $variation, true ) ); |
|
| 190 | + $this->assertTrue( isset( $variation[ 'description' ] ), print_r( $variation, true ) ); |
|
| 191 | + $this->assertContains( 'O_O', $variation[ 'description' ], print_r( $variation, true ) ); |
|
| 192 | + $this->assertEquals( '8', $variation[ 'price' ], print_r( $variation, true ) ); |
|
| 193 | + $this->assertEquals( '8', $variation[ 'sale_price' ], print_r( $variation, true ) ); |
|
| 194 | + $this->assertEquals( '10', $variation[ 'regular_price' ], print_r( $variation, true ) ); |
|
| 195 | + $this->assertEquals( 'FIXED-SKU', $variation[ 'sku' ], print_r( $variation, true ) ); |
|
| 196 | + $this->assertEquals( 'medium', $variation[ 'attributes' ][ 0 ][ 'option' ], print_r( $variation, true ) ); |
|
| 197 | + $this->assertContains( 'Dr1Bczxq4q', $variation[ 'image' ][ 'src' ], print_r( $variation, true ) ); |
|
| 198 | + $this->assertContains( 'test upload image', $variation[ 'image' ][ 'alt' ], print_r( $variation, true ) ); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | wp_set_current_user( 0 ); |
| 208 | 208 | $product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_variation_product(); |
| 209 | 209 | $children = $product->get_children(); |
| 210 | - $variation_id = $children[0]; |
|
| 210 | + $variation_id = $children[ 0 ]; |
|
| 211 | 211 | |
| 212 | 212 | $request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id ); |
| 213 | 213 | $request->set_body_params( |
@@ -267,12 +267,12 @@ discard block |
||
| 267 | 267 | $response = $this->server->dispatch( $request ); |
| 268 | 268 | $variation = $response->get_data(); |
| 269 | 269 | |
| 270 | - $this->assertContains( 'A medium size.', $variation['description'] ); |
|
| 271 | - $this->assertEquals( '12', $variation['price'] ); |
|
| 272 | - $this->assertEquals( '12', $variation['regular_price'] ); |
|
| 273 | - $this->assertTrue( $variation['purchasable'] ); |
|
| 274 | - $this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $variation['sku'] ); |
|
| 275 | - $this->assertEquals( 'medium', $variation['attributes'][0]['option'] ); |
|
| 270 | + $this->assertContains( 'A medium size.', $variation[ 'description' ] ); |
|
| 271 | + $this->assertEquals( '12', $variation[ 'price' ] ); |
|
| 272 | + $this->assertEquals( '12', $variation[ 'regular_price' ] ); |
|
| 273 | + $this->assertTrue( $variation[ 'purchasable' ] ); |
|
| 274 | + $this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $variation[ 'sku' ] ); |
|
| 275 | + $this->assertEquals( 'medium', $variation[ 'attributes' ][ 0 ][ 'option' ] ); |
|
| 276 | 276 | |
| 277 | 277 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() . '/variations' ) ); |
| 278 | 278 | $variations = $response->get_data(); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | array( |
| 319 | 319 | 'update' => array( |
| 320 | 320 | array( |
| 321 | - 'id' => $children[0], |
|
| 321 | + 'id' => $children[ 0 ], |
|
| 322 | 322 | 'description' => 'Updated description.', |
| 323 | 323 | 'image' => array( |
| 324 | 324 | 'position' => 0, |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | ), |
| 329 | 329 | ), |
| 330 | 330 | 'delete' => array( |
| 331 | - $children[1], |
|
| 331 | + $children[ 1 ], |
|
| 332 | 332 | ), |
| 333 | 333 | 'create' => array( |
| 334 | 334 | array( |
@@ -348,10 +348,10 @@ discard block |
||
| 348 | 348 | $response = $this->server->dispatch( $request ); |
| 349 | 349 | $data = $response->get_data(); |
| 350 | 350 | |
| 351 | - $this->assertContains( 'Updated description.', $data['update'][0]['description'] ); |
|
| 352 | - $this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $data['create'][0]['sku'] ); |
|
| 353 | - $this->assertEquals( 'medium', $data['create'][0]['attributes'][0]['option'] ); |
|
| 354 | - $this->assertEquals( $children[1], $data['delete'][0]['id'] ); |
|
| 351 | + $this->assertContains( 'Updated description.', $data[ 'update' ][ 0 ][ 'description' ] ); |
|
| 352 | + $this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $data[ 'create' ][ 0 ][ 'sku' ] ); |
|
| 353 | + $this->assertEquals( 'medium', $data[ 'create' ][ 0 ][ 'attributes' ][ 0 ][ 'option' ] ); |
|
| 354 | + $this->assertEquals( $children[ 1 ], $data[ 'delete' ][ 0 ][ 'id' ] ); |
|
| 355 | 355 | |
| 356 | 356 | $request = new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() . '/variations' ); |
| 357 | 357 | $response = $this->server->dispatch( $request ); |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/products/' . $product->get_id() . '/variations' ); |
| 372 | 372 | $response = $this->server->dispatch( $request ); |
| 373 | 373 | $data = $response->get_data(); |
| 374 | - $properties = $data['schema']['properties']; |
|
| 374 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 375 | 375 | |
| 376 | 376 | $this->assertEquals( 37, count( $properties ) ); |
| 377 | 377 | $this->assertArrayHasKey( 'id', $properties ); |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | $product->save(); |
| 425 | 425 | |
| 426 | 426 | $children = $product->get_children(); |
| 427 | - $variation_id = $children[0]; |
|
| 427 | + $variation_id = $children[ 0 ]; |
|
| 428 | 428 | |
| 429 | 429 | // Set stock to true. |
| 430 | 430 | $request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id ); |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $variation = $response->get_data(); |
| 439 | 439 | |
| 440 | 440 | $this->assertEquals( 200, $response->get_status() ); |
| 441 | - $this->assertEquals( true, $variation['manage_stock'] ); |
|
| 441 | + $this->assertEquals( true, $variation[ 'manage_stock' ] ); |
|
| 442 | 442 | |
| 443 | 443 | // Set stock to false. |
| 444 | 444 | $request = new WP_REST_Request( 'PUT', '/wc/v2/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( false, $variation['manage_stock'] ); |
|
| 455 | + $this->assertEquals( false, $variation[ 'manage_stock' ] ); |
|
| 456 | 456 | |
| 457 | 457 | // Set stock to false but parent is managing stock. |
| 458 | 458 | $product->set_manage_stock( true ); |
@@ -468,6 +468,6 @@ discard block |
||
| 468 | 468 | $variation = $response->get_data(); |
| 469 | 469 | |
| 470 | 470 | $this->assertEquals( 200, $response->get_status() ); |
| 471 | - $this->assertEquals( 'parent', $variation['manage_stock'] ); |
|
| 471 | + $this->assertEquals( 'parent', $variation[ 'manage_stock' ] ); |
|
| 472 | 472 | } |
| 473 | 473 | } |
@@ -194,13 +194,13 @@ discard block |
||
| 194 | 194 | $this->assertEquals( 201, $response->get_status() ); |
| 195 | 195 | $this->assertEquals( |
| 196 | 196 | array( |
| 197 | - 'id' => $data['id'], |
|
| 197 | + 'id' => $data[ 'id' ], |
|
| 198 | 198 | 'code' => 'test', |
| 199 | 199 | 'amount' => '5.00', |
| 200 | - 'date_created' => $data['date_created'], |
|
| 201 | - 'date_created_gmt' => $data['date_created_gmt'], |
|
| 202 | - 'date_modified' => $data['date_modified'], |
|
| 203 | - 'date_modified_gmt' => $data['date_modified_gmt'], |
|
| 200 | + 'date_created' => $data[ 'date_created' ], |
|
| 201 | + 'date_created_gmt' => $data[ 'date_created_gmt' ], |
|
| 202 | + 'date_modified' => $data[ 'date_modified' ], |
|
| 203 | + 'date_modified_gmt' => $data[ 'date_modified_gmt' ], |
|
| 204 | 204 | 'discount_type' => 'fixed_product', |
| 205 | 205 | 'description' => 'Test', |
| 206 | 206 | 'date_expires' => null, |
@@ -280,9 +280,9 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/coupons/' . $coupon->get_id() ) ); |
| 282 | 282 | $data = $response->get_data(); |
| 283 | - $this->assertEquals( 'This is a dummy coupon', $data['description'] ); |
|
| 284 | - $this->assertEquals( 'fixed_cart', $data['discount_type'] ); |
|
| 285 | - $this->assertEquals( '1.00', $data['amount'] ); |
|
| 283 | + $this->assertEquals( 'This is a dummy coupon', $data[ 'description' ] ); |
|
| 284 | + $this->assertEquals( 'fixed_cart', $data[ 'discount_type' ] ); |
|
| 285 | + $this->assertEquals( '1.00', $data[ 'amount' ] ); |
|
| 286 | 286 | |
| 287 | 287 | $request = new WP_REST_Request( 'PUT', '/wc/v2/coupons/' . $coupon->get_id() ); |
| 288 | 288 | $request->set_body_params( |
@@ -294,9 +294,9 @@ discard block |
||
| 294 | 294 | $response = $this->server->dispatch( $request ); |
| 295 | 295 | $data = $response->get_data(); |
| 296 | 296 | |
| 297 | - $this->assertEquals( '10.00', $data['amount'] ); |
|
| 298 | - $this->assertEquals( 'New description', $data['description'] ); |
|
| 299 | - $this->assertEquals( 'fixed_cart', $data['discount_type'] ); |
|
| 297 | + $this->assertEquals( '10.00', $data[ 'amount' ] ); |
|
| 298 | + $this->assertEquals( 'New description', $data[ 'description' ] ); |
|
| 299 | + $this->assertEquals( 'fixed_cart', $data[ 'discount_type' ] ); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -416,11 +416,11 @@ discard block |
||
| 416 | 416 | $response = $this->server->dispatch( $request ); |
| 417 | 417 | $data = $response->get_data(); |
| 418 | 418 | |
| 419 | - $this->assertEquals( '5.15', $data['update'][0]['amount'] ); |
|
| 420 | - $this->assertEquals( '11.00', $data['create'][0]['amount'] ); |
|
| 421 | - $this->assertEquals( 'new-coupon', $data['create'][0]['code'] ); |
|
| 422 | - $this->assertEquals( $coupon_2->get_id(), $data['delete'][0]['id'] ); |
|
| 423 | - $this->assertEquals( $coupon_3->get_id(), $data['delete'][1]['id'] ); |
|
| 419 | + $this->assertEquals( '5.15', $data[ 'update' ][ 0 ][ 'amount' ] ); |
|
| 420 | + $this->assertEquals( '11.00', $data[ 'create' ][ 0 ][ 'amount' ] ); |
|
| 421 | + $this->assertEquals( 'new-coupon', $data[ 'create' ][ 0 ][ 'code' ] ); |
|
| 422 | + $this->assertEquals( $coupon_2->get_id(), $data[ 'delete' ][ 0 ][ 'id' ] ); |
|
| 423 | + $this->assertEquals( $coupon_3->get_id(), $data[ 'delete' ][ 1 ][ 'id' ] ); |
|
| 424 | 424 | |
| 425 | 425 | $request = new WP_REST_Request( 'GET', '/wc/v2/coupons' ); |
| 426 | 426 | $response = $this->server->dispatch( $request ); |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/coupons' ); |
| 439 | 439 | $response = $this->server->dispatch( $request ); |
| 440 | 440 | $data = $response->get_data(); |
| 441 | - $properties = $data['schema']['properties']; |
|
| 441 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 442 | 442 | |
| 443 | 443 | $this->assertEquals( 27, count( $properties ) ); |
| 444 | 444 | $this->assertArrayHasKey( 'id', $properties ); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | // Create 10 orders. |
| 48 | 48 | for ( $i = 0; $i < 10; $i++ ) { |
| 49 | - $this->orders[] = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order( $this->user ); |
|
| 49 | + $this->orders[ ] = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order( $this->user ); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/orders' ) ); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function test_get_items_without_permission() { |
| 65 | 65 | wp_set_current_user( 0 ); |
| 66 | - $this->orders[] = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order(); |
|
| 66 | + $this->orders[ ] = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order(); |
|
| 67 | 67 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/orders' ) ); |
| 68 | 68 | $this->assertEquals( 401, $response->get_status() ); |
| 69 | 69 | } |
@@ -78,18 +78,18 @@ discard block |
||
| 78 | 78 | $order->add_meta_data( 'key', 'value' ); |
| 79 | 79 | $order->add_meta_data( 'key2', 'value2' ); |
| 80 | 80 | $order->save(); |
| 81 | - $this->orders[] = $order; |
|
| 81 | + $this->orders[ ] = $order; |
|
| 82 | 82 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/orders/' . $order->get_id() ) ); |
| 83 | 83 | $data = $response->get_data(); |
| 84 | 84 | |
| 85 | 85 | $this->assertEquals( 200, $response->get_status() ); |
| 86 | - $this->assertEquals( $order->get_id(), $data['id'] ); |
|
| 86 | + $this->assertEquals( $order->get_id(), $data[ 'id' ] ); |
|
| 87 | 87 | |
| 88 | 88 | // Test meta data is set. |
| 89 | - $this->assertEquals( 'key', $data['meta_data'][0]->key ); |
|
| 90 | - $this->assertEquals( 'value', $data['meta_data'][0]->value ); |
|
| 91 | - $this->assertEquals( 'key2', $data['meta_data'][1]->key ); |
|
| 92 | - $this->assertEquals( 'value2', $data['meta_data'][1]->value ); |
|
| 89 | + $this->assertEquals( 'key', $data[ 'meta_data' ][ 0 ]->key ); |
|
| 90 | + $this->assertEquals( 'value', $data[ 'meta_data' ][ 0 ]->value ); |
|
| 91 | + $this->assertEquals( 'key2', $data[ 'meta_data' ][ 1 ]->key ); |
|
| 92 | + $this->assertEquals( 'value2', $data[ 'meta_data' ][ 1 ]->value ); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | public function test_get_item_without_permission() { |
| 100 | 100 | wp_set_current_user( 0 ); |
| 101 | 101 | $order = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order(); |
| 102 | - $this->orders[] = $order; |
|
| 102 | + $this->orders[ ] = $order; |
|
| 103 | 103 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/orders/' . $order->get_id() ) ); |
| 104 | 104 | $this->assertEquals( 401, $response->get_status() ); |
| 105 | 105 | } |
@@ -182,32 +182,32 @@ discard block |
||
| 182 | 182 | ); |
| 183 | 183 | $response = $this->server->dispatch( $request ); |
| 184 | 184 | $data = $response->get_data(); |
| 185 | - $order = wc_get_order( $data['id'] ); |
|
| 185 | + $order = wc_get_order( $data[ 'id' ] ); |
|
| 186 | 186 | $this->assertEquals( 201, $response->get_status() ); |
| 187 | - $this->assertEquals( $order->get_payment_method(), $data['payment_method'] ); |
|
| 188 | - $this->assertEquals( $order->get_payment_method_title(), $data['payment_method_title'] ); |
|
| 189 | - $this->assertEquals( $order->get_billing_first_name(), $data['billing']['first_name'] ); |
|
| 190 | - $this->assertEquals( $order->get_billing_last_name(), $data['billing']['last_name'] ); |
|
| 191 | - $this->assertEquals( '', $data['billing']['company'] ); |
|
| 192 | - $this->assertEquals( $order->get_billing_address_1(), $data['billing']['address_1'] ); |
|
| 193 | - $this->assertEquals( $order->get_billing_address_2(), $data['billing']['address_2'] ); |
|
| 194 | - $this->assertEquals( $order->get_billing_city(), $data['billing']['city'] ); |
|
| 195 | - $this->assertEquals( $order->get_billing_state(), $data['billing']['state'] ); |
|
| 196 | - $this->assertEquals( $order->get_billing_postcode(), $data['billing']['postcode'] ); |
|
| 197 | - $this->assertEquals( $order->get_billing_country(), $data['billing']['country'] ); |
|
| 198 | - $this->assertEquals( $order->get_billing_email(), $data['billing']['email'] ); |
|
| 199 | - $this->assertEquals( $order->get_billing_phone(), $data['billing']['phone'] ); |
|
| 200 | - $this->assertEquals( $order->get_shipping_first_name(), $data['shipping']['first_name'] ); |
|
| 201 | - $this->assertEquals( $order->get_shipping_last_name(), $data['shipping']['last_name'] ); |
|
| 202 | - $this->assertEquals( '', $data['shipping']['company'] ); |
|
| 203 | - $this->assertEquals( $order->get_shipping_address_1(), $data['shipping']['address_1'] ); |
|
| 204 | - $this->assertEquals( $order->get_shipping_address_2(), $data['shipping']['address_2'] ); |
|
| 205 | - $this->assertEquals( $order->get_shipping_city(), $data['shipping']['city'] ); |
|
| 206 | - $this->assertEquals( $order->get_shipping_state(), $data['shipping']['state'] ); |
|
| 207 | - $this->assertEquals( $order->get_shipping_postcode(), $data['shipping']['postcode'] ); |
|
| 208 | - $this->assertEquals( $order->get_shipping_country(), $data['shipping']['country'] ); |
|
| 209 | - $this->assertEquals( 1, count( $data['line_items'] ) ); |
|
| 210 | - $this->assertEquals( 1, count( $data['shipping_lines'] ) ); |
|
| 187 | + $this->assertEquals( $order->get_payment_method(), $data[ 'payment_method' ] ); |
|
| 188 | + $this->assertEquals( $order->get_payment_method_title(), $data[ 'payment_method_title' ] ); |
|
| 189 | + $this->assertEquals( $order->get_billing_first_name(), $data[ 'billing' ][ 'first_name' ] ); |
|
| 190 | + $this->assertEquals( $order->get_billing_last_name(), $data[ 'billing' ][ 'last_name' ] ); |
|
| 191 | + $this->assertEquals( '', $data[ 'billing' ][ 'company' ] ); |
|
| 192 | + $this->assertEquals( $order->get_billing_address_1(), $data[ 'billing' ][ 'address_1' ] ); |
|
| 193 | + $this->assertEquals( $order->get_billing_address_2(), $data[ 'billing' ][ 'address_2' ] ); |
|
| 194 | + $this->assertEquals( $order->get_billing_city(), $data[ 'billing' ][ 'city' ] ); |
|
| 195 | + $this->assertEquals( $order->get_billing_state(), $data[ 'billing' ][ 'state' ] ); |
|
| 196 | + $this->assertEquals( $order->get_billing_postcode(), $data[ 'billing' ][ 'postcode' ] ); |
|
| 197 | + $this->assertEquals( $order->get_billing_country(), $data[ 'billing' ][ 'country' ] ); |
|
| 198 | + $this->assertEquals( $order->get_billing_email(), $data[ 'billing' ][ 'email' ] ); |
|
| 199 | + $this->assertEquals( $order->get_billing_phone(), $data[ 'billing' ][ 'phone' ] ); |
|
| 200 | + $this->assertEquals( $order->get_shipping_first_name(), $data[ 'shipping' ][ 'first_name' ] ); |
|
| 201 | + $this->assertEquals( $order->get_shipping_last_name(), $data[ 'shipping' ][ 'last_name' ] ); |
|
| 202 | + $this->assertEquals( '', $data[ 'shipping' ][ 'company' ] ); |
|
| 203 | + $this->assertEquals( $order->get_shipping_address_1(), $data[ 'shipping' ][ 'address_1' ] ); |
|
| 204 | + $this->assertEquals( $order->get_shipping_address_2(), $data[ 'shipping' ][ 'address_2' ] ); |
|
| 205 | + $this->assertEquals( $order->get_shipping_city(), $data[ 'shipping' ][ 'city' ] ); |
|
| 206 | + $this->assertEquals( $order->get_shipping_state(), $data[ 'shipping' ][ 'state' ] ); |
|
| 207 | + $this->assertEquals( $order->get_shipping_postcode(), $data[ 'shipping' ][ 'postcode' ] ); |
|
| 208 | + $this->assertEquals( $order->get_shipping_country(), $data[ 'shipping' ][ 'country' ] ); |
|
| 209 | + $this->assertEquals( 1, count( $data[ 'line_items' ] ) ); |
|
| 210 | + $this->assertEquals( 1, count( $data[ 'shipping_lines' ] ) ); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | ); |
| 266 | 266 | $response = $this->server->dispatch( $request ); |
| 267 | 267 | $data = $response->get_data(); |
| 268 | - $order = wc_get_order( $data['id'] ); |
|
| 268 | + $order = wc_get_order( $data[ 'id' ] ); |
|
| 269 | 269 | $this->assertEquals( 201, $response->get_status() ); |
| 270 | - $this->assertEquals( $order->get_payment_method(), $data['payment_method'] ); |
|
| 270 | + $this->assertEquals( $order->get_payment_method(), $data[ 'payment_method' ] ); |
|
| 271 | 271 | $this->assertEquals( $order->get_payment_method_title(), 'Sanitize this' ); |
| 272 | 272 | |
| 273 | 273 | // Test when updating order. |
| 274 | - $request = new WP_REST_Request( 'PUT', '/wc/v3/orders/' . $data['id'] ); |
|
| 274 | + $request = new WP_REST_Request( 'PUT', '/wc/v3/orders/' . $data[ 'id' ] ); |
|
| 275 | 275 | $request->set_body_params( |
| 276 | 276 | array( |
| 277 | 277 | 'payment_method' => 'bacs', |
@@ -280,9 +280,9 @@ discard block |
||
| 280 | 280 | ); |
| 281 | 281 | $response = $this->server->dispatch( $request ); |
| 282 | 282 | $data = $response->get_data(); |
| 283 | - $order = wc_get_order( $data['id'] ); |
|
| 283 | + $order = wc_get_order( $data[ 'id' ] ); |
|
| 284 | 284 | $this->assertEquals( 200, $response->get_status() ); |
| 285 | - $this->assertEquals( $order->get_payment_method(), $data['payment_method'] ); |
|
| 285 | + $this->assertEquals( $order->get_payment_method(), $data[ 'payment_method' ] ); |
|
| 286 | 286 | $this->assertEquals( $order->get_payment_method_title(), 'Sanitize this too' ); |
| 287 | 287 | } |
| 288 | 288 | |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | $data = $response->get_data(); |
| 367 | 367 | |
| 368 | 368 | $this->assertEquals( 200, $response->get_status() ); |
| 369 | - $this->assertEquals( 'test-update', $data['payment_method'] ); |
|
| 370 | - $this->assertEquals( 'Fish', $data['billing']['first_name'] ); |
|
| 371 | - $this->assertEquals( 'Face', $data['billing']['last_name'] ); |
|
| 369 | + $this->assertEquals( 'test-update', $data[ 'payment_method' ] ); |
|
| 370 | + $this->assertEquals( 'Fish', $data[ 'billing' ][ 'first_name' ] ); |
|
| 371 | + $this->assertEquals( 'Face', $data[ 'billing' ][ 'last_name' ] ); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | /** |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | $data = $response->get_data(); |
| 409 | 409 | |
| 410 | 410 | $this->assertEquals( 200, $response->get_status() ); |
| 411 | - $this->assertTrue( empty( $data['fee_lines'] ) ); |
|
| 411 | + $this->assertTrue( empty( $data[ 'fee_lines' ] ) ); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | $data = $response->get_data(); |
| 447 | 447 | |
| 448 | 448 | $this->assertEquals( 200, $response->get_status() ); |
| 449 | - $this->assertCount( 1, $data['coupon_lines'] ); |
|
| 450 | - $this->assertEquals( '45.00', $data['total'] ); |
|
| 449 | + $this->assertCount( 1, $data[ 'coupon_lines' ] ); |
|
| 450 | + $this->assertEquals( '45.00', $data[ 'total' ] ); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | /** |
@@ -493,8 +493,8 @@ discard block |
||
| 493 | 493 | $data = $response->get_data(); |
| 494 | 494 | |
| 495 | 495 | $this->assertEquals( 200, $response->get_status() ); |
| 496 | - $this->assertTrue( empty( $data['coupon_lines'] ) ); |
|
| 497 | - $this->assertEquals( '50.00', $data['total'] ); |
|
| 496 | + $this->assertTrue( empty( $data[ 'coupon_lines' ] ) ); |
|
| 497 | + $this->assertEquals( '50.00', $data[ 'total' ] ); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -607,9 +607,9 @@ discard block |
||
| 607 | 607 | $response = $this->server->dispatch( $request ); |
| 608 | 608 | $data = $response->get_data(); |
| 609 | 609 | |
| 610 | - $this->assertEquals( 'updated', $data['update'][0]['payment_method'] ); |
|
| 611 | - $this->assertEquals( $order2->get_id(), $data['delete'][0]['id'] ); |
|
| 612 | - $this->assertEquals( $order3->get_id(), $data['delete'][1]['id'] ); |
|
| 610 | + $this->assertEquals( 'updated', $data[ 'update' ][ 0 ][ 'payment_method' ] ); |
|
| 611 | + $this->assertEquals( $order2->get_id(), $data[ 'delete' ][ 0 ][ 'id' ] ); |
|
| 612 | + $this->assertEquals( $order3->get_id(), $data[ 'delete' ][ 1 ][ 'id' ] ); |
|
| 613 | 613 | |
| 614 | 614 | $request = new WP_REST_Request( 'GET', '/wc/v2/orders' ); |
| 615 | 615 | $response = $this->server->dispatch( $request ); |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/orders/' . $order->get_id() ); |
| 628 | 628 | $response = $this->server->dispatch( $request ); |
| 629 | 629 | $data = $response->get_data(); |
| 630 | - $properties = $data['schema']['properties']; |
|
| 630 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 631 | 631 | |
| 632 | 632 | $this->assertEquals( 42, count( $properties ) ); |
| 633 | 633 | $this->assertArrayHasKey( 'id', $properties ); |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | $this->assertEquals( 201, $response->get_status() ); |
| 145 | 145 | $this->assertEquals( |
| 146 | 146 | array( |
| 147 | - 'id' => $data['id'], |
|
| 148 | - 'date_created' => $data['date_created'], |
|
| 149 | - 'date_created_gmt' => $data['date_created_gmt'], |
|
| 150 | - 'date_modified' => $data['date_modified'], |
|
| 151 | - 'date_modified_gmt' => $data['date_modified_gmt'], |
|
| 147 | + 'id' => $data[ 'id' ], |
|
| 148 | + 'date_created' => $data[ 'date_created' ], |
|
| 149 | + 'date_created_gmt' => $data[ 'date_created_gmt' ], |
|
| 150 | + 'date_modified' => $data[ 'date_modified' ], |
|
| 151 | + 'date_modified_gmt' => $data[ 'date_modified_gmt' ], |
|
| 152 | 152 | 'email' => '[email protected]', |
| 153 | 153 | 'first_name' => '', |
| 154 | 154 | 'last_name' => '', |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | 'meta_data' => array(), |
| 183 | 183 | 'orders_count' => 0, |
| 184 | 184 | 'total_spent' => '0.00', |
| 185 | - 'avatar_url' => $data['avatar_url'], |
|
| 185 | + 'avatar_url' => $data[ 'avatar_url' ], |
|
| 186 | 186 | ), |
| 187 | 187 | $data |
| 188 | 188 | ); |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | $this->assertEquals( 201, $response->get_status() ); |
| 213 | 213 | $this->assertEquals( |
| 214 | 214 | array( |
| 215 | - 'id' => $data['id'], |
|
| 216 | - 'date_created' => $data['date_created'], |
|
| 217 | - 'date_created_gmt' => $data['date_created_gmt'], |
|
| 218 | - 'date_modified' => $data['date_modified'], |
|
| 219 | - 'date_modified_gmt' => $data['date_modified_gmt'], |
|
| 215 | + 'id' => $data[ 'id' ], |
|
| 216 | + 'date_created' => $data[ 'date_created' ], |
|
| 217 | + 'date_created_gmt' => $data[ 'date_created_gmt' ], |
|
| 218 | + 'date_modified' => $data[ 'date_modified' ], |
|
| 219 | + 'date_modified_gmt' => $data[ 'date_modified_gmt' ], |
|
| 220 | 220 | 'email' => '[email protected]', |
| 221 | 221 | 'first_name' => 'Test', |
| 222 | 222 | 'last_name' => 'McTestFace', |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | 'meta_data' => array(), |
| 251 | 251 | 'orders_count' => 0, |
| 252 | 252 | 'total_spent' => '0.00', |
| 253 | - 'avatar_url' => $data['avatar_url'], |
|
| 253 | + 'avatar_url' => $data[ 'avatar_url' ], |
|
| 254 | 254 | ), |
| 255 | 255 | $data |
| 256 | 256 | ); |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $this->assertEquals( |
| 304 | 304 | array( |
| 305 | - 'id' => $data['id'], |
|
| 306 | - 'date_created' => $data['date_created'], |
|
| 307 | - 'date_created_gmt' => $data['date_created_gmt'], |
|
| 308 | - 'date_modified' => $data['date_modified'], |
|
| 309 | - 'date_modified_gmt' => $data['date_modified_gmt'], |
|
| 305 | + 'id' => $data[ 'id' ], |
|
| 306 | + 'date_created' => $data[ 'date_created' ], |
|
| 307 | + 'date_created_gmt' => $data[ 'date_created_gmt' ], |
|
| 308 | + 'date_modified' => $data[ 'date_modified' ], |
|
| 309 | + 'date_modified_gmt' => $data[ 'date_modified_gmt' ], |
|
| 310 | 310 | 'email' => '[email protected]', |
| 311 | 311 | 'first_name' => 'Justin', |
| 312 | 312 | 'billing' => array( |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | 'username' => 'get_customer_test', |
| 341 | 341 | 'orders_count' => 0, |
| 342 | 342 | 'total_spent' => '0.00', |
| 343 | - 'avatar_url' => $data['avatar_url'], |
|
| 343 | + 'avatar_url' => $data[ 'avatar_url' ], |
|
| 344 | 344 | ), |
| 345 | 345 | $data |
| 346 | 346 | ); |
@@ -380,8 +380,8 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/customers/' . $customer->get_id() ) ); |
| 382 | 382 | $data = $response->get_data(); |
| 383 | - $this->assertEquals( 'update_customer_test', $data['username'] ); |
|
| 384 | - $this->assertEquals( '[email protected]', $data['email'] ); |
|
| 383 | + $this->assertEquals( 'update_customer_test', $data[ 'username' ] ); |
|
| 384 | + $this->assertEquals( '[email protected]', $data[ 'email' ] ); |
|
| 385 | 385 | |
| 386 | 386 | $request = new WP_REST_Request( 'PUT', '/wc/v2/customers/' . $customer->get_id() ); |
| 387 | 387 | $request->set_body_params( |
@@ -393,8 +393,8 @@ discard block |
||
| 393 | 393 | $response = $this->server->dispatch( $request ); |
| 394 | 394 | $data = $response->get_data(); |
| 395 | 395 | |
| 396 | - $this->assertEquals( '[email protected]', $data['email'] ); |
|
| 397 | - $this->assertEquals( 'UpdatedTest', $data['first_name'] ); |
|
| 396 | + $this->assertEquals( '[email protected]', $data[ 'email' ] ); |
|
| 397 | + $this->assertEquals( 'UpdatedTest', $data[ 'first_name' ] ); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -500,11 +500,11 @@ discard block |
||
| 500 | 500 | $response = $this->server->dispatch( $request ); |
| 501 | 501 | $data = $response->get_data(); |
| 502 | 502 | |
| 503 | - $this->assertEquals( 'McTest', $data['update'][0]['last_name'] ); |
|
| 504 | - $this->assertEquals( 'newuser', $data['create'][0]['username'] ); |
|
| 505 | - $this->assertEmpty( $data['create'][0]['last_name'] ); |
|
| 506 | - $this->assertEquals( $customer_2->get_id(), $data['delete'][0]['id'] ); |
|
| 507 | - $this->assertEquals( $customer_3->get_id(), $data['delete'][1]['id'] ); |
|
| 503 | + $this->assertEquals( 'McTest', $data[ 'update' ][ 0 ][ 'last_name' ] ); |
|
| 504 | + $this->assertEquals( 'newuser', $data[ 'create' ][ 0 ][ 'username' ] ); |
|
| 505 | + $this->assertEmpty( $data[ 'create' ][ 0 ][ 'last_name' ] ); |
|
| 506 | + $this->assertEquals( $customer_2->get_id(), $data[ 'delete' ][ 0 ][ 'id' ] ); |
|
| 507 | + $this->assertEquals( $customer_3->get_id(), $data[ 'delete' ][ 1 ][ 'id' ] ); |
|
| 508 | 508 | |
| 509 | 509 | $request = new WP_REST_Request( 'GET', '/wc/v2/customers' ); |
| 510 | 510 | $response = $this->server->dispatch( $request ); |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/customers' ); |
| 524 | 524 | $response = $this->server->dispatch( $request ); |
| 525 | 525 | $data = $response->get_data(); |
| 526 | - $properties = $data['schema']['properties']; |
|
| 526 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 527 | 527 | |
| 528 | 528 | $this->assertEquals( 18, count( $properties ) ); |
| 529 | 529 | $this->assertArrayHasKey( 'id', $properties ); |
@@ -541,26 +541,26 @@ discard block |
||
| 541 | 541 | $this->assertArrayHasKey( 'total_spent', $properties ); |
| 542 | 542 | $this->assertArrayHasKey( 'avatar_url', $properties ); |
| 543 | 543 | $this->assertArrayHasKey( 'billing', $properties ); |
| 544 | - $this->assertArrayHasKey( 'first_name', $properties['billing']['properties'] ); |
|
| 545 | - $this->assertArrayHasKey( 'last_name', $properties['billing']['properties'] ); |
|
| 546 | - $this->assertArrayHasKey( 'company', $properties['billing']['properties'] ); |
|
| 547 | - $this->assertArrayHasKey( 'address_1', $properties['billing']['properties'] ); |
|
| 548 | - $this->assertArrayHasKey( 'address_2', $properties['billing']['properties'] ); |
|
| 549 | - $this->assertArrayHasKey( 'city', $properties['billing']['properties'] ); |
|
| 550 | - $this->assertArrayHasKey( 'state', $properties['billing']['properties'] ); |
|
| 551 | - $this->assertArrayHasKey( 'postcode', $properties['billing']['properties'] ); |
|
| 552 | - $this->assertArrayHasKey( 'country', $properties['billing']['properties'] ); |
|
| 553 | - $this->assertArrayHasKey( 'email', $properties['billing']['properties'] ); |
|
| 554 | - $this->assertArrayHasKey( 'phone', $properties['billing']['properties'] ); |
|
| 544 | + $this->assertArrayHasKey( 'first_name', $properties[ 'billing' ][ 'properties' ] ); |
|
| 545 | + $this->assertArrayHasKey( 'last_name', $properties[ 'billing' ][ 'properties' ] ); |
|
| 546 | + $this->assertArrayHasKey( 'company', $properties[ 'billing' ][ 'properties' ] ); |
|
| 547 | + $this->assertArrayHasKey( 'address_1', $properties[ 'billing' ][ 'properties' ] ); |
|
| 548 | + $this->assertArrayHasKey( 'address_2', $properties[ 'billing' ][ 'properties' ] ); |
|
| 549 | + $this->assertArrayHasKey( 'city', $properties[ 'billing' ][ 'properties' ] ); |
|
| 550 | + $this->assertArrayHasKey( 'state', $properties[ 'billing' ][ 'properties' ] ); |
|
| 551 | + $this->assertArrayHasKey( 'postcode', $properties[ 'billing' ][ 'properties' ] ); |
|
| 552 | + $this->assertArrayHasKey( 'country', $properties[ 'billing' ][ 'properties' ] ); |
|
| 553 | + $this->assertArrayHasKey( 'email', $properties[ 'billing' ][ 'properties' ] ); |
|
| 554 | + $this->assertArrayHasKey( 'phone', $properties[ 'billing' ][ 'properties' ] ); |
|
| 555 | 555 | $this->assertArrayHasKey( 'shipping', $properties ); |
| 556 | - $this->assertArrayHasKey( 'first_name', $properties['shipping']['properties'] ); |
|
| 557 | - $this->assertArrayHasKey( 'last_name', $properties['shipping']['properties'] ); |
|
| 558 | - $this->assertArrayHasKey( 'company', $properties['shipping']['properties'] ); |
|
| 559 | - $this->assertArrayHasKey( 'address_1', $properties['shipping']['properties'] ); |
|
| 560 | - $this->assertArrayHasKey( 'address_2', $properties['shipping']['properties'] ); |
|
| 561 | - $this->assertArrayHasKey( 'city', $properties['shipping']['properties'] ); |
|
| 562 | - $this->assertArrayHasKey( 'state', $properties['shipping']['properties'] ); |
|
| 563 | - $this->assertArrayHasKey( 'postcode', $properties['shipping']['properties'] ); |
|
| 564 | - $this->assertArrayHasKey( 'country', $properties['shipping']['properties'] ); |
|
| 556 | + $this->assertArrayHasKey( 'first_name', $properties[ 'shipping' ][ 'properties' ] ); |
|
| 557 | + $this->assertArrayHasKey( 'last_name', $properties[ 'shipping' ][ 'properties' ] ); |
|
| 558 | + $this->assertArrayHasKey( 'company', $properties[ 'shipping' ][ 'properties' ] ); |
|
| 559 | + $this->assertArrayHasKey( 'address_1', $properties[ 'shipping' ][ 'properties' ] ); |
|
| 560 | + $this->assertArrayHasKey( 'address_2', $properties[ 'shipping' ][ 'properties' ] ); |
|
| 561 | + $this->assertArrayHasKey( 'city', $properties[ 'shipping' ][ 'properties' ] ); |
|
| 562 | + $this->assertArrayHasKey( 'state', $properties[ 'shipping' ][ 'properties' ] ); |
|
| 563 | + $this->assertArrayHasKey( 'postcode', $properties[ 'shipping' ][ 'properties' ] ); |
|
| 564 | + $this->assertArrayHasKey( 'country', $properties[ 'shipping' ][ 'properties' ] ); |
|
| 565 | 565 | } |
| 566 | 566 | } |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | $this->assertEquals( 200, $response->get_status() ); |
| 53 | 53 | |
| 54 | 54 | $this->assertEquals( 2, count( $products ) ); |
| 55 | - $this->assertEquals( 'Dummy Product', $products[0]['name'] ); |
|
| 56 | - $this->assertEquals( 'DUMMY SKU', $products[0]['sku'] ); |
|
| 57 | - $this->assertEquals( 'Dummy External Product', $products[1]['name'] ); |
|
| 58 | - $this->assertEquals( 'DUMMY EXTERNAL SKU', $products[1]['sku'] ); |
|
| 55 | + $this->assertEquals( 'Dummy Product', $products[ 0 ][ 'name' ] ); |
|
| 56 | + $this->assertEquals( 'DUMMY SKU', $products[ 0 ][ 'sku' ] ); |
|
| 57 | + $this->assertEquals( 'Dummy External Product', $products[ 1 ][ 'name' ] ); |
|
| 58 | + $this->assertEquals( 'DUMMY EXTERNAL SKU', $products[ 1 ][ 'sku' ] ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() ) ); |
| 167 | 167 | $data = $response->get_data(); |
| 168 | 168 | |
| 169 | - $this->assertEquals( 'DUMMY SKU', $data['sku'] ); |
|
| 170 | - $this->assertEquals( 10, $data['regular_price'] ); |
|
| 171 | - $this->assertEmpty( $data['sale_price'] ); |
|
| 169 | + $this->assertEquals( 'DUMMY SKU', $data[ 'sku' ] ); |
|
| 170 | + $this->assertEquals( 10, $data[ 'regular_price' ] ); |
|
| 171 | + $this->assertEmpty( $data[ 'sale_price' ] ); |
|
| 172 | 172 | |
| 173 | 173 | $request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() ); |
| 174 | 174 | $request->set_body_params( |
@@ -188,13 +188,13 @@ discard block |
||
| 188 | 188 | $response = $this->server->dispatch( $request ); |
| 189 | 189 | $data = $response->get_data(); |
| 190 | 190 | |
| 191 | - $this->assertContains( 'Testing', $data['description'] ); |
|
| 192 | - $this->assertEquals( '8', $data['price'] ); |
|
| 193 | - $this->assertEquals( '8', $data['sale_price'] ); |
|
| 194 | - $this->assertEquals( '10', $data['regular_price'] ); |
|
| 195 | - $this->assertEquals( 'FIXED-SKU', $data['sku'] ); |
|
| 196 | - $this->assertContains( 'Dr1Bczxq4q', $data['images'][0]['src'] ); |
|
| 197 | - $this->assertContains( 'test upload image', $data['images'][0]['alt'] ); |
|
| 191 | + $this->assertContains( 'Testing', $data[ 'description' ] ); |
|
| 192 | + $this->assertEquals( '8', $data[ 'price' ] ); |
|
| 193 | + $this->assertEquals( '8', $data[ 'sale_price' ] ); |
|
| 194 | + $this->assertEquals( '10', $data[ 'regular_price' ] ); |
|
| 195 | + $this->assertEquals( 'FIXED-SKU', $data[ 'sku' ] ); |
|
| 196 | + $this->assertContains( 'Dr1Bczxq4q', $data[ 'images' ][ 0 ][ 'src' ] ); |
|
| 197 | + $this->assertContains( 'test upload image', $data[ 'images' ][ 0 ][ 'alt' ] ); |
|
| 198 | 198 | $product->delete( true ); |
| 199 | 199 | |
| 200 | 200 | // test variable product (variations are tested in product-variations.php). |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $data = $response->get_data(); |
| 204 | 204 | |
| 205 | 205 | foreach ( array( 'small', 'large' ) as $term_name ) { |
| 206 | - $this->assertContains( $term_name, $data['attributes'][0]['options'] ); |
|
| 206 | + $this->assertContains( $term_name, $data[ 'attributes' ][ 0 ][ 'options' ] ); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | $request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() ); |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | $response = $this->server->dispatch( $request ); |
| 236 | 236 | $data = $response->get_data(); |
| 237 | 237 | |
| 238 | - $this->assertEquals( array( 'small' ), $data['attributes'][0]['options'] ); |
|
| 239 | - $this->assertEquals( array( 'red', 'yellow' ), $data['attributes'][1]['options'] ); |
|
| 238 | + $this->assertEquals( array( 'small' ), $data[ 'attributes' ][ 0 ][ 'options' ] ); |
|
| 239 | + $this->assertEquals( array( 'red', 'yellow' ), $data[ 'attributes' ][ 1 ][ 'options' ] ); |
|
| 240 | 240 | $product->delete( true ); |
| 241 | 241 | |
| 242 | 242 | // test external product. |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() ) ); |
| 245 | 245 | $data = $response->get_data(); |
| 246 | 246 | |
| 247 | - $this->assertEquals( 'Buy external product', $data['button_text'] ); |
|
| 248 | - $this->assertEquals( 'http://woocommerce.com', $data['external_url'] ); |
|
| 247 | + $this->assertEquals( 'Buy external product', $data[ 'button_text' ] ); |
|
| 248 | + $this->assertEquals( 'http://woocommerce.com', $data[ 'external_url' ] ); |
|
| 249 | 249 | |
| 250 | 250 | $request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() ); |
| 251 | 251 | $request->set_body_params( |
@@ -257,8 +257,8 @@ discard block |
||
| 257 | 257 | $response = $this->server->dispatch( $request ); |
| 258 | 258 | $data = $response->get_data(); |
| 259 | 259 | |
| 260 | - $this->assertEquals( 'Test API Update', $data['button_text'] ); |
|
| 261 | - $this->assertEquals( 'http://automattic.com', $data['external_url'] ); |
|
| 260 | + $this->assertEquals( 'Test API Update', $data[ 'button_text' ] ); |
|
| 261 | + $this->assertEquals( 'http://automattic.com', $data[ 'external_url' ] ); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | ); |
| 314 | 314 | $response = $this->server->dispatch( $request ); |
| 315 | 315 | $data = $response->get_data(); |
| 316 | - $shipping_class_id = $data['id']; |
|
| 316 | + $shipping_class_id = $data[ 'id' ]; |
|
| 317 | 317 | |
| 318 | 318 | // Create simple. |
| 319 | 319 | $request = new WP_REST_Request( 'POST', '/wc/v2/products' ); |
@@ -329,13 +329,13 @@ discard block |
||
| 329 | 329 | $response = $this->server->dispatch( $request ); |
| 330 | 330 | $data = $response->get_data(); |
| 331 | 331 | |
| 332 | - $this->assertEquals( '10', $data['price'] ); |
|
| 333 | - $this->assertEquals( '10', $data['regular_price'] ); |
|
| 334 | - $this->assertTrue( $data['purchasable'] ); |
|
| 335 | - $this->assertEquals( 'DUMMY SKU SIMPLE API', $data['sku'] ); |
|
| 336 | - $this->assertEquals( 'Test Simple Product', $data['name'] ); |
|
| 337 | - $this->assertEquals( 'simple', $data['type'] ); |
|
| 338 | - $this->assertEquals( $shipping_class_id, $data['shipping_class_id'] ); |
|
| 332 | + $this->assertEquals( '10', $data[ 'price' ] ); |
|
| 333 | + $this->assertEquals( '10', $data[ 'regular_price' ] ); |
|
| 334 | + $this->assertTrue( $data[ 'purchasable' ] ); |
|
| 335 | + $this->assertEquals( 'DUMMY SKU SIMPLE API', $data[ 'sku' ] ); |
|
| 336 | + $this->assertEquals( 'Test Simple Product', $data[ 'name' ] ); |
|
| 337 | + $this->assertEquals( 'simple', $data[ 'type' ] ); |
|
| 338 | + $this->assertEquals( $shipping_class_id, $data[ 'shipping_class_id' ] ); |
|
| 339 | 339 | |
| 340 | 340 | // Create external. |
| 341 | 341 | $request = new WP_REST_Request( 'POST', '/wc/v2/products' ); |
@@ -352,14 +352,14 @@ discard block |
||
| 352 | 352 | $response = $this->server->dispatch( $request ); |
| 353 | 353 | $data = $response->get_data(); |
| 354 | 354 | |
| 355 | - $this->assertEquals( '10', $data['price'] ); |
|
| 356 | - $this->assertEquals( '10', $data['regular_price'] ); |
|
| 357 | - $this->assertFalse( $data['purchasable'] ); |
|
| 358 | - $this->assertEquals( 'DUMMY SKU EXTERNAL API', $data['sku'] ); |
|
| 359 | - $this->assertEquals( 'Test External Product', $data['name'] ); |
|
| 360 | - $this->assertEquals( 'external', $data['type'] ); |
|
| 361 | - $this->assertEquals( 'Test Button', $data['button_text'] ); |
|
| 362 | - $this->assertEquals( 'https://wordpress.org', $data['external_url'] ); |
|
| 355 | + $this->assertEquals( '10', $data[ 'price' ] ); |
|
| 356 | + $this->assertEquals( '10', $data[ 'regular_price' ] ); |
|
| 357 | + $this->assertFalse( $data[ 'purchasable' ] ); |
|
| 358 | + $this->assertEquals( 'DUMMY SKU EXTERNAL API', $data[ 'sku' ] ); |
|
| 359 | + $this->assertEquals( 'Test External Product', $data[ 'name' ] ); |
|
| 360 | + $this->assertEquals( 'external', $data[ 'type' ] ); |
|
| 361 | + $this->assertEquals( 'Test Button', $data[ 'button_text' ] ); |
|
| 362 | + $this->assertEquals( 'https://wordpress.org', $data[ 'external_url' ] ); |
|
| 363 | 363 | |
| 364 | 364 | // Create variable. |
| 365 | 365 | $request = new WP_REST_Request( 'POST', '/wc/v2/products' ); |
@@ -385,10 +385,10 @@ discard block |
||
| 385 | 385 | $response = $this->server->dispatch( $request ); |
| 386 | 386 | $data = $response->get_data(); |
| 387 | 387 | |
| 388 | - $this->assertEquals( 'DUMMY SKU VARIABLE API', $data['sku'] ); |
|
| 389 | - $this->assertEquals( 'Test Variable Product', $data['name'] ); |
|
| 390 | - $this->assertEquals( 'variable', $data['type'] ); |
|
| 391 | - $this->assertEquals( array( 'small', 'medium' ), $data['attributes'][0]['options'] ); |
|
| 388 | + $this->assertEquals( 'DUMMY SKU VARIABLE API', $data[ 'sku' ] ); |
|
| 389 | + $this->assertEquals( 'Test Variable Product', $data[ 'name' ] ); |
|
| 390 | + $this->assertEquals( 'variable', $data[ 'type' ] ); |
|
| 391 | + $this->assertEquals( array( 'small', 'medium' ), $data[ 'attributes' ][ 0 ][ 'options' ] ); |
|
| 392 | 392 | |
| 393 | 393 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products' ) ); |
| 394 | 394 | $products = $response->get_data(); |
@@ -453,13 +453,13 @@ discard block |
||
| 453 | 453 | $response = $this->server->dispatch( $request ); |
| 454 | 454 | $data = $response->get_data(); |
| 455 | 455 | |
| 456 | - $this->assertContains( 'Updated description.', $data['update'][0]['description'] ); |
|
| 457 | - $this->assertEquals( 'DUMMY SKU BATCH TEST 1', $data['create'][0]['sku'] ); |
|
| 458 | - $this->assertEquals( 'DUMMY SKU BATCH TEST 2', $data['create'][1]['sku'] ); |
|
| 459 | - $this->assertEquals( 'Test Button', $data['create'][0]['button_text'] ); |
|
| 460 | - $this->assertEquals( 'external', $data['create'][0]['type'] ); |
|
| 461 | - $this->assertEquals( 'simple', $data['create'][1]['type'] ); |
|
| 462 | - $this->assertEquals( $product_2->get_id(), $data['delete'][0]['id'] ); |
|
| 456 | + $this->assertContains( 'Updated description.', $data[ 'update' ][ 0 ][ 'description' ] ); |
|
| 457 | + $this->assertEquals( 'DUMMY SKU BATCH TEST 1', $data[ 'create' ][ 0 ][ 'sku' ] ); |
|
| 458 | + $this->assertEquals( 'DUMMY SKU BATCH TEST 2', $data[ 'create' ][ 1 ][ 'sku' ] ); |
|
| 459 | + $this->assertEquals( 'Test Button', $data[ 'create' ][ 0 ][ 'button_text' ] ); |
|
| 460 | + $this->assertEquals( 'external', $data[ 'create' ][ 0 ][ 'type' ] ); |
|
| 461 | + $this->assertEquals( 'simple', $data[ 'create' ][ 1 ][ 'type' ] ); |
|
| 462 | + $this->assertEquals( $product_2->get_id(), $data[ 'delete' ][ 0 ][ 'id' ] ); |
|
| 463 | 463 | |
| 464 | 464 | $request = new WP_REST_Request( 'GET', '/wc/v2/products' ); |
| 465 | 465 | $response = $this->server->dispatch( $request ); |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | $this->assertEquals( 4, count( $products ) ); |
| 498 | 498 | foreach ( $products as $product ) { |
| 499 | - $this->assertEquals( 'publish', $product['status'] ); |
|
| 499 | + $this->assertEquals( 'publish', $product[ 'status' ] ); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | // Test filtering with status=draft. |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | $this->assertEquals( 4, count( $products ) ); |
| 509 | 509 | foreach ( $products as $product ) { |
| 510 | - $this->assertEquals( 'draft', $product['status'] ); |
|
| 510 | + $this->assertEquals( 'draft', $product[ 'status' ] ); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | // Test filtering with no filters - which should return 'any' (all 8). |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/products/' . $product->get_id() ); |
| 530 | 530 | $response = $this->server->dispatch( $request ); |
| 531 | 531 | $data = $response->get_data(); |
| 532 | - $properties = $data['schema']['properties']; |
|
| 532 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 533 | 533 | $this->assertEquals( 65, count( $properties ) ); |
| 534 | 534 | } |
| 535 | 535 | } |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/payment_gateways/paypal' ) ); |
| 156 | 156 | $paypal = $response->get_data(); |
| 157 | 157 | |
| 158 | - $this->assertEquals( 'PayPal', $paypal['settings']['title']['value'] ); |
|
| 159 | - $this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] ); |
|
| 160 | - $this->assertEquals( 'no', $paypal['settings']['testmode']['value'] ); |
|
| 158 | + $this->assertEquals( 'PayPal', $paypal[ 'settings' ][ 'title' ][ 'value' ] ); |
|
| 159 | + $this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] ); |
|
| 160 | + $this->assertEquals( 'no', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] ); |
|
| 161 | 161 | |
| 162 | 162 | // test updating single setting |
| 163 | 163 | $request = new WP_REST_Request( 'POST', '/wc/v2/payment_gateways/paypal' ); |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | $paypal = $response->get_data(); |
| 173 | 173 | |
| 174 | 174 | $this->assertEquals( 200, $response->get_status() ); |
| 175 | - $this->assertEquals( 'PayPal', $paypal['settings']['title']['value'] ); |
|
| 176 | - $this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] ); |
|
| 177 | - $this->assertEquals( 'no', $paypal['settings']['testmode']['value'] ); |
|
| 175 | + $this->assertEquals( 'PayPal', $paypal[ 'settings' ][ 'title' ][ 'value' ] ); |
|
| 176 | + $this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] ); |
|
| 177 | + $this->assertEquals( 'no', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] ); |
|
| 178 | 178 | |
| 179 | 179 | // test updating multiple settings |
| 180 | 180 | $request = new WP_REST_Request( 'POST', '/wc/v2/payment_gateways/paypal' ); |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | $paypal = $response->get_data(); |
| 191 | 191 | |
| 192 | 192 | $this->assertEquals( 200, $response->get_status() ); |
| 193 | - $this->assertEquals( 'PayPal - New Title', $paypal['settings']['title']['value'] ); |
|
| 194 | - $this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] ); |
|
| 195 | - $this->assertEquals( 'yes', $paypal['settings']['testmode']['value'] ); |
|
| 193 | + $this->assertEquals( 'PayPal - New Title', $paypal[ 'settings' ][ 'title' ][ 'value' ] ); |
|
| 194 | + $this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] ); |
|
| 195 | + $this->assertEquals( 'yes', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] ); |
|
| 196 | 196 | |
| 197 | 197 | // Test other parameters, and recheck settings |
| 198 | 198 | $request = new WP_REST_Request( 'POST', '/wc/v2/payment_gateways/paypal' ); |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | $response = $this->server->dispatch( $request ); |
| 206 | 206 | $paypal = $response->get_data(); |
| 207 | 207 | |
| 208 | - $this->assertFalse( $paypal['enabled'] ); |
|
| 209 | - $this->assertEquals( 2, $paypal['order'] ); |
|
| 210 | - $this->assertEquals( 'PayPal - New Title', $paypal['settings']['title']['value'] ); |
|
| 211 | - $this->assertEquals( '[email protected]', $paypal['settings']['email']['value'] ); |
|
| 212 | - $this->assertEquals( 'yes', $paypal['settings']['testmode']['value'] ); |
|
| 208 | + $this->assertFalse( $paypal[ 'enabled' ] ); |
|
| 209 | + $this->assertEquals( 2, $paypal[ 'order' ] ); |
|
| 210 | + $this->assertEquals( 'PayPal - New Title', $paypal[ 'settings' ][ 'title' ][ 'value' ] ); |
|
| 211 | + $this->assertEquals( '[email protected]', $paypal[ 'settings' ][ 'email' ][ 'value' ] ); |
|
| 212 | + $this->assertEquals( 'yes', $paypal[ 'settings' ][ 'testmode' ][ 'value' ] ); |
|
| 213 | 213 | |
| 214 | 214 | // test bogus |
| 215 | 215 | $request = new WP_REST_Request( 'POST', '/wc/v2/payment_gateways/paypal' ); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | ); |
| 234 | 234 | $response = $this->server->dispatch( $request ); |
| 235 | 235 | $paypal = $response->get_data(); |
| 236 | - $this->assertEquals( 'authorization', $paypal['settings']['paymentaction']['value'] ); |
|
| 236 | + $this->assertEquals( 'authorization', $paypal[ 'settings' ][ 'paymentaction' ][ 'value' ] ); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/payment_gateways' ); |
| 285 | 285 | $response = $this->server->dispatch( $request ); |
| 286 | 286 | $data = $response->get_data(); |
| 287 | - $properties = $data['schema']['properties']; |
|
| 287 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 288 | 288 | |
| 289 | 289 | $this->assertEquals( 8, count( $properties ) ); |
| 290 | 290 | $this->assertArrayHasKey( 'id', $properties ); |
@@ -309,25 +309,25 @@ discard block |
||
| 309 | 309 | $gateway->init_form_fields(); |
| 310 | 310 | foreach ( $gateway->form_fields as $id => $field ) { |
| 311 | 311 | // Make sure we at least have a title and type |
| 312 | - if ( empty( $field['title'] ) || empty( $field['type'] ) ) { |
|
| 312 | + if ( empty( $field[ 'title' ] ) || empty( $field[ 'type' ] ) ) { |
|
| 313 | 313 | continue; |
| 314 | 314 | } |
| 315 | 315 | // Ignore 'title' settings/fields -- they are UI only |
| 316 | - if ( 'title' === $field['type'] ) { |
|
| 316 | + if ( 'title' === $field[ 'type' ] ) { |
|
| 317 | 317 | continue; |
| 318 | 318 | } |
| 319 | 319 | $data = array( |
| 320 | 320 | 'id' => $id, |
| 321 | - 'label' => empty( $field['label'] ) ? $field['title'] : $field['label'], |
|
| 322 | - 'description' => empty( $field['description'] ) ? '' : $field['description'], |
|
| 323 | - 'type' => $field['type'], |
|
| 321 | + 'label' => empty( $field[ 'label' ] ) ? $field[ 'title' ] : $field[ 'label' ], |
|
| 322 | + 'description' => empty( $field[ 'description' ] ) ? '' : $field[ 'description' ], |
|
| 323 | + 'type' => $field[ 'type' ], |
|
| 324 | 324 | 'value' => $gateway->settings[ $id ], |
| 325 | - 'default' => empty( $field['default'] ) ? '' : $field['default'], |
|
| 326 | - 'tip' => empty( $field['description'] ) ? '' : $field['description'], |
|
| 327 | - 'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'], |
|
| 325 | + 'default' => empty( $field[ 'default' ] ) ? '' : $field[ 'default' ], |
|
| 326 | + 'tip' => empty( $field[ 'description' ] ) ? '' : $field[ 'description' ], |
|
| 327 | + 'placeholder' => empty( $field[ 'placeholder' ] ) ? '' : $field[ 'placeholder' ], |
|
| 328 | 328 | ); |
| 329 | - if ( ! empty( $field['options'] ) ) { |
|
| 330 | - $data['options'] = $field['options']; |
|
| 329 | + if ( ! empty( $field[ 'options' ] ) ) { |
|
| 330 | + $data[ 'options' ] = $field[ 'options' ]; |
|
| 331 | 331 | } |
| 332 | 332 | $settings[ $id ] = $data; |
| 333 | 333 | } |
@@ -133,7 +133,7 @@ |
||
| 133 | 133 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/shipping_methods' ); |
| 134 | 134 | $response = $this->server->dispatch( $request ); |
| 135 | 135 | $data = $response->get_data(); |
| 136 | - $properties = $data['schema']['properties']; |
|
| 136 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 137 | 137 | |
| 138 | 138 | $this->assertEquals( 3, count( $properties ) ); |
| 139 | 139 | $this->assertArrayHasKey( 'id', $properties ); |
@@ -76,15 +76,15 @@ discard block |
||
| 76 | 76 | wp_set_current_user( $this->user ); |
| 77 | 77 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) ); |
| 78 | 78 | $data = $response->get_data(); |
| 79 | - $environment = (array) $data['environment']; |
|
| 79 | + $environment = (array) $data[ 'environment' ]; |
|
| 80 | 80 | |
| 81 | 81 | // Make sure all expected data is present. |
| 82 | 82 | $this->assertEquals( 32, count( $environment ) ); |
| 83 | 83 | |
| 84 | 84 | // Test some responses to make sure they match up. |
| 85 | - $this->assertEquals( get_option( 'home' ), $environment['home_url'] ); |
|
| 86 | - $this->assertEquals( get_option( 'siteurl' ), $environment['site_url'] ); |
|
| 87 | - $this->assertEquals( WC()->version, $environment['version'] ); |
|
| 85 | + $this->assertEquals( get_option( 'home' ), $environment[ 'home_url' ] ); |
|
| 86 | + $this->assertEquals( get_option( 'siteurl' ), $environment[ 'site_url' ] ); |
|
| 87 | + $this->assertEquals( WC()->version, $environment[ 'version' ] ); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | wp_set_current_user( $this->user ); |
| 98 | 98 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) ); |
| 99 | 99 | $data = $response->get_data(); |
| 100 | - $database = (array) $data['database']; |
|
| 100 | + $database = (array) $data[ 'database' ]; |
|
| 101 | 101 | |
| 102 | - $this->assertEquals( get_option( 'woocommerce_db_version' ), $database['wc_database_version'] ); |
|
| 103 | - $this->assertEquals( $wpdb->prefix, $database['database_prefix'] ); |
|
| 104 | - $this->assertEquals( WC_Geolocation::get_local_database_path(), $database['maxmind_geoip_database'] ); |
|
| 105 | - $this->assertArrayHasKey( 'woocommerce', $database['database_tables'], print_r( $database, true ) ); |
|
| 106 | - $this->assertArrayHasKey( $wpdb->prefix . 'woocommerce_payment_tokens', $database['database_tables']['woocommerce'], print_r( $database, true ) ); |
|
| 102 | + $this->assertEquals( get_option( 'woocommerce_db_version' ), $database[ 'wc_database_version' ] ); |
|
| 103 | + $this->assertEquals( $wpdb->prefix, $database[ 'database_prefix' ] ); |
|
| 104 | + $this->assertEquals( WC_Geolocation::get_local_database_path(), $database[ 'maxmind_geoip_database' ] ); |
|
| 105 | + $this->assertArrayHasKey( 'woocommerce', $database[ 'database_tables' ], print_r( $database, true ) ); |
|
| 106 | + $this->assertArrayHasKey( $wpdb->prefix . 'woocommerce_payment_tokens', $database[ 'database_tables' ][ 'woocommerce' ], print_r( $database, true ) ); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | update_option( 'active_plugins', array() ); |
| 121 | 121 | |
| 122 | 122 | $data = $response->get_data(); |
| 123 | - $plugins = (array) $data['active_plugins']; |
|
| 123 | + $plugins = (array) $data[ 'active_plugins' ]; |
|
| 124 | 124 | |
| 125 | 125 | $this->assertEquals( 1, count( $plugins ) ); |
| 126 | - $this->assertEquals( 'Hello Dolly', $plugins[0]['name'] ); |
|
| 126 | + $this->assertEquals( 'Hello Dolly', $plugins[ 0 ][ 'name' ] ); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) ); |
| 139 | 139 | $data = $response->get_data(); |
| 140 | - $theme = (array) $data['theme']; |
|
| 140 | + $theme = (array) $data[ 'theme' ]; |
|
| 141 | 141 | |
| 142 | 142 | $this->assertEquals( 13, count( $theme ) ); |
| 143 | - $this->assertEquals( $active_theme->Name, $theme['name'] ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar |
|
| 143 | + $this->assertEquals( $active_theme->Name, $theme[ 'name' ] ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -159,12 +159,12 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) ); |
| 161 | 161 | $data = $response->get_data(); |
| 162 | - $settings = (array) $data['settings']; |
|
| 162 | + $settings = (array) $data[ 'settings' ]; |
|
| 163 | 163 | |
| 164 | 164 | $this->assertEquals( 12, count( $settings ) ); |
| 165 | - $this->assertEquals( ( 'yes' === get_option( 'woocommerce_api_enabled' ) ), $settings['api_enabled'] ); |
|
| 166 | - $this->assertEquals( get_woocommerce_currency(), $settings['currency'] ); |
|
| 167 | - $this->assertEquals( $term_response, $settings['taxonomies'] ); |
|
| 165 | + $this->assertEquals( ( 'yes' === get_option( 'woocommerce_api_enabled' ) ), $settings[ 'api_enabled' ] ); |
|
| 166 | + $this->assertEquals( get_woocommerce_currency(), $settings[ 'currency' ] ); |
|
| 167 | + $this->assertEquals( $term_response, $settings[ 'taxonomies' ] ); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) ); |
| 179 | 179 | $data = $response->get_data(); |
| 180 | - $settings = (array) $data['security']; |
|
| 180 | + $settings = (array) $data[ 'security' ]; |
|
| 181 | 181 | |
| 182 | 182 | $this->assertEquals( 2, count( $settings ) ); |
| 183 | - $this->assertEquals( 'https' === substr( wc_get_page_permalink( 'shop' ), 0, 5 ), $settings['secure_connection'] ); |
|
| 184 | - $this->assertEquals( ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), $settings['hide_errors'] ); |
|
| 183 | + $this->assertEquals( 'https' === substr( wc_get_page_permalink( 'shop' ), 0, 5 ), $settings[ 'secure_connection' ] ); |
|
| 184 | + $this->assertEquals( ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), $settings[ 'hide_errors' ] ); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | wp_set_current_user( $this->user ); |
| 194 | 194 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) ); |
| 195 | 195 | $data = $response->get_data(); |
| 196 | - $pages = $data['pages']; |
|
| 196 | + $pages = $data[ 'pages' ]; |
|
| 197 | 197 | $this->assertEquals( 5, count( $pages ) ); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/system_status' ); |
| 207 | 207 | $response = $this->server->dispatch( $request ); |
| 208 | 208 | $data = $response->get_data(); |
| 209 | - $properties = $data['schema']['properties']; |
|
| 209 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 210 | 210 | $this->assertEquals( 9, count( $properties ) ); |
| 211 | 211 | $this->assertArrayHasKey( 'environment', $properties ); |
| 212 | 212 | $this->assertArrayHasKey( 'database', $properties ); |
@@ -273,17 +273,17 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | $tools_controller = new WC_REST_System_Status_Tools_Controller(); |
| 275 | 275 | $raw_tools = $tools_controller->get_tools(); |
| 276 | - $raw_tool = $raw_tools['recount_terms']; |
|
| 276 | + $raw_tool = $raw_tools[ 'recount_terms' ]; |
|
| 277 | 277 | |
| 278 | 278 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status/tools/recount_terms' ) ); |
| 279 | 279 | $data = $response->get_data(); |
| 280 | 280 | |
| 281 | 281 | $this->assertEquals( 200, $response->get_status() ); |
| 282 | 282 | |
| 283 | - $this->assertEquals( 'recount_terms', $data['id'] ); |
|
| 284 | - $this->assertEquals( 'Term counts', $data['name'] ); |
|
| 285 | - $this->assertEquals( 'Recount terms', $data['action'] ); |
|
| 286 | - $this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data['description'] ); |
|
| 283 | + $this->assertEquals( 'recount_terms', $data[ 'id' ] ); |
|
| 284 | + $this->assertEquals( 'Term counts', $data[ 'name' ] ); |
|
| 285 | + $this->assertEquals( 'Recount terms', $data[ 'action' ] ); |
|
| 286 | + $this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data[ 'description' ] ); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -307,16 +307,16 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | $tools_controller = new WC_REST_System_Status_Tools_Controller(); |
| 309 | 309 | $raw_tools = $tools_controller->get_tools(); |
| 310 | - $raw_tool = $raw_tools['recount_terms']; |
|
| 310 | + $raw_tool = $raw_tools[ 'recount_terms' ]; |
|
| 311 | 311 | |
| 312 | 312 | $response = $this->server->dispatch( new WP_REST_Request( 'POST', '/wc/v2/system_status/tools/recount_terms' ) ); |
| 313 | 313 | $data = $response->get_data(); |
| 314 | 314 | |
| 315 | - $this->assertEquals( 'recount_terms', $data['id'] ); |
|
| 316 | - $this->assertEquals( 'Term counts', $data['name'] ); |
|
| 317 | - $this->assertEquals( 'Recount terms', $data['action'] ); |
|
| 318 | - $this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data['description'] ); |
|
| 319 | - $this->assertTrue( $data['success'] ); |
|
| 315 | + $this->assertEquals( 'recount_terms', $data[ 'id' ] ); |
|
| 316 | + $this->assertEquals( 'Term counts', $data[ 'name' ] ); |
|
| 317 | + $this->assertEquals( 'Recount terms', $data[ 'action' ] ); |
|
| 318 | + $this->assertEquals( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data[ 'description' ] ); |
|
| 319 | + $this->assertTrue( $data[ 'success' ] ); |
|
| 320 | 320 | $this->assertEquals( 1, did_action( 'woocommerce_rest_insert_system_status_tool' ) ); |
| 321 | 321 | |
| 322 | 322 | $response = $this->server->dispatch( new WP_REST_Request( 'POST', '/wc/v2/system_status/tools/not_a_real_tool' ) ); |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/system_status/tools' ); |
| 344 | 344 | $response = $this->server->dispatch( $request ); |
| 345 | 345 | $data = $response->get_data(); |
| 346 | - $properties = $data['schema']['properties']; |
|
| 346 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 347 | 347 | |
| 348 | 348 | $this->assertEquals( 6, count( $properties ) ); |
| 349 | 349 | $this->assertArrayHasKey( 'id', $properties ); |