@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | $attribute_data = self::create_attribute( 'size', array( 'small', 'large' ) ); // Create all attribute related things. |
130 | 130 | $attributes = array(); |
131 | 131 | $attribute = new WC_Product_Attribute(); |
132 | - $attribute->set_id( $attribute_data['attribute_id'] ); |
|
133 | - $attribute->set_name( $attribute_data['attribute_taxonomy'] ); |
|
134 | - $attribute->set_options( $attribute_data['term_ids'] ); |
|
132 | + $attribute->set_id( $attribute_data[ 'attribute_id' ] ); |
|
133 | + $attribute->set_name( $attribute_data[ 'attribute_taxonomy' ] ); |
|
134 | + $attribute->set_options( $attribute_data[ 'term_ids' ] ); |
|
135 | 135 | $attribute->set_position( 1 ); |
136 | 136 | $attribute->set_visible( true ); |
137 | 137 | $attribute->set_variation( true ); |
138 | - $attributes[] = $attribute; |
|
138 | + $attributes[ ] = $attribute; |
|
139 | 139 | |
140 | 140 | $product->set_attributes( $attributes ); |
141 | 141 | $product->save(); |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | |
247 | 247 | if ( ! $result ) { |
248 | 248 | $result = wp_insert_term( $term, $attribute->slug ); |
249 | - $return['term_ids'][] = $result['term_id']; |
|
249 | + $return[ 'term_ids' ][ ] = $result[ 'term_id' ]; |
|
250 | 250 | } else { |
251 | - $return['term_ids'][] = $result['term_id']; |
|
251 | + $return[ 'term_ids' ][ ] = $result[ 'term_id' ]; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | // Delete all products in the order. |
32 | 32 | foreach ( $order->get_items() as $item ) { |
33 | - \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::delete_product( $item['product_id'] ); |
|
33 | + \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::delete_product( $item[ 'product_id' ] ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | ShippingHelper::delete_simple_flat_rate(); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'total' => '', |
66 | 66 | ); |
67 | 67 | |
68 | - $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // Required, else wc_create_order throws an exception |
|
68 | + $_SERVER[ 'REMOTE_ADDR' ] = '127.0.0.1'; // Required, else wc_create_order throws an exception |
|
69 | 69 | $order = wc_create_order( $order_data ); |
70 | 70 | |
71 | 71 | // Add order products |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | // Set payment gateway |
115 | 115 | $payment_gateways = WC()->payment_gateways->payment_gateways(); |
116 | - $order->set_payment_method( $payment_gateways['bacs'] ); |
|
116 | + $order->set_payment_method( $payment_gateways[ 'bacs' ] ); |
|
117 | 117 | |
118 | 118 | // Set totals |
119 | 119 | $order->set_shipping_total( 10 ); |
@@ -30,26 +30,26 @@ discard block |
||
30 | 30 | * @return array |
31 | 31 | */ |
32 | 32 | public static function register_groups( $groups ) { |
33 | - $groups[] = array( |
|
33 | + $groups[ ] = array( |
|
34 | 34 | 'id' => 'test', |
35 | 35 | 'bad' => 'value', |
36 | 36 | 'label' => 'Test extension', |
37 | 37 | 'description' => 'My awesome test settings.', |
38 | 38 | 'option_key' => '', |
39 | 39 | ); |
40 | - $groups[] = array( |
|
40 | + $groups[ ] = array( |
|
41 | 41 | 'id' => 'sub-test', |
42 | 42 | 'parent_id' => 'test', |
43 | 43 | 'label' => 'Sub test', |
44 | 44 | 'description' => '', |
45 | 45 | 'option_key' => '', |
46 | 46 | ); |
47 | - $groups[] = array( |
|
47 | + $groups[ ] = array( |
|
48 | 48 | 'id' => 'coupon-data', |
49 | 49 | 'label' => 'Coupon data', |
50 | 50 | 'option_key' => '', |
51 | 51 | ); |
52 | - $groups[] = array( |
|
52 | + $groups[ ] = array( |
|
53 | 53 | 'id' => 'invalid', |
54 | 54 | 'option_key' => '', |
55 | 55 | ); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return array |
65 | 65 | */ |
66 | 66 | public static function register_test_settings( $settings ) { |
67 | - $settings[] = array( |
|
67 | + $settings[ ] = array( |
|
68 | 68 | 'id' => 'woocommerce_shop_page_display', |
69 | 69 | 'label' => 'Shop page display', |
70 | 70 | 'description' => 'This controls what is shown on the product archive.', |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @var array Keys are property names, values are supported context. |
40 | 40 | */ |
41 | - protected $properties = []; |
|
41 | + protected $properties = [ ]; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Routes that this endpoint creates. |
45 | 45 | * |
46 | 46 | * @var array |
47 | 47 | */ |
48 | - protected $routes = []; |
|
48 | + protected $routes = [ ]; |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * User variable. |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | * @return void |
94 | 94 | */ |
95 | 95 | public function test_schema_properties() { |
96 | - $request = new \WP_REST_Request( 'OPTIONS', $this->routes[0] ); |
|
96 | + $request = new \WP_REST_Request( 'OPTIONS', $this->routes[ 0 ] ); |
|
97 | 97 | $response = $this->server->dispatch( $request ); |
98 | 98 | $data = $response->get_data(); |
99 | - $properties = $data['schema']['properties']; |
|
99 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
100 | 100 | |
101 | 101 | $this->assertEquals( count( array_keys( $this->properties ) ), count( $properties ), print_r( array_diff( array_keys( $properties ), array_keys( $this->properties ) ), true ) ); |
102 | 102 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param array $params Request body or query. |
137 | 137 | * @return object |
138 | 138 | */ |
139 | - protected function do_request( $endpoint, $type = 'GET', $params = [] ) { |
|
139 | + protected function do_request( $endpoint, $type = 'GET', $params = [ ] ) { |
|
140 | 140 | $request = new \WP_REST_Request( $type, untrailingslashit( $endpoint ) ); |
141 | 141 | 'GET' === $type ? $request->set_query_params( $params ) : $request->set_body_params( $params ); |
142 | 142 | $response = $this->server->dispatch( $request ); |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | $this->assertArrayHasKey( 'id', $meta ); |
195 | 195 | $this->assertArrayHasKey( 'key', $meta ); |
196 | 196 | $this->assertArrayHasKey( 'value', $meta ); |
197 | - $this->assertEquals( $expected_meta_data[ $key ]['key'], $meta['key'] ); |
|
198 | - $this->assertEquals( $expected_meta_data[ $key ]['value'], $meta['value'] ); |
|
197 | + $this->assertEquals( $expected_meta_data[ $key ][ 'key' ], $meta[ 'key' ] ); |
|
198 | + $this->assertEquals( $expected_meta_data[ $key ][ 'value' ], $meta[ 'value' ] ); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | 'hide_empty' => false, |
49 | 49 | ) |
50 | 50 | ); |
51 | - $data = array(); |
|
51 | + $data = array(); |
|
52 | 52 | |
53 | 53 | foreach ( $terms as $product_type ) { |
54 | 54 | if ( ! isset( $types[ $product_type->name ] ) ) { |
55 | 55 | continue; |
56 | 56 | } |
57 | 57 | |
58 | - $data[] = array( |
|
58 | + $data[ ] = array( |
|
59 | 59 | 'slug' => $product_type->name, |
60 | 60 | 'name' => $types[ $product_type->name ], |
61 | 61 | 'total' => (int) $product_type->count, |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v3/reports/products/totals' ); |
90 | 90 | $response = $this->server->dispatch( $request ); |
91 | 91 | $data = $response->get_data(); |
92 | - $properties = $data['schema']['properties']; |
|
92 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
93 | 93 | |
94 | 94 | $this->assertEquals( 3, count( $properties ) ); |
95 | 95 | $this->assertArrayHasKey( 'slug', $properties ); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'role' => 'administrator', |
28 | 28 | ) |
29 | 29 | ); |
30 | - $this->zones = array(); |
|
30 | + $this->zones = array(); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $zone->set_locations( $locations ); |
45 | 45 | $zone->save(); |
46 | 46 | |
47 | - $this->zones[] = $zone; |
|
47 | + $this->zones[ ] = $zone; |
|
48 | 48 | |
49 | 49 | return $zone; |
50 | 50 | } |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | $this->assertEquals( count( $data ), 1 ); |
80 | 80 | $this->assertContains( |
81 | 81 | array( |
82 | - 'id' => $data[0]['id'], |
|
82 | + 'id' => $data[ 0 ][ 'id' ], |
|
83 | 83 | 'name' => 'Locations not covered by your other zones', |
84 | 84 | 'order' => 0, |
85 | 85 | '_links' => array( |
86 | 86 | 'self' => array( |
87 | 87 | array( |
88 | - 'href' => rest_url( '/wc/v3/shipping/zones/' . $data[0]['id'] ), |
|
88 | + 'href' => rest_url( '/wc/v3/shipping/zones/' . $data[ 0 ][ 'id' ] ), |
|
89 | 89 | ), |
90 | 90 | ), |
91 | 91 | 'collection' => array( |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ), |
96 | 96 | 'describedby' => array( |
97 | 97 | array( |
98 | - 'href' => rest_url( '/wc/v3/shipping/zones/' . $data[0]['id'] . '/locations' ), |
|
98 | + 'href' => rest_url( '/wc/v3/shipping/zones/' . $data[ 0 ][ 'id' ] . '/locations' ), |
|
99 | 99 | ), |
100 | 100 | ), |
101 | 101 | ), |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | $this->assertEquals( count( $data ), 2 ); |
114 | 114 | $this->assertContains( |
115 | 115 | array( |
116 | - 'id' => $data[1]['id'], |
|
116 | + 'id' => $data[ 1 ][ 'id' ], |
|
117 | 117 | 'name' => 'Zone 1', |
118 | 118 | 'order' => 0, |
119 | 119 | '_links' => array( |
120 | 120 | 'self' => array( |
121 | 121 | array( |
122 | - 'href' => rest_url( '/wc/v3/shipping/zones/' . $data[1]['id'] ), |
|
122 | + 'href' => rest_url( '/wc/v3/shipping/zones/' . $data[ 1 ][ 'id' ] ), |
|
123 | 123 | ), |
124 | 124 | ), |
125 | 125 | 'collection' => array( |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | ), |
130 | 130 | 'describedby' => array( |
131 | 131 | array( |
132 | - 'href' => rest_url( '/wc/v3/shipping/zones/' . $data[1]['id'] . '/locations' ), |
|
132 | + 'href' => rest_url( '/wc/v3/shipping/zones/' . $data[ 1 ][ 'id' ] . '/locations' ), |
|
133 | 133 | ), |
134 | 134 | ), |
135 | 135 | ), |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v3/shipping/zones' ); |
176 | 176 | $response = $this->server->dispatch( $request ); |
177 | 177 | $data = $response->get_data(); |
178 | - $properties = $data['schema']['properties']; |
|
178 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
179 | 179 | $this->assertEquals( 3, count( $properties ) ); |
180 | 180 | $this->assertArrayHasKey( 'id', $properties ); |
181 | - $this->assertTrue( $properties['id']['readonly'] ); |
|
181 | + $this->assertTrue( $properties[ 'id' ][ 'readonly' ] ); |
|
182 | 182 | $this->assertArrayHasKey( 'name', $properties ); |
183 | 183 | $this->assertArrayHasKey( 'order', $properties ); |
184 | 184 | } |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | $this->assertEquals( 201, $response->get_status() ); |
205 | 205 | $this->assertEquals( |
206 | 206 | array( |
207 | - 'id' => $data['id'], |
|
207 | + 'id' => $data[ 'id' ], |
|
208 | 208 | 'name' => 'Test Zone', |
209 | 209 | 'order' => 1, |
210 | 210 | '_links' => array( |
211 | 211 | 'self' => array( |
212 | 212 | array( |
213 | - 'href' => rest_url( '/wc/v3/shipping/zones/' . $data['id'] ), |
|
213 | + 'href' => rest_url( '/wc/v3/shipping/zones/' . $data[ 'id' ] ), |
|
214 | 214 | ), |
215 | 215 | ), |
216 | 216 | 'collection' => array( |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | ), |
221 | 221 | 'describedby' => array( |
222 | 222 | array( |
223 | - 'href' => rest_url( '/wc/v3/shipping/zones/' . $data['id'] . '/locations' ), |
|
223 | + 'href' => rest_url( '/wc/v3/shipping/zones/' . $data[ 'id' ] . '/locations' ), |
|
224 | 224 | ), |
225 | 225 | ), |
226 | 226 | ), |
@@ -597,16 +597,16 @@ discard block |
||
597 | 597 | foreach ( $method->get_instance_form_fields() as $id => $field ) { |
598 | 598 | $data = array( |
599 | 599 | 'id' => $id, |
600 | - 'label' => $field['title'], |
|
601 | - 'description' => ( empty( $field['description'] ) ? '' : $field['description'] ), |
|
602 | - 'type' => $field['type'], |
|
600 | + 'label' => $field[ 'title' ], |
|
601 | + 'description' => ( empty( $field[ 'description' ] ) ? '' : $field[ 'description' ] ), |
|
602 | + 'type' => $field[ 'type' ], |
|
603 | 603 | 'value' => $method->instance_settings[ $id ], |
604 | - 'default' => ( empty( $field['default'] ) ? '' : $field['default'] ), |
|
605 | - 'tip' => ( empty( $field['description'] ) ? '' : $field['description'] ), |
|
606 | - 'placeholder' => ( empty( $field['placeholder'] ) ? '' : $field['placeholder'] ), |
|
604 | + 'default' => ( empty( $field[ 'default' ] ) ? '' : $field[ 'default' ] ), |
|
605 | + 'tip' => ( empty( $field[ 'description' ] ) ? '' : $field[ 'description' ] ), |
|
606 | + 'placeholder' => ( empty( $field[ 'placeholder' ] ) ? '' : $field[ 'placeholder' ] ), |
|
607 | 607 | ); |
608 | - if ( ! empty( $field['options'] ) ) { |
|
609 | - $data['options'] = $field['options']; |
|
608 | + if ( ! empty( $field[ 'options' ] ) ) { |
|
609 | + $data[ 'options' ] = $field[ 'options' ]; |
|
610 | 610 | } |
611 | 611 | $settings[ $id ] = $data; |
612 | 612 | } |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | $expected = array( |
617 | 617 | 'id' => $instance_id, |
618 | 618 | 'instance_id' => $instance_id, |
619 | - 'title' => $method->instance_settings['title'], |
|
619 | + 'title' => $method->instance_settings[ 'title' ], |
|
620 | 620 | 'order' => $method->method_order, |
621 | 621 | 'enabled' => ( 'yes' === $method->enabled ), |
622 | 622 | 'method_id' => $method->id, |
@@ -702,12 +702,12 @@ discard block |
||
702 | 702 | $response = $this->server->dispatch( $request ); |
703 | 703 | $data = $response->get_data(); |
704 | 704 | |
705 | - $this->assertArrayHasKey( 'title', $data['settings'] ); |
|
706 | - $this->assertEquals( 'Flat rate', $data['settings']['title']['value'] ); |
|
707 | - $this->assertArrayHasKey( 'tax_status', $data['settings'] ); |
|
708 | - $this->assertEquals( 'taxable', $data['settings']['tax_status']['value'] ); |
|
709 | - $this->assertArrayHasKey( 'cost', $data['settings'] ); |
|
710 | - $this->assertEquals( '0', $data['settings']['cost']['value'] ); |
|
705 | + $this->assertArrayHasKey( 'title', $data[ 'settings' ] ); |
|
706 | + $this->assertEquals( 'Flat rate', $data[ 'settings' ][ 'title' ][ 'value' ] ); |
|
707 | + $this->assertArrayHasKey( 'tax_status', $data[ 'settings' ] ); |
|
708 | + $this->assertEquals( 'taxable', $data[ 'settings' ][ 'tax_status' ][ 'value' ] ); |
|
709 | + $this->assertArrayHasKey( 'cost', $data[ 'settings' ] ); |
|
710 | + $this->assertEquals( '0', $data[ 'settings' ][ 'cost' ][ 'value' ] ); |
|
711 | 711 | |
712 | 712 | // Update a single value |
713 | 713 | $request = new WP_REST_Request( 'POST', '/wc/v3/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id ); |
@@ -721,12 +721,12 @@ discard block |
||
721 | 721 | $response = $this->server->dispatch( $request ); |
722 | 722 | $data = $response->get_data(); |
723 | 723 | |
724 | - $this->assertArrayHasKey( 'title', $data['settings'] ); |
|
725 | - $this->assertEquals( 'Flat rate', $data['settings']['title']['value'] ); |
|
726 | - $this->assertArrayHasKey( 'tax_status', $data['settings'] ); |
|
727 | - $this->assertEquals( 'taxable', $data['settings']['tax_status']['value'] ); |
|
728 | - $this->assertArrayHasKey( 'cost', $data['settings'] ); |
|
729 | - $this->assertEquals( '5', $data['settings']['cost']['value'] ); |
|
724 | + $this->assertArrayHasKey( 'title', $data[ 'settings' ] ); |
|
725 | + $this->assertEquals( 'Flat rate', $data[ 'settings' ][ 'title' ][ 'value' ] ); |
|
726 | + $this->assertArrayHasKey( 'tax_status', $data[ 'settings' ] ); |
|
727 | + $this->assertEquals( 'taxable', $data[ 'settings' ][ 'tax_status' ][ 'value' ] ); |
|
728 | + $this->assertArrayHasKey( 'cost', $data[ 'settings' ] ); |
|
729 | + $this->assertEquals( '5', $data[ 'settings' ][ 'cost' ][ 'value' ] ); |
|
730 | 730 | |
731 | 731 | // Test multiple settings |
732 | 732 | $request = new WP_REST_Request( 'POST', '/wc/v3/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id ); |
@@ -741,12 +741,12 @@ discard block |
||
741 | 741 | $response = $this->server->dispatch( $request ); |
742 | 742 | $data = $response->get_data(); |
743 | 743 | |
744 | - $this->assertArrayHasKey( 'title', $data['settings'] ); |
|
745 | - $this->assertEquals( 'Flat rate', $data['settings']['title']['value'] ); |
|
746 | - $this->assertArrayHasKey( 'tax_status', $data['settings'] ); |
|
747 | - $this->assertEquals( 'none', $data['settings']['tax_status']['value'] ); |
|
748 | - $this->assertArrayHasKey( 'cost', $data['settings'] ); |
|
749 | - $this->assertEquals( '10', $data['settings']['cost']['value'] ); |
|
744 | + $this->assertArrayHasKey( 'title', $data[ 'settings' ] ); |
|
745 | + $this->assertEquals( 'Flat rate', $data[ 'settings' ][ 'title' ][ 'value' ] ); |
|
746 | + $this->assertArrayHasKey( 'tax_status', $data[ 'settings' ] ); |
|
747 | + $this->assertEquals( 'none', $data[ 'settings' ][ 'tax_status' ][ 'value' ] ); |
|
748 | + $this->assertArrayHasKey( 'cost', $data[ 'settings' ] ); |
|
749 | + $this->assertEquals( '10', $data[ 'settings' ][ 'cost' ][ 'value' ] ); |
|
750 | 750 | |
751 | 751 | // Test bogus |
752 | 752 | $request = new WP_REST_Request( 'POST', '/wc/v3/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id ); |
@@ -762,8 +762,8 @@ discard block |
||
762 | 762 | $this->assertEquals( 400, $response->get_status() ); |
763 | 763 | |
764 | 764 | // Test other parameters |
765 | - $this->assertTrue( $data['enabled'] ); |
|
766 | - $this->assertEquals( 1, $data['order'] ); |
|
765 | + $this->assertTrue( $data[ 'enabled' ] ); |
|
766 | + $this->assertEquals( 1, $data[ 'order' ] ); |
|
767 | 767 | |
768 | 768 | $request = new WP_REST_Request( 'POST', '/wc/v3/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id ); |
769 | 769 | $request->set_body_params( |
@@ -775,10 +775,10 @@ discard block |
||
775 | 775 | $response = $this->server->dispatch( $request ); |
776 | 776 | $data = $response->get_data(); |
777 | 777 | |
778 | - $this->assertFalse( $data['enabled'] ); |
|
779 | - $this->assertEquals( 2, $data['order'] ); |
|
780 | - $this->assertArrayHasKey( 'cost', $data['settings'] ); |
|
781 | - $this->assertEquals( '10', $data['settings']['cost']['value'] ); |
|
778 | + $this->assertFalse( $data[ 'enabled' ] ); |
|
779 | + $this->assertEquals( 2, $data[ 'order' ] ); |
|
780 | + $this->assertArrayHasKey( 'cost', $data[ 'settings' ] ); |
|
781 | + $this->assertEquals( '10', $data[ 'settings' ][ 'cost' ][ 'value' ] ); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
@@ -800,10 +800,10 @@ discard block |
||
800 | 800 | $response = $this->server->dispatch( $request ); |
801 | 801 | $data = $response->get_data(); |
802 | 802 | |
803 | - $this->assertFalse( $data['enabled'] ); |
|
804 | - $this->assertEquals( 2, $data['order'] ); |
|
805 | - $this->assertArrayHasKey( 'cost', $data['settings'] ); |
|
806 | - $this->assertEquals( '0', $data['settings']['cost']['value'] ); |
|
803 | + $this->assertFalse( $data[ 'enabled' ] ); |
|
804 | + $this->assertEquals( 2, $data[ 'order' ] ); |
|
805 | + $this->assertArrayHasKey( 'cost', $data[ 'settings' ] ); |
|
806 | + $this->assertEquals( '0', $data[ 'settings' ][ 'cost' ][ 'value' ] ); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | continue; |
49 | 49 | } |
50 | 50 | |
51 | - $data[] = array( |
|
51 | + $data[ ] = array( |
|
52 | 52 | 'slug' => str_replace( 'wc-', '', $slug ), |
53 | 53 | 'name' => $name, |
54 | 54 | 'total' => (int) $totals->$slug, |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v3/reports/orders/totals' ); |
83 | 83 | $response = $this->server->dispatch( $request ); |
84 | 84 | $data = $response->get_data(); |
85 | - $properties = $data['schema']['properties']; |
|
85 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
86 | 86 | |
87 | 87 | $this->assertEquals( 3, count( $properties ) ); |
88 | 88 | $this->assertArrayHasKey( 'slug', $properties ); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v3/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/v3/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( 10, count( $properties ) ); |
145 | 145 | $this->assertArrayHasKey( 'id', $properties ); |
146 | 146 | $this->assertArrayHasKey( 'label', $properties ); |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/test' ) ); |
179 | 179 | $data = $response->get_data(); |
180 | 180 | $this->assertEquals( 1, count( $data ) ); |
181 | - $this->assertEquals( 'woocommerce_shop_page_display', $data[0]['id'] ); |
|
182 | - $this->assertEmpty( $data[0]['value'] ); |
|
181 | + $this->assertEquals( 'woocommerce_shop_page_display', $data[ 0 ][ 'id' ] ); |
|
182 | + $this->assertEmpty( $data[ 0 ][ 'value' ] ); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | // test defaults first |
206 | 206 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/test/woocommerce_shop_page_display' ) ); |
207 | 207 | $data = $response->get_data(); |
208 | - $this->assertEquals( '', $data['value'] ); |
|
208 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
209 | 209 | |
210 | 210 | // test updating shop display setting |
211 | 211 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v3/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $response = $this->server->dispatch( $request ); |
218 | 218 | $data = $response->get_data(); |
219 | 219 | |
220 | - $this->assertEquals( 'both', $data['value'] ); |
|
220 | + $this->assertEquals( 'both', $data[ 'value' ] ); |
|
221 | 221 | $this->assertEquals( 'both', get_option( 'woocommerce_shop_page_display' ) ); |
222 | 222 | |
223 | 223 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v3/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $response = $this->server->dispatch( $request ); |
230 | 230 | $data = $response->get_data(); |
231 | 231 | |
232 | - $this->assertEquals( 'subcategories', $data['value'] ); |
|
232 | + $this->assertEquals( 'subcategories', $data[ 'value' ] ); |
|
233 | 233 | $this->assertEquals( 'subcategories', get_option( 'woocommerce_shop_page_display' ) ); |
234 | 234 | |
235 | 235 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v3/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $response = $this->server->dispatch( $request ); |
242 | 242 | $data = $response->get_data(); |
243 | 243 | |
244 | - $this->assertEquals( '', $data['value'] ); |
|
244 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
245 | 245 | $this->assertEquals( '', get_option( 'woocommerce_shop_page_display' ) ); |
246 | 246 | } |
247 | 247 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | // test defaults first |
257 | 257 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/test' ) ); |
258 | 258 | $data = $response->get_data(); |
259 | - $this->assertEquals( '', $data[0]['value'] ); |
|
259 | + $this->assertEquals( '', $data[ 0 ][ 'value' ] ); |
|
260 | 260 | |
261 | 261 | // test setting both at once |
262 | 262 | $request = new WP_REST_Request( 'POST', '/wc/v3/settings/test/batch' ); |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $response = $this->server->dispatch( $request ); |
274 | 274 | $data = $response->get_data(); |
275 | 275 | |
276 | - $this->assertEquals( 'both', $data['update'][0]['value'] ); |
|
276 | + $this->assertEquals( 'both', $data[ 'update' ][ 0 ][ 'value' ] ); |
|
277 | 277 | $this->assertEquals( 'both', get_option( 'woocommerce_shop_page_display' ) ); |
278 | 278 | |
279 | 279 | // test updating one, but making sure the other value stays the same |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | ); |
291 | 291 | $response = $this->server->dispatch( $request ); |
292 | 292 | $data = $response->get_data(); |
293 | - $this->assertEquals( 'subcategories', $data['update'][0]['value'] ); |
|
293 | + $this->assertEquals( 'subcategories', $data[ 'update' ][ 0 ][ 'value' ] ); |
|
294 | 294 | $this->assertEquals( 'subcategories', get_option( 'woocommerce_shop_page_display' ) ); |
295 | 295 | } |
296 | 296 | |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | |
319 | 319 | $this->assertEquals( 200, $response->get_status() ); |
320 | 320 | |
321 | - $this->assertEquals( 'woocommerce_shop_page_display', $data['id'] ); |
|
322 | - $this->assertEquals( 'Shop page display', $data['label'] ); |
|
323 | - $this->assertEquals( '', $data['default'] ); |
|
324 | - $this->assertEquals( 'select', $data['type'] ); |
|
325 | - $this->assertEquals( '', $data['value'] ); |
|
321 | + $this->assertEquals( 'woocommerce_shop_page_display', $data[ 'id' ] ); |
|
322 | + $this->assertEquals( 'Shop page display', $data[ 'label' ] ); |
|
323 | + $this->assertEquals( '', $data[ 'default' ] ); |
|
324 | + $this->assertEquals( 'select', $data[ 'type' ] ); |
|
325 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/products/woocommerce_dimension_unit' ) ); |
486 | 486 | $data = $response->get_data(); |
487 | 487 | |
488 | - $this->assertEquals( 'cm', $data['default'] ); |
|
488 | + $this->assertEquals( 'cm', $data[ 'default' ] ); |
|
489 | 489 | |
490 | 490 | // test update |
491 | 491 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v3/settings/%s/%s', 'products', 'woocommerce_dimension_unit' ) ); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | $response = $this->server->dispatch( $request ); |
498 | 498 | $data = $response->get_data(); |
499 | 499 | |
500 | - $this->assertEquals( 'yd', $data['value'] ); |
|
500 | + $this->assertEquals( 'yd', $data[ 'value' ] ); |
|
501 | 501 | $this->assertEquals( 'yd', get_option( 'woocommerce_dimension_unit' ) ); |
502 | 502 | } |
503 | 503 | |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $response = $this->server->dispatch( $request ); |
587 | 587 | $setting = $response->get_data(); |
588 | 588 | |
589 | - $this->assertEmpty( $setting['value'] ); |
|
589 | + $this->assertEmpty( $setting[ 'value' ] ); |
|
590 | 590 | |
591 | 591 | // test update |
592 | 592 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v3/settings/%s/%s', 'email_customer_new_account', 'subject' ) ); |
@@ -598,13 +598,13 @@ discard block |
||
598 | 598 | $response = $this->server->dispatch( $request ); |
599 | 599 | $setting = $response->get_data(); |
600 | 600 | |
601 | - $this->assertEquals( 'This is my new subject', $setting['value'] ); |
|
601 | + $this->assertEquals( 'This is my new subject', $setting[ 'value' ] ); |
|
602 | 602 | |
603 | 603 | // make sure the other is what we left it |
604 | 604 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/email_new_order/subject' ) ); |
605 | 605 | $setting = $response->get_data(); |
606 | 606 | |
607 | - $this->assertEquals( 'This is my subject', $setting['value'] ); |
|
607 | + $this->assertEquals( 'This is my subject', $setting[ 'value' ] ); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | |
686 | 686 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', sprintf( '/wc/v3/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries' ) ) ); |
687 | 687 | $setting = $response->get_data(); |
688 | - $this->assertEmpty( $setting['value'] ); |
|
688 | + $this->assertEmpty( $setting[ 'value' ] ); |
|
689 | 689 | |
690 | 690 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v3/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries' ) ); |
691 | 691 | $request->set_body_params( |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | ); |
696 | 696 | $response = $this->server->dispatch( $request ); |
697 | 697 | $setting = $response->get_data(); |
698 | - $this->assertEquals( array( 'AX', 'DZ' ), $setting['value'] ); |
|
698 | + $this->assertEquals( array( 'AX', 'DZ' ), $setting[ 'value' ] ); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', sprintf( '/wc/v3/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) ) ); |
710 | 710 | $setting = $response->get_data(); |
711 | - $this->assertEquals( 'kg', $setting['value'] ); |
|
711 | + $this->assertEquals( 'kg', $setting[ 'value' ] ); |
|
712 | 712 | |
713 | 713 | // invalid |
714 | 714 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v3/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) ); |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | ); |
730 | 730 | $response = $this->server->dispatch( $request ); |
731 | 731 | $setting = $response->get_data(); |
732 | - $this->assertEquals( 'lbs', $setting['value'] ); |
|
732 | + $this->assertEquals( 'lbs', $setting[ 'value' ] ); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | /** |
@@ -744,9 +744,9 @@ discard block |
||
744 | 744 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/general/woocommerce_default_country' ) ); |
745 | 745 | $setting = $response->get_data(); |
746 | 746 | |
747 | - $this->assertEquals( 'select', $setting['type'] ); |
|
748 | - $this->assertArrayHasKey( 'GB', $setting['options'] ); |
|
749 | - $this->assertArrayHasKey( 'US:OR', $setting['options'] ); |
|
747 | + $this->assertEquals( 'select', $setting[ 'type' ] ); |
|
748 | + $this->assertArrayHasKey( 'GB', $setting[ 'options' ] ); |
|
749 | + $this->assertArrayHasKey( 'US:OR', $setting[ 'options' ] ); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | /** |
@@ -758,10 +758,10 @@ discard block |
||
758 | 758 | wp_set_current_user( $this->user ); |
759 | 759 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/general/woocommerce_store_address' ) ); |
760 | 760 | $setting = $response->get_data(); |
761 | - $this->assertEquals( 'text', $setting['type'] ); |
|
761 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
762 | 762 | |
763 | 763 | // Repalce the old value with something uniquely new |
764 | - $old_value = $setting['value']; |
|
764 | + $old_value = $setting[ 'value' ]; |
|
765 | 765 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
766 | 766 | $request = new WP_REST_Request( 'PUT', '/wc/v3/settings/general/woocommerce_store_address' ); |
767 | 767 | $request->set_body_params( |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | ); |
772 | 772 | $response = $this->server->dispatch( $request ); |
773 | 773 | $setting = $response->get_data(); |
774 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
774 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
775 | 775 | |
776 | 776 | // Put the original value back |
777 | 777 | $request = new WP_REST_Request( 'PUT', '/wc/v3/settings/general/woocommerce_store_address' ); |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | ); |
783 | 783 | $response = $this->server->dispatch( $request ); |
784 | 784 | $setting = $response->get_data(); |
785 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
785 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | /** |
@@ -794,10 +794,10 @@ discard block |
||
794 | 794 | wp_set_current_user( $this->user ); |
795 | 795 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/general/woocommerce_store_address_2' ) ); |
796 | 796 | $setting = $response->get_data(); |
797 | - $this->assertEquals( 'text', $setting['type'] ); |
|
797 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
798 | 798 | |
799 | 799 | // Repalce the old value with something uniquely new |
800 | - $old_value = $setting['value']; |
|
800 | + $old_value = $setting[ 'value' ]; |
|
801 | 801 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
802 | 802 | $request = new WP_REST_Request( 'PUT', '/wc/v3/settings/general/woocommerce_store_address_2' ); |
803 | 803 | $request->set_body_params( |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | ); |
808 | 808 | $response = $this->server->dispatch( $request ); |
809 | 809 | $setting = $response->get_data(); |
810 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
810 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
811 | 811 | |
812 | 812 | // Put the original value back |
813 | 813 | $request = new WP_REST_Request( 'PUT', '/wc/v3/settings/general/woocommerce_store_address_2' ); |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | ); |
819 | 819 | $response = $this->server->dispatch( $request ); |
820 | 820 | $setting = $response->get_data(); |
821 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
821 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | /** |
@@ -830,10 +830,10 @@ discard block |
||
830 | 830 | wp_set_current_user( $this->user ); |
831 | 831 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/general/woocommerce_store_city' ) ); |
832 | 832 | $setting = $response->get_data(); |
833 | - $this->assertEquals( 'text', $setting['type'] ); |
|
833 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
834 | 834 | |
835 | 835 | // Repalce the old value with something uniquely new |
836 | - $old_value = $setting['value']; |
|
836 | + $old_value = $setting[ 'value' ]; |
|
837 | 837 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
838 | 838 | $request = new WP_REST_Request( 'PUT', '/wc/v3/settings/general/woocommerce_store_city' ); |
839 | 839 | $request->set_body_params( |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | ); |
844 | 844 | $response = $this->server->dispatch( $request ); |
845 | 845 | $setting = $response->get_data(); |
846 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
846 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
847 | 847 | |
848 | 848 | // Put the original value back |
849 | 849 | $request = new WP_REST_Request( 'PUT', '/wc/v3/settings/general/woocommerce_store_city' ); |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | ); |
855 | 855 | $response = $this->server->dispatch( $request ); |
856 | 856 | $setting = $response->get_data(); |
857 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
857 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | /** |
@@ -866,10 +866,10 @@ discard block |
||
866 | 866 | wp_set_current_user( $this->user ); |
867 | 867 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/general/woocommerce_store_postcode' ) ); |
868 | 868 | $setting = $response->get_data(); |
869 | - $this->assertEquals( 'text', $setting['type'] ); |
|
869 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
870 | 870 | |
871 | 871 | // Repalce the old value with something uniquely new |
872 | - $old_value = $setting['value']; |
|
872 | + $old_value = $setting[ 'value' ]; |
|
873 | 873 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
874 | 874 | $request = new WP_REST_Request( 'PUT', '/wc/v3/settings/general/woocommerce_store_postcode' ); |
875 | 875 | $request->set_body_params( |
@@ -879,7 +879,7 @@ discard block |
||
879 | 879 | ); |
880 | 880 | $response = $this->server->dispatch( $request ); |
881 | 881 | $setting = $response->get_data(); |
882 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
882 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
883 | 883 | |
884 | 884 | // Put the original value back |
885 | 885 | $request = new WP_REST_Request( 'PUT', '/wc/v3/settings/general/woocommerce_store_postcode' ); |
@@ -890,6 +890,6 @@ discard block |
||
890 | 890 | ); |
891 | 891 | $response = $this->server->dispatch( $request ); |
892 | 892 | $setting = $response->get_data(); |
893 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
893 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
894 | 894 | } |
895 | 895 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | - $total = isset( $results[0] ) ? (int) $results[0]->total : 0; |
|
60 | + $total = isset( $results[ 0 ] ) ? (int) $results[ 0 ]->total : 0; |
|
61 | 61 | |
62 | - $data[] = array( |
|
62 | + $data[ ] = array( |
|
63 | 63 | 'slug' => $slug, |
64 | 64 | 'name' => $name, |
65 | 65 | 'total' => $total, |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v3/reports/coupons/totals' ); |
94 | 94 | $response = $this->server->dispatch( $request ); |
95 | 95 | $data = $response->get_data(); |
96 | - $properties = $data['schema']['properties']; |
|
96 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
97 | 97 | |
98 | 98 | $this->assertEquals( 3, count( $properties ) ); |
99 | 99 | $this->assertArrayHasKey( 'slug', $properties ); |