@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | $variations = $response->get_data(); |
| 68 | 68 | $this->assertEquals( 200, $response->get_status() ); |
| 69 | 69 | $this->assertEquals( 2, count( $variations ) ); |
| 70 | - $this->assertEquals( 'DUMMY SKU VARIABLE LARGE', $variations[0]['sku'] ); |
|
| 71 | - $this->assertEquals( 'size', $variations[0]['attributes'][0]['name'] ); |
|
| 70 | + $this->assertEquals( 'DUMMY SKU VARIABLE LARGE', $variations[ 0 ][ 'sku' ] ); |
|
| 71 | + $this->assertEquals( 'size', $variations[ 0 ][ 'attributes' ][ 0 ][ 'name' ] ); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | public function test_get_variation() { |
| 92 | 92 | $product = ProductHelper::create_variation_product(); |
| 93 | 93 | $children = $product->get_children(); |
| 94 | - $variation_id = $children[0]; |
|
| 94 | + $variation_id = $children[ 0 ]; |
|
| 95 | 95 | |
| 96 | 96 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ) ); |
| 97 | 97 | $variation = $response->get_data(); |
| 98 | 98 | |
| 99 | 99 | $this->assertEquals( 200, $response->get_status() ); |
| 100 | - $this->assertEquals( $variation_id, $variation['id'] ); |
|
| 101 | - $this->assertEquals( 'size', $variation['attributes'][0]['name'] ); |
|
| 100 | + $this->assertEquals( $variation_id, $variation[ 'id' ] ); |
|
| 101 | + $this->assertEquals( 'size', $variation[ 'attributes' ][ 0 ][ 'name' ] ); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | wp_set_current_user( 0 ); |
| 111 | 111 | $product = ProductHelper::create_variation_product(); |
| 112 | 112 | $children = $product->get_children(); |
| 113 | - $variation_id = $children[0]; |
|
| 113 | + $variation_id = $children[ 0 ]; |
|
| 114 | 114 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ) ); |
| 115 | 115 | $this->assertEquals( 401, $response->get_status() ); |
| 116 | 116 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | public function test_delete_variation() { |
| 124 | 124 | $product = ProductHelper::create_variation_product(); |
| 125 | 125 | $children = $product->get_children(); |
| 126 | - $variation_id = $children[0]; |
|
| 126 | + $variation_id = $children[ 0 ]; |
|
| 127 | 127 | |
| 128 | 128 | $request = new WP_REST_Request( 'DELETE', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ); |
| 129 | 129 | $request->set_param( 'force', true ); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | wp_set_current_user( 0 ); |
| 145 | 145 | $product = ProductHelper::create_variation_product(); |
| 146 | 146 | $children = $product->get_children(); |
| 147 | - $variation_id = $children[0]; |
|
| 147 | + $variation_id = $children[ 0 ]; |
|
| 148 | 148 | |
| 149 | 149 | $request = new WP_REST_Request( 'DELETE', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ); |
| 150 | 150 | $request->set_param( 'force', true ); |
@@ -174,15 +174,15 @@ discard block |
||
| 174 | 174 | public function test_update_variation() { |
| 175 | 175 | $product = ProductHelper::create_variation_product(); |
| 176 | 176 | $children = $product->get_children(); |
| 177 | - $variation_id = $children[0]; |
|
| 177 | + $variation_id = $children[ 0 ]; |
|
| 178 | 178 | |
| 179 | 179 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ) ); |
| 180 | 180 | $variation = $response->get_data(); |
| 181 | 181 | |
| 182 | - $this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variation['sku'] ); |
|
| 183 | - $this->assertEquals( 10, $variation['regular_price'] ); |
|
| 184 | - $this->assertEmpty( $variation['sale_price'] ); |
|
| 185 | - $this->assertEquals( 'small', $variation['attributes'][0]['option'] ); |
|
| 182 | + $this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variation[ 'sku' ] ); |
|
| 183 | + $this->assertEquals( 10, $variation[ 'regular_price' ] ); |
|
| 184 | + $this->assertEmpty( $variation[ 'sale_price' ] ); |
|
| 185 | + $this->assertEquals( 'small', $variation[ 'attributes' ][ 0 ][ 'option' ] ); |
|
| 186 | 186 | |
| 187 | 187 | $request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ); |
| 188 | 188 | $request->set_body_params( |
@@ -206,15 +206,15 @@ discard block |
||
| 206 | 206 | $response = $this->server->dispatch( $request ); |
| 207 | 207 | $variation = $response->get_data(); |
| 208 | 208 | |
| 209 | - $this->assertTrue( isset( $variation['description'] ), print_r( $variation, true ) ); |
|
| 210 | - $this->assertContains( 'O_O', $variation['description'], print_r( $variation, true ) ); |
|
| 211 | - $this->assertEquals( '8', $variation['price'], print_r( $variation, true ) ); |
|
| 212 | - $this->assertEquals( '8', $variation['sale_price'], print_r( $variation, true ) ); |
|
| 213 | - $this->assertEquals( '10', $variation['regular_price'], print_r( $variation, true ) ); |
|
| 214 | - $this->assertEquals( 'FIXED-\'SKU', $variation['sku'], print_r( $variation, true ) ); |
|
| 215 | - $this->assertEquals( 'medium', $variation['attributes'][0]['option'], print_r( $variation, true ) ); |
|
| 216 | - $this->assertContains( 'Dr1Bczxq4q', $variation['image']['src'], print_r( $variation, true ) ); |
|
| 217 | - $this->assertContains( 'test upload image', $variation['image']['alt'], print_r( $variation, true ) ); |
|
| 209 | + $this->assertTrue( isset( $variation[ 'description' ] ), print_r( $variation, true ) ); |
|
| 210 | + $this->assertContains( 'O_O', $variation[ 'description' ], print_r( $variation, true ) ); |
|
| 211 | + $this->assertEquals( '8', $variation[ 'price' ], print_r( $variation, true ) ); |
|
| 212 | + $this->assertEquals( '8', $variation[ 'sale_price' ], print_r( $variation, true ) ); |
|
| 213 | + $this->assertEquals( '10', $variation[ 'regular_price' ], print_r( $variation, true ) ); |
|
| 214 | + $this->assertEquals( 'FIXED-\'SKU', $variation[ 'sku' ], print_r( $variation, true ) ); |
|
| 215 | + $this->assertEquals( 'medium', $variation[ 'attributes' ][ 0 ][ 'option' ], print_r( $variation, true ) ); |
|
| 216 | + $this->assertContains( 'Dr1Bczxq4q', $variation[ 'image' ][ 'src' ], print_r( $variation, true ) ); |
|
| 217 | + $this->assertContains( 'test upload image', $variation[ 'image' ][ 'alt' ], print_r( $variation, true ) ); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | wp_set_current_user( 0 ); |
| 227 | 227 | $product = ProductHelper::create_variation_product(); |
| 228 | 228 | $children = $product->get_children(); |
| 229 | - $variation_id = $children[0]; |
|
| 229 | + $variation_id = $children[ 0 ]; |
|
| 230 | 230 | |
| 231 | 231 | $request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ); |
| 232 | 232 | $request->set_body_params( |
@@ -284,12 +284,12 @@ discard block |
||
| 284 | 284 | $response = $this->server->dispatch( $request ); |
| 285 | 285 | $variation = $response->get_data(); |
| 286 | 286 | |
| 287 | - $this->assertContains( 'A medium size.', $variation['description'] ); |
|
| 288 | - $this->assertEquals( '12', $variation['price'] ); |
|
| 289 | - $this->assertEquals( '12', $variation['regular_price'] ); |
|
| 290 | - $this->assertTrue( $variation['purchasable'] ); |
|
| 291 | - $this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $variation['sku'] ); |
|
| 292 | - $this->assertEquals( 'medium', $variation['attributes'][0]['option'] ); |
|
| 287 | + $this->assertContains( 'A medium size.', $variation[ 'description' ] ); |
|
| 288 | + $this->assertEquals( '12', $variation[ 'price' ] ); |
|
| 289 | + $this->assertEquals( '12', $variation[ 'regular_price' ] ); |
|
| 290 | + $this->assertTrue( $variation[ 'purchasable' ] ); |
|
| 291 | + $this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $variation[ 'sku' ] ); |
|
| 292 | + $this->assertEquals( 'medium', $variation[ 'attributes' ][ 0 ][ 'option' ] ); |
|
| 293 | 293 | |
| 294 | 294 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() . '/variations' ) ); |
| 295 | 295 | $variations = $response->get_data(); |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | array( |
| 337 | 337 | 'update' => array( |
| 338 | 338 | array( |
| 339 | - 'id' => $children[0], |
|
| 339 | + 'id' => $children[ 0 ], |
|
| 340 | 340 | 'description' => 'Updated description.', |
| 341 | 341 | 'image' => array( |
| 342 | 342 | 'position' => 0, |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | ), |
| 347 | 347 | ), |
| 348 | 348 | 'delete' => array( |
| 349 | - $children[1], |
|
| 349 | + $children[ 1 ], |
|
| 350 | 350 | ), |
| 351 | 351 | 'create' => array( |
| 352 | 352 | array( |
@@ -366,10 +366,10 @@ discard block |
||
| 366 | 366 | $response = $this->server->dispatch( $request ); |
| 367 | 367 | $data = $response->get_data(); |
| 368 | 368 | |
| 369 | - $this->assertContains( 'Updated description.', $data['update'][0]['description'] ); |
|
| 370 | - $this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $data['create'][0]['sku'] ); |
|
| 371 | - $this->assertEquals( 'medium', $data['create'][0]['attributes'][0]['option'] ); |
|
| 372 | - $this->assertEquals( $children[1], $data['delete'][0]['previous']['id'] ); |
|
| 369 | + $this->assertContains( 'Updated description.', $data[ 'update' ][ 0 ][ 'description' ] ); |
|
| 370 | + $this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $data[ 'create' ][ 0 ][ 'sku' ] ); |
|
| 371 | + $this->assertEquals( 'medium', $data[ 'create' ][ 0 ][ 'attributes' ][ 0 ][ 'option' ] ); |
|
| 372 | + $this->assertEquals( $children[ 1 ], $data[ 'delete' ][ 0 ][ 'previous' ][ 'id' ] ); |
|
| 373 | 373 | |
| 374 | 374 | $request = new WP_REST_Request( 'GET', '/wc/v4/products/' . $product->get_id() . '/variations' ); |
| 375 | 375 | $response = $this->server->dispatch( $request ); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v4/products/' . $product->get_id() . '/variations' ); |
| 389 | 389 | $response = $this->server->dispatch( $request ); |
| 390 | 390 | $data = $response->get_data(); |
| 391 | - $properties = $data['schema']['properties']; |
|
| 391 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 392 | 392 | |
| 393 | 393 | $this->assertEquals( 40, count( $properties ) ); |
| 394 | 394 | $this->assertArrayHasKey( 'id', $properties ); |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $product->save(); |
| 439 | 439 | |
| 440 | 440 | $children = $product->get_children(); |
| 441 | - $variation_id = $children[0]; |
|
| 441 | + $variation_id = $children[ 0 ]; |
|
| 442 | 442 | |
| 443 | 443 | // Set stock to true. |
| 444 | 444 | $request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ); |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $variation = $response->get_data(); |
| 453 | 453 | |
| 454 | 454 | $this->assertEquals( 200, $response->get_status() ); |
| 455 | - $this->assertEquals( true, $variation['manage_stock'] ); |
|
| 455 | + $this->assertEquals( true, $variation[ 'manage_stock' ] ); |
|
| 456 | 456 | |
| 457 | 457 | // Set stock to false. |
| 458 | 458 | $request = new WP_REST_Request( 'PUT', '/wc/v4/products/' . $product->get_id() . '/variations/' . $variation_id ); |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | $variation = $response->get_data(); |
| 467 | 467 | |
| 468 | 468 | $this->assertEquals( 200, $response->get_status() ); |
| 469 | - $this->assertEquals( false, $variation['manage_stock'] ); |
|
| 469 | + $this->assertEquals( false, $variation[ 'manage_stock' ] ); |
|
| 470 | 470 | |
| 471 | 471 | // Set stock to false but parent is managing stock. |
| 472 | 472 | $product->set_manage_stock( true ); |
@@ -482,6 +482,6 @@ discard block |
||
| 482 | 482 | $variation = $response->get_data(); |
| 483 | 483 | |
| 484 | 484 | $this->assertEquals( 200, $response->get_status() ); |
| 485 | - $this->assertEquals( 'parent', $variation['manage_stock'] ); |
|
| 485 | + $this->assertEquals( 'parent', $variation[ 'manage_stock' ] ); |
|
| 486 | 486 | } |
| 487 | 487 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $this->assertEquals( 200, $response->get_status() ); |
| 61 | 61 | $this->assertEquals( 4, count( $data ) ); |
| 62 | - $this->assertEquals( 'download-ips', $data[3]['slug'] ); |
|
| 62 | + $this->assertEquals( 'download-ips', $data[ 3 ][ 'slug' ] ); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $this->assertEquals( 200, $response->get_status() ); |
| 128 | 128 | $this->assertEquals( 2, count( $addresses ) ); |
| 129 | 129 | |
| 130 | - $this->assertEquals( '54.2.1.3', $addresses[0]['user_ip_address'] ); |
|
| 131 | - $this->assertEquals( '54.5.1.7', $addresses[1]['user_ip_address'] ); |
|
| 130 | + $this->assertEquals( '54.2.1.3', $addresses[ 0 ][ 'user_ip_address' ] ); |
|
| 131 | + $this->assertEquals( '54.5.1.7', $addresses[ 1 ][ 'user_ip_address' ] ); |
|
| 132 | 132 | } |
| 133 | 133 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v4/settings' ); |
| 143 | 143 | $response = $this->server->dispatch( $request ); |
| 144 | 144 | $data = $response->get_data(); |
| 145 | - $properties = $data['schema']['properties']; |
|
| 145 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 146 | 146 | $this->assertEquals( 5, count( $properties ) ); |
| 147 | 147 | $this->assertArrayHasKey( 'id', $properties ); |
| 148 | 148 | $this->assertArrayHasKey( 'parent_id', $properties ); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v4/settings/test/woocommerce_shop_page_display' ); |
| 161 | 161 | $response = $this->server->dispatch( $request ); |
| 162 | 162 | $data = $response->get_data(); |
| 163 | - $properties = $data['schema']['properties']; |
|
| 163 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 164 | 164 | $this->assertEquals( 10, count( $properties ) ); |
| 165 | 165 | $this->assertArrayHasKey( 'id', $properties ); |
| 166 | 166 | $this->assertArrayHasKey( 'label', $properties ); |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test' ) ); |
| 197 | 197 | $data = $response->get_data(); |
| 198 | 198 | $this->assertEquals( 1, count( $data ) ); |
| 199 | - $this->assertEquals( 'woocommerce_shop_page_display', $data[0]['id'] ); |
|
| 200 | - $this->assertEmpty( $data[0]['value'] ); |
|
| 199 | + $this->assertEquals( 'woocommerce_shop_page_display', $data[ 0 ][ 'id' ] ); |
|
| 200 | + $this->assertEmpty( $data[ 0 ][ 'value' ] ); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | // test defaults first |
| 222 | 222 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test/woocommerce_shop_page_display' ) ); |
| 223 | 223 | $data = $response->get_data(); |
| 224 | - $this->assertEquals( '', $data['value'] ); |
|
| 224 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
| 225 | 225 | |
| 226 | 226 | // test updating shop display setting |
| 227 | 227 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $response = $this->server->dispatch( $request ); |
| 234 | 234 | $data = $response->get_data(); |
| 235 | 235 | |
| 236 | - $this->assertEquals( 'both', $data['value'] ); |
|
| 236 | + $this->assertEquals( 'both', $data[ 'value' ] ); |
|
| 237 | 237 | $this->assertEquals( 'both', get_option( 'woocommerce_shop_page_display' ) ); |
| 238 | 238 | |
| 239 | 239 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $response = $this->server->dispatch( $request ); |
| 246 | 246 | $data = $response->get_data(); |
| 247 | 247 | |
| 248 | - $this->assertEquals( 'subcategories', $data['value'] ); |
|
| 248 | + $this->assertEquals( 'subcategories', $data[ 'value' ] ); |
|
| 249 | 249 | $this->assertEquals( 'subcategories', get_option( 'woocommerce_shop_page_display' ) ); |
| 250 | 250 | |
| 251 | 251 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) ); |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $response = $this->server->dispatch( $request ); |
| 258 | 258 | $data = $response->get_data(); |
| 259 | 259 | |
| 260 | - $this->assertEquals( '', $data['value'] ); |
|
| 260 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
| 261 | 261 | $this->assertEquals( '', get_option( 'woocommerce_shop_page_display' ) ); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | // test defaults first |
| 271 | 271 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test' ) ); |
| 272 | 272 | $data = $response->get_data(); |
| 273 | - $this->assertEquals( '', $data[0]['value'] ); |
|
| 273 | + $this->assertEquals( '', $data[ 0 ][ 'value' ] ); |
|
| 274 | 274 | |
| 275 | 275 | // test setting both at once |
| 276 | 276 | $request = new WP_REST_Request( 'POST', '/wc/v4/settings/test/batch' ); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $response = $this->server->dispatch( $request ); |
| 288 | 288 | $data = $response->get_data(); |
| 289 | 289 | |
| 290 | - $this->assertEquals( 'both', $data['update'][0]['value'] ); |
|
| 290 | + $this->assertEquals( 'both', $data[ 'update' ][ 0 ][ 'value' ] ); |
|
| 291 | 291 | $this->assertEquals( 'both', get_option( 'woocommerce_shop_page_display' ) ); |
| 292 | 292 | |
| 293 | 293 | // test updating one, but making sure the other value stays the same |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | ); |
| 305 | 305 | $response = $this->server->dispatch( $request ); |
| 306 | 306 | $data = $response->get_data(); |
| 307 | - $this->assertEquals( 'subcategories', $data['update'][0]['value'] ); |
|
| 307 | + $this->assertEquals( 'subcategories', $data[ 'update' ][ 0 ][ 'value' ] ); |
|
| 308 | 308 | $this->assertEquals( 'subcategories', get_option( 'woocommerce_shop_page_display' ) ); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -330,11 +330,11 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | $this->assertEquals( 200, $response->get_status() ); |
| 332 | 332 | |
| 333 | - $this->assertEquals( 'woocommerce_shop_page_display', $data['id'] ); |
|
| 334 | - $this->assertEquals( 'Shop page display', $data['label'] ); |
|
| 335 | - $this->assertEquals( '', $data['default'] ); |
|
| 336 | - $this->assertEquals( 'select', $data['type'] ); |
|
| 337 | - $this->assertEquals( '', $data['value'] ); |
|
| 333 | + $this->assertEquals( 'woocommerce_shop_page_display', $data[ 'id' ] ); |
|
| 334 | + $this->assertEquals( 'Shop page display', $data[ 'label' ] ); |
|
| 335 | + $this->assertEquals( '', $data[ 'default' ] ); |
|
| 336 | + $this->assertEquals( 'select', $data[ 'type' ] ); |
|
| 337 | + $this->assertEquals( '', $data[ 'value' ] ); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/products/woocommerce_dimension_unit' ) ); |
| 492 | 492 | $data = $response->get_data(); |
| 493 | 493 | |
| 494 | - $this->assertEquals( 'cm', $data['default'] ); |
|
| 494 | + $this->assertEquals( 'cm', $data[ 'default' ] ); |
|
| 495 | 495 | |
| 496 | 496 | // test update |
| 497 | 497 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'products', 'woocommerce_dimension_unit' ) ); |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | $response = $this->server->dispatch( $request ); |
| 504 | 504 | $data = $response->get_data(); |
| 505 | 505 | |
| 506 | - $this->assertEquals( 'yd', $data['value'] ); |
|
| 506 | + $this->assertEquals( 'yd', $data[ 'value' ] ); |
|
| 507 | 507 | $this->assertEquals( 'yd', get_option( 'woocommerce_dimension_unit' ) ); |
| 508 | 508 | } |
| 509 | 509 | |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | $response = $this->server->dispatch( $request ); |
| 591 | 591 | $setting = $response->get_data(); |
| 592 | 592 | |
| 593 | - $this->assertEmpty( $setting['value'] ); |
|
| 593 | + $this->assertEmpty( $setting[ 'value' ] ); |
|
| 594 | 594 | |
| 595 | 595 | // test update |
| 596 | 596 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'email_customer_new_account', 'subject' ) ); |
@@ -602,13 +602,13 @@ discard block |
||
| 602 | 602 | $response = $this->server->dispatch( $request ); |
| 603 | 603 | $setting = $response->get_data(); |
| 604 | 604 | |
| 605 | - $this->assertEquals( 'This is my new subject', $setting['value'] ); |
|
| 605 | + $this->assertEquals( 'This is my new subject', $setting[ 'value' ] ); |
|
| 606 | 606 | |
| 607 | 607 | // make sure the other is what we left it |
| 608 | 608 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/email_new_order/subject' ) ); |
| 609 | 609 | $setting = $response->get_data(); |
| 610 | 610 | |
| 611 | - $this->assertEquals( 'This is my subject', $setting['value'] ); |
|
| 611 | + $this->assertEquals( 'This is my subject', $setting[ 'value' ] ); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /** |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | public function test_validation_multiselect() { |
| 684 | 684 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', sprintf( '/wc/v4/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries' ) ) ); |
| 685 | 685 | $setting = $response->get_data(); |
| 686 | - $this->assertEmpty( $setting['value'] ); |
|
| 686 | + $this->assertEmpty( $setting[ 'value' ] ); |
|
| 687 | 687 | |
| 688 | 688 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries' ) ); |
| 689 | 689 | $request->set_body_params( |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | ); |
| 694 | 694 | $response = $this->server->dispatch( $request ); |
| 695 | 695 | $setting = $response->get_data(); |
| 696 | - $this->assertEquals( array( 'AX', 'DZ' ), $setting['value'] ); |
|
| 696 | + $this->assertEquals( array( 'AX', 'DZ' ), $setting[ 'value' ] ); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | /** |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | public function test_validation_select() { |
| 705 | 705 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', sprintf( '/wc/v4/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) ) ); |
| 706 | 706 | $setting = $response->get_data(); |
| 707 | - $this->assertEquals( 'kg', $setting['value'] ); |
|
| 707 | + $this->assertEquals( 'kg', $setting[ 'value' ] ); |
|
| 708 | 708 | |
| 709 | 709 | // invalid |
| 710 | 710 | $request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) ); |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | ); |
| 726 | 726 | $response = $this->server->dispatch( $request ); |
| 727 | 727 | $setting = $response->get_data(); |
| 728 | - $this->assertEquals( 'lbs', $setting['value'] ); |
|
| 728 | + $this->assertEquals( 'lbs', $setting[ 'value' ] ); |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | /** |
@@ -739,9 +739,9 @@ discard block |
||
| 739 | 739 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_default_country' ) ); |
| 740 | 740 | $setting = $response->get_data(); |
| 741 | 741 | |
| 742 | - $this->assertEquals( 'select', $setting['type'] ); |
|
| 743 | - $this->assertArrayHasKey( 'GB', $setting['options'] ); |
|
| 744 | - $this->assertArrayHasKey( 'US:OR', $setting['options'] ); |
|
| 742 | + $this->assertEquals( 'select', $setting[ 'type' ] ); |
|
| 743 | + $this->assertArrayHasKey( 'GB', $setting[ 'options' ] ); |
|
| 744 | + $this->assertArrayHasKey( 'US:OR', $setting[ 'options' ] ); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | /** |
@@ -752,10 +752,10 @@ discard block |
||
| 752 | 752 | public function test_woocommerce_store_address() { |
| 753 | 753 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_address' ) ); |
| 754 | 754 | $setting = $response->get_data(); |
| 755 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 755 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 756 | 756 | |
| 757 | 757 | // Repalce the old value with something uniquely new |
| 758 | - $old_value = $setting['value']; |
|
| 758 | + $old_value = $setting[ 'value' ]; |
|
| 759 | 759 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 760 | 760 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address' ); |
| 761 | 761 | $request->set_body_params( |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | ); |
| 766 | 766 | $response = $this->server->dispatch( $request ); |
| 767 | 767 | $setting = $response->get_data(); |
| 768 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 768 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 769 | 769 | |
| 770 | 770 | // Put the original value back |
| 771 | 771 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address' ); |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | ); |
| 777 | 777 | $response = $this->server->dispatch( $request ); |
| 778 | 778 | $setting = $response->get_data(); |
| 779 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 779 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
@@ -787,10 +787,10 @@ discard block |
||
| 787 | 787 | public function test_woocommerce_store_address_2() { |
| 788 | 788 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_address_2' ) ); |
| 789 | 789 | $setting = $response->get_data(); |
| 790 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 790 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 791 | 791 | |
| 792 | 792 | // Repalce the old value with something uniquely new |
| 793 | - $old_value = $setting['value']; |
|
| 793 | + $old_value = $setting[ 'value' ]; |
|
| 794 | 794 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 795 | 795 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address_2' ); |
| 796 | 796 | $request->set_body_params( |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | ); |
| 801 | 801 | $response = $this->server->dispatch( $request ); |
| 802 | 802 | $setting = $response->get_data(); |
| 803 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 803 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 804 | 804 | |
| 805 | 805 | // Put the original value back |
| 806 | 806 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address_2' ); |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | ); |
| 812 | 812 | $response = $this->server->dispatch( $request ); |
| 813 | 813 | $setting = $response->get_data(); |
| 814 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 814 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | /** |
@@ -822,10 +822,10 @@ discard block |
||
| 822 | 822 | public function test_woocommerce_store_city() { |
| 823 | 823 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_city' ) ); |
| 824 | 824 | $setting = $response->get_data(); |
| 825 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 825 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 826 | 826 | |
| 827 | 827 | // Repalce the old value with something uniquely new |
| 828 | - $old_value = $setting['value']; |
|
| 828 | + $old_value = $setting[ 'value' ]; |
|
| 829 | 829 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 830 | 830 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_city' ); |
| 831 | 831 | $request->set_body_params( |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | ); |
| 836 | 836 | $response = $this->server->dispatch( $request ); |
| 837 | 837 | $setting = $response->get_data(); |
| 838 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 838 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 839 | 839 | |
| 840 | 840 | // Put the original value back |
| 841 | 841 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_city' ); |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | ); |
| 847 | 847 | $response = $this->server->dispatch( $request ); |
| 848 | 848 | $setting = $response->get_data(); |
| 849 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 849 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | /** |
@@ -857,10 +857,10 @@ discard block |
||
| 857 | 857 | public function test_woocommerce_store_postcode() { |
| 858 | 858 | $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_postcode' ) ); |
| 859 | 859 | $setting = $response->get_data(); |
| 860 | - $this->assertEquals( 'text', $setting['type'] ); |
|
| 860 | + $this->assertEquals( 'text', $setting[ 'type' ] ); |
|
| 861 | 861 | |
| 862 | 862 | // Repalce the old value with something uniquely new |
| 863 | - $old_value = $setting['value']; |
|
| 863 | + $old_value = $setting[ 'value' ]; |
|
| 864 | 864 | $new_value = $old_value . ' ' . rand( 1000, 9999 ); |
| 865 | 865 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_postcode' ); |
| 866 | 866 | $request->set_body_params( |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | ); |
| 871 | 871 | $response = $this->server->dispatch( $request ); |
| 872 | 872 | $setting = $response->get_data(); |
| 873 | - $this->assertEquals( $new_value, $setting['value'] ); |
|
| 873 | + $this->assertEquals( $new_value, $setting[ 'value' ] ); |
|
| 874 | 874 | |
| 875 | 875 | // Put the original value back |
| 876 | 876 | $request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_postcode' ); |
@@ -881,6 +881,6 @@ discard block |
||
| 881 | 881 | ); |
| 882 | 882 | $response = $this->server->dispatch( $request ); |
| 883 | 883 | $setting = $response->get_data(); |
| 884 | - $this->assertEquals( $old_value, $setting['value'] ); |
|
| 884 | + $this->assertEquals( $old_value, $setting[ 'value' ] ); |
|
| 885 | 885 | } |
| 886 | 886 | } |
@@ -149,7 +149,7 @@ |
||
| 149 | 149 | $request = new WP_REST_Request( 'OPTIONS', '/wc/v4/shipping_methods' ); |
| 150 | 150 | $response = $this->server->dispatch( $request ); |
| 151 | 151 | $data = $response->get_data(); |
| 152 | - $properties = $data['schema']['properties']; |
|
| 152 | + $properties = $data[ 'schema' ][ 'properties' ]; |
|
| 153 | 153 | |
| 154 | 154 | $this->assertEquals( 3, count( $properties ) ); |
| 155 | 155 | $this->assertArrayHasKey( 'id', $properties ); |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | $this->assertExpectedResponse( $response, 201, $data ); |
| 66 | 66 | $this->assertEquals( |
| 67 | 67 | array( |
| 68 | - 'id' => $response->data['id'], |
|
| 69 | - 'date_created' => $response->data['date_created'], |
|
| 70 | - 'date_created_gmt' => $response->data['date_created_gmt'], |
|
| 68 | + 'id' => $response->data[ 'id' ], |
|
| 69 | + 'date_created' => $response->data[ 'date_created' ], |
|
| 70 | + 'date_created_gmt' => $response->data[ 'date_created_gmt' ], |
|
| 71 | 71 | 'product_id' => $product->get_id(), |
| 72 | 72 | 'status' => 'approved', |
| 73 | 73 | 'reviewer' => 'Admin', |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | 'review' => 'Hello world.', |
| 76 | 76 | 'rating' => 5, |
| 77 | 77 | 'verified' => false, |
| 78 | - 'reviewer_avatar_urls' => $response->data['reviewer_avatar_urls'], |
|
| 78 | + 'reviewer_avatar_urls' => $response->data[ 'reviewer_avatar_urls' ], |
|
| 79 | 79 | ), |
| 80 | 80 | $response->data |
| 81 | 81 | ); |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | $this->assertContains( |
| 104 | 104 | array( |
| 105 | 105 | 'id' => $review_id, |
| 106 | - 'date_created' => $product_reviews[0]['date_created'], |
|
| 107 | - 'date_created_gmt' => $product_reviews[0]['date_created_gmt'], |
|
| 106 | + 'date_created' => $product_reviews[ 0 ][ 'date_created' ], |
|
| 107 | + 'date_created_gmt' => $product_reviews[ 0 ][ 'date_created_gmt' ], |
|
| 108 | 108 | 'product_id' => $product->get_id(), |
| 109 | 109 | 'status' => 'approved', |
| 110 | 110 | 'reviewer' => 'admin', |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | 'review' => "<p>Review content here</p>\n", |
| 113 | 113 | 'rating' => 0, |
| 114 | 114 | 'verified' => false, |
| 115 | - 'reviewer_avatar_urls' => $product_reviews[0]['reviewer_avatar_urls'], |
|
| 115 | + 'reviewer_avatar_urls' => $product_reviews[ 0 ][ 'reviewer_avatar_urls' ], |
|
| 116 | 116 | '_links' => array( |
| 117 | 117 | 'self' => array( |
| 118 | 118 | array( |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $response = $this->do_request( '/wc/v4/products/reviews/' . $product_review_id ); |
| 148 | 148 | $this->assertEquals( 200, $response->status ); |
| 149 | - $this->assertEquals( "<p>Review content here</p>\n", $response->data['review'] ); |
|
| 150 | - $this->assertEquals( 'admin', $response->data['reviewer'] ); |
|
| 151 | - $this->assertEquals( '[email protected]', $response->data['reviewer_email'] ); |
|
| 152 | - $this->assertEquals( 0, $response->data['rating'] ); |
|
| 149 | + $this->assertEquals( "<p>Review content here</p>\n", $response->data[ 'review' ] ); |
|
| 150 | + $this->assertEquals( 'admin', $response->data[ 'reviewer' ] ); |
|
| 151 | + $this->assertEquals( '[email protected]', $response->data[ 'reviewer_email' ] ); |
|
| 152 | + $this->assertEquals( 0, $response->data[ 'rating' ] ); |
|
| 153 | 153 | |
| 154 | - $data = [ |
|
| 154 | + $data = [ |
|
| 155 | 155 | 'review' => 'Hello world - updated.', |
| 156 | 156 | 'reviewer' => 'Justin', |
| 157 | 157 | 'reviewer_email' => '[email protected]', |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | $this->assertEquals( |
| 208 | 208 | array( |
| 209 | 209 | 'id' => $product_review_id, |
| 210 | - 'date_created' => $data['date_created'], |
|
| 211 | - 'date_created_gmt' => $data['date_created_gmt'], |
|
| 210 | + 'date_created' => $data[ 'date_created' ], |
|
| 211 | + 'date_created_gmt' => $data[ 'date_created_gmt' ], |
|
| 212 | 212 | 'product_id' => $product->get_id(), |
| 213 | 213 | 'status' => 'approved', |
| 214 | 214 | 'reviewer' => 'admin', |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | 'review' => "<p>Review content here</p>\n", |
| 217 | 217 | 'rating' => 0, |
| 218 | 218 | 'verified' => false, |
| 219 | - 'reviewer_avatar_urls' => $data['reviewer_avatar_urls'], |
|
| 219 | + 'reviewer_avatar_urls' => $data[ 'reviewer_avatar_urls' ], |
|
| 220 | 220 | ), |
| 221 | 221 | $data |
| 222 | 222 | ); |
@@ -383,10 +383,10 @@ discard block |
||
| 383 | 383 | $response = $this->server->dispatch( $request ); |
| 384 | 384 | $data = $response->get_data(); |
| 385 | 385 | |
| 386 | - $this->assertEquals( 'Updated review.', $data['update'][0]['review'] ); |
|
| 387 | - $this->assertEquals( 'New review.', $data['create'][0]['review'] ); |
|
| 388 | - $this->assertEquals( $review_2_id, $data['delete'][0]['previous']['id'] ); |
|
| 389 | - $this->assertEquals( $review_3_id, $data['delete'][1]['previous']['id'] ); |
|
| 386 | + $this->assertEquals( 'Updated review.', $data[ 'update' ][ 0 ][ 'review' ] ); |
|
| 387 | + $this->assertEquals( 'New review.', $data[ 'create' ][ 0 ][ 'review' ] ); |
|
| 388 | + $this->assertEquals( $review_2_id, $data[ 'delete' ][ 0 ][ 'previous' ][ 'id' ] ); |
|
| 389 | + $this->assertEquals( $review_3_id, $data[ 'delete' ][ 1 ][ 'previous' ][ 'id' ] ); |
|
| 390 | 390 | |
| 391 | 391 | $request = new \WP_REST_Request( 'GET', '/wc/v4/products/reviews' ); |
| 392 | 392 | $request->set_param( 'product', $product->get_id() ); |