@@ -111,21 +111,21 @@ discard block |
||
111 | 111 | global $wpdb; |
112 | 112 | |
113 | 113 | $prepared_args = array(); |
114 | - $prepared_args['order'] = $request['order']; |
|
115 | - $prepared_args['number'] = $request['per_page']; |
|
116 | - if ( ! empty( $request['offset'] ) ) { |
|
117 | - $prepared_args['offset'] = $request['offset']; |
|
114 | + $prepared_args[ 'order' ] = $request[ 'order' ]; |
|
115 | + $prepared_args[ 'number' ] = $request[ 'per_page' ]; |
|
116 | + if ( ! empty( $request[ 'offset' ] ) ) { |
|
117 | + $prepared_args[ 'offset' ] = $request[ 'offset' ]; |
|
118 | 118 | } else { |
119 | - $prepared_args['offset'] = ( $request['page'] - 1 ) * $prepared_args['number']; |
|
119 | + $prepared_args[ 'offset' ] = ( $request[ 'page' ] - 1 ) * $prepared_args[ 'number' ]; |
|
120 | 120 | } |
121 | 121 | $orderby_possibles = array( |
122 | 122 | 'id' => 'tax_rate_id', |
123 | 123 | 'order' => 'tax_rate_order', |
124 | 124 | ); |
125 | - $prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ]; |
|
126 | - $prepared_args['class'] = $request['class']; |
|
127 | - $prepared_args['code'] = $request['code']; |
|
128 | - $prepared_args['include'] = $request['include']; |
|
125 | + $prepared_args[ 'orderby' ] = $orderby_possibles[ $request[ 'orderby' ] ]; |
|
126 | + $prepared_args[ 'class' ] = $request[ 'class' ]; |
|
127 | + $prepared_args[ 'code' ] = $request[ 'code' ]; |
|
128 | + $prepared_args[ 'include' ] = $request[ 'include' ]; |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * Filter arguments, before passing to $wpdb->get_results(), when querying taxes via the REST API. |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | "; |
143 | 143 | |
144 | 144 | // Filter by tax class. |
145 | - if ( ! empty( $prepared_args['class'] ) ) { |
|
146 | - $class = 'standard' !== $prepared_args['class'] ? sanitize_title( $prepared_args['class'] ) : ''; |
|
145 | + if ( ! empty( $prepared_args[ 'class' ] ) ) { |
|
146 | + $class = 'standard' !== $prepared_args[ 'class' ] ? sanitize_title( $prepared_args[ 'class' ] ) : ''; |
|
147 | 147 | $query .= " AND tax_rate_class = '$class'"; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Filter by tax code. |
151 | - $tax_code_search = $prepared_args['code']; |
|
151 | + $tax_code_search = $prepared_args[ 'code' ]; |
|
152 | 152 | if ( $tax_code_search ) { |
153 | 153 | $tax_code_search = $wpdb->esc_like( $tax_code_search ); |
154 | 154 | $tax_code_search = ' \'%' . $tax_code_search . '%\''; |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | // Filter by included tax rate IDs. |
159 | - $included_taxes = $prepared_args['include']; |
|
159 | + $included_taxes = $prepared_args[ 'include' ]; |
|
160 | 160 | if ( ! empty( $included_taxes ) ) { |
161 | - $included_taxes = implode( ',', $prepared_args['include'] ); |
|
161 | + $included_taxes = implode( ',', $prepared_args[ 'include' ] ); |
|
162 | 162 | $query .= " AND tax_rate_id IN ({$included_taxes})"; |
163 | 163 | } |
164 | 164 | |
165 | 165 | // Order tax rates. |
166 | - $order_by = sprintf( ' ORDER BY %s', sanitize_key( $prepared_args['orderby'] ) ); |
|
166 | + $order_by = sprintf( ' ORDER BY %s', sanitize_key( $prepared_args[ 'orderby' ] ) ); |
|
167 | 167 | |
168 | 168 | // Pagination. |
169 | - $pagination = sprintf( ' LIMIT %d, %d', $prepared_args['offset'], $prepared_args['number'] ); |
|
169 | + $pagination = sprintf( ' LIMIT %d, %d', $prepared_args[ 'offset' ], $prepared_args[ 'number' ] ); |
|
170 | 170 | |
171 | 171 | // Query taxes. |
172 | 172 | $results = $wpdb->get_results( $query . $order_by . $pagination ); // @codingStandardsIgnoreLine. |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | $taxes = array(); |
175 | 175 | foreach ( $results as $tax ) { |
176 | 176 | $data = $this->prepare_item_for_response( $tax, $request ); |
177 | - $taxes[] = $this->prepare_response_for_collection( $data ); |
|
177 | + $taxes[ ] = $this->prepare_response_for_collection( $data ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // Store pagination values for headers then unset for count query. |
181 | - $per_page = (int) $prepared_args['number']; |
|
182 | - $page = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 ); |
|
181 | + $per_page = (int) $prepared_args[ 'number' ]; |
|
182 | + $page = ceil( ( ( (int) $prepared_args[ 'offset' ] ) / $per_page ) + 1 ); |
|
183 | 183 | |
184 | 184 | // Query only for ids. |
185 | 185 | $wpdb->get_results( str_replace( 'SELECT *', 'SELECT tax_rate_id', $query ) ); // @codingStandardsIgnoreLine. |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return object |
203 | 203 | */ |
204 | 204 | protected function create_or_update_tax( $request, $current = null ) { |
205 | - $id = absint( isset( $request['id'] ) ? $request['id'] : 0 ); |
|
205 | + $id = absint( isset( $request[ 'id' ] ) ? $request[ 'id' ] : 0 ); |
|
206 | 206 | $data = array(); |
207 | 207 | $fields = array( |
208 | 208 | 'tax_rate_country', |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $data[ $field ] = absint( $request[ $key ] ); |
240 | 240 | break; |
241 | 241 | case 'tax_rate_class': |
242 | - $data[ $field ] = 'standard' !== $request['tax_rate_class'] ? $request['tax_rate_class'] : ''; |
|
242 | + $data[ $field ] = 'standard' !== $request[ 'tax_rate_class' ] ? $request[ 'tax_rate_class' ] : ''; |
|
243 | 243 | break; |
244 | 244 | default: |
245 | 245 | $data[ $field ] = wc_clean( $request[ $key ] ); |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | // Add locales. |
257 | - if ( ! empty( $request['postcode'] ) ) { |
|
258 | - \WC_Tax::_update_tax_rate_postcodes( $id, wc_clean( $request['postcode'] ) ); |
|
257 | + if ( ! empty( $request[ 'postcode' ] ) ) { |
|
258 | + \WC_Tax::_update_tax_rate_postcodes( $id, wc_clean( $request[ 'postcode' ] ) ); |
|
259 | 259 | } |
260 | - if ( ! empty( $request['city'] ) ) { |
|
261 | - \WC_Tax::_update_tax_rate_cities( $id, wc_clean( $request['city'] ) ); |
|
260 | + if ( ! empty( $request[ 'city' ] ) ) { |
|
261 | + \WC_Tax::_update_tax_rate_cities( $id, wc_clean( $request[ 'city' ] ) ); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | return \WC_Tax::_get_tax_rate( $id, OBJECT ); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @return \WP_Error|\WP_REST_Response |
272 | 272 | */ |
273 | 273 | public function create_item( $request ) { |
274 | - if ( ! empty( $request['id'] ) ) { |
|
274 | + if ( ! empty( $request[ 'id' ] ) ) { |
|
275 | 275 | return new \WP_Error( 'woocommerce_rest_tax_exists', __( 'Cannot create existing resource.', 'woocommerce-rest-api' ), array( 'status' => 400 ) ); |
276 | 276 | } |
277 | 277 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @return \WP_Error|\WP_REST_Response |
305 | 305 | */ |
306 | 306 | public function get_item( $request ) { |
307 | - $id = (int) $request['id']; |
|
307 | + $id = (int) $request[ 'id' ]; |
|
308 | 308 | $tax_obj = \WC_Tax::_get_tax_rate( $id, OBJECT ); |
309 | 309 | |
310 | 310 | if ( empty( $id ) || empty( $tax_obj ) ) { |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @return \WP_Error|\WP_REST_Response |
325 | 325 | */ |
326 | 326 | public function update_item( $request ) { |
327 | - $id = (int) $request['id']; |
|
327 | + $id = (int) $request[ 'id' ]; |
|
328 | 328 | $tax_obj = \WC_Tax::_get_tax_rate( $id, OBJECT ); |
329 | 329 | |
330 | 330 | if ( empty( $id ) || empty( $tax_obj ) ) { |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | public function delete_item( $request ) { |
361 | 361 | global $wpdb; |
362 | 362 | |
363 | - $id = (int) $request['id']; |
|
364 | - $force = isset( $request['force'] ) ? (bool) $request['force'] : false; |
|
363 | + $id = (int) $request[ 'id' ]; |
|
364 | + $force = isset( $request[ 'force' ] ) ? (bool) $request[ 'force' ] : false; |
|
365 | 365 | |
366 | 366 | // We don't support trashing for this type, error out. |
367 | 367 | if ( ! $force ) { |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | */ |
552 | 552 | public function get_collection_params() { |
553 | 553 | $params = array(); |
554 | - $params['context'] = $this->get_context_param(); |
|
555 | - $params['context']['default'] = 'view'; |
|
554 | + $params[ 'context' ] = $this->get_context_param(); |
|
555 | + $params[ 'context' ][ 'default' ] = 'view'; |
|
556 | 556 | |
557 | - $params['page'] = array( |
|
557 | + $params[ 'page' ] = array( |
|
558 | 558 | 'description' => __( 'Current page of the collection.', 'woocommerce-rest-api' ), |
559 | 559 | 'type' => 'integer', |
560 | 560 | 'default' => 1, |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | 'validate_callback' => 'rest_validate_request_arg', |
563 | 563 | 'minimum' => 1, |
564 | 564 | ); |
565 | - $params['per_page'] = array( |
|
565 | + $params[ 'per_page' ] = array( |
|
566 | 566 | 'description' => __( 'Maximum number of items to be returned in result set.', 'woocommerce-rest-api' ), |
567 | 567 | 'type' => 'integer', |
568 | 568 | 'default' => 10, |
@@ -571,13 +571,13 @@ discard block |
||
571 | 571 | 'sanitize_callback' => 'absint', |
572 | 572 | 'validate_callback' => 'rest_validate_request_arg', |
573 | 573 | ); |
574 | - $params['offset'] = array( |
|
574 | + $params[ 'offset' ] = array( |
|
575 | 575 | 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce-rest-api' ), |
576 | 576 | 'type' => 'integer', |
577 | 577 | 'sanitize_callback' => 'absint', |
578 | 578 | 'validate_callback' => 'rest_validate_request_arg', |
579 | 579 | ); |
580 | - $params['order'] = array( |
|
580 | + $params[ 'order' ] = array( |
|
581 | 581 | 'default' => 'asc', |
582 | 582 | 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce-rest-api' ), |
583 | 583 | 'enum' => array( 'asc', 'desc' ), |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | 'type' => 'string', |
586 | 586 | 'validate_callback' => 'rest_validate_request_arg', |
587 | 587 | ); |
588 | - $params['orderby'] = array( |
|
588 | + $params[ 'orderby' ] = array( |
|
589 | 589 | 'default' => 'order', |
590 | 590 | 'description' => __( 'Sort collection by object attribute.', 'woocommerce-rest-api' ), |
591 | 591 | 'enum' => array( |
@@ -596,19 +596,19 @@ discard block |
||
596 | 596 | 'type' => 'string', |
597 | 597 | 'validate_callback' => 'rest_validate_request_arg', |
598 | 598 | ); |
599 | - $params['class'] = array( |
|
599 | + $params[ 'class' ] = array( |
|
600 | 600 | 'description' => __( 'Sort by tax class.', 'woocommerce-rest-api' ), |
601 | 601 | 'enum' => array_merge( array( 'standard' ), \WC_Tax::get_tax_class_slugs() ), |
602 | 602 | 'sanitize_callback' => 'sanitize_title', |
603 | 603 | 'type' => 'string', |
604 | 604 | 'validate_callback' => 'rest_validate_request_arg', |
605 | 605 | ); |
606 | - $params['code'] = array( |
|
606 | + $params[ 'code' ] = array( |
|
607 | 607 | 'description' => __( 'Search by similar tax code.', 'woocommerce-rest-api' ), |
608 | 608 | 'type' => 'string', |
609 | 609 | 'validate_callback' => 'rest_validate_request_arg', |
610 | 610 | ); |
611 | - $params['include'] = array( |
|
611 | + $params[ 'include' ] = array( |
|
612 | 612 | 'description' => __( 'Limit result set to items that have the specified rate ID(s) assigned.', 'woocommerce-rest-api' ), |
613 | 613 | 'type' => 'array', |
614 | 614 | 'items' => array( |
@@ -100,7 +100,7 @@ |
||
100 | 100 | |
101 | 101 | \WC_Install::install(); |
102 | 102 | |
103 | - $GLOBALS['wp_roles'] = null; // WPCS: override ok. |
|
103 | + $GLOBALS[ 'wp_roles' ] = null; // WPCS: override ok. |
|
104 | 104 | \wp_roles(); |
105 | 105 | } ); |
106 | 106 | } |
@@ -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 ); |