PHPCS fixes
This commit is contained in:
parent
eeb97510eb
commit
7ce69dfca2
|
@ -19,9 +19,11 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->endpoint = new WC_REST_Orders_Controller();
|
$this->endpoint = new WC_REST_Orders_Controller();
|
||||||
$this->user = $this->factory->user->create( array(
|
$this->user = $this->factory->user->create(
|
||||||
|
array(
|
||||||
'role' => 'administrator',
|
'role' => 'administrator',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,7 +137,8 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
$product = WC_Helper_Product::create_simple_product();
|
$product = WC_Helper_Product::create_simple_product();
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/orders' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/orders' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'payment_method' => 'bacs',
|
'payment_method' => 'bacs',
|
||||||
'payment_method_title' => 'Direct Bank Transfer',
|
'payment_method_title' => 'Direct Bank Transfer',
|
||||||
'set_paid' => true,
|
'set_paid' => true,
|
||||||
|
@ -174,7 +177,8 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
'total' => '10',
|
'total' => '10',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
$order = wc_get_order( $data['id'] );
|
$order = wc_get_order( $data['id'] );
|
||||||
|
@ -218,7 +222,8 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// non-existent customer
|
// non-existent customer
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/orders' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/orders' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'payment_method' => 'bacs',
|
'payment_method' => 'bacs',
|
||||||
'payment_method_title' => 'Direct Bank Transfer',
|
'payment_method_title' => 'Direct Bank Transfer',
|
||||||
'set_paid' => true,
|
'set_paid' => true,
|
||||||
|
@ -258,7 +263,8 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
'total' => 10,
|
'total' => 10,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
$this->assertEquals( 400, $response->get_status() );
|
$this->assertEquals( 400, $response->get_status() );
|
||||||
|
@ -274,13 +280,15 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
$order = WC_Helper_Order::create_order();
|
$order = WC_Helper_Order::create_order();
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'payment_method' => 'test-update',
|
'payment_method' => 'test-update',
|
||||||
'billing' => array(
|
'billing' => array(
|
||||||
'first_name' => 'Fish',
|
'first_name' => 'Fish',
|
||||||
'last_name' => 'Face',
|
'last_name' => 'Face',
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -301,26 +309,30 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
$order = WC_Helper_Order::create_order();
|
$order = WC_Helper_Order::create_order();
|
||||||
$fee = new WC_Order_Item_Fee();
|
$fee = new WC_Order_Item_Fee();
|
||||||
$fee->set_props( array(
|
$fee->set_props(
|
||||||
|
array(
|
||||||
'name' => 'Some Fee',
|
'name' => 'Some Fee',
|
||||||
'tax_status' => 'taxable',
|
'tax_status' => 'taxable',
|
||||||
'total' => '100',
|
'total' => '100',
|
||||||
'tax_class' => '',
|
'tax_class' => '',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$order->add_item( $fee );
|
$order->add_item( $fee );
|
||||||
$order->save();
|
$order->save();
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
|
||||||
$fee_data = current( $order->get_items( 'fee' ) );
|
$fee_data = current( $order->get_items( 'fee' ) );
|
||||||
|
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'fee_lines' => array(
|
'fee_lines' => array(
|
||||||
array(
|
array(
|
||||||
'id' => $fee_data->get_id(),
|
'id' => $fee_data->get_id(),
|
||||||
'name' => null,
|
'name' => null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -343,7 +355,8 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
$coupon->set_amount( 5 );
|
$coupon->set_amount( 5 );
|
||||||
$coupon->save();
|
$coupon->save();
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'coupon_lines' => array(
|
'coupon_lines' => array(
|
||||||
array(
|
array(
|
||||||
'code' => 'fake-coupon',
|
'code' => 'fake-coupon',
|
||||||
|
@ -358,7 +371,8 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
'total' => '35.00',
|
'total' => '35.00',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -391,7 +405,8 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
|
||||||
$coupon_data = current( $order->get_items( 'coupon' ) );
|
$coupon_data = current( $order->get_items( 'coupon' ) );
|
||||||
|
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'coupon_lines' => array(
|
'coupon_lines' => array(
|
||||||
array(
|
array(
|
||||||
'id' => $coupon_data->get_id(),
|
'id' => $coupon_data->get_id(),
|
||||||
|
@ -405,7 +420,8 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
'total' => '40.00',
|
'total' => '40.00',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -425,13 +441,15 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( 0 );
|
wp_set_current_user( 0 );
|
||||||
$order = WC_Helper_Order::create_order();
|
$order = WC_Helper_Order::create_order();
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'payment_method' => 'test-update',
|
'payment_method' => 'test-update',
|
||||||
'billing' => array(
|
'billing' => array(
|
||||||
'first_name' => 'Fish',
|
'first_name' => 'Fish',
|
||||||
'last_name' => 'Face',
|
'last_name' => 'Face',
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$this->assertEquals( 401, $response->get_status() );
|
$this->assertEquals( 401, $response->get_status() );
|
||||||
WC_Helper_Order::delete_order( $order->get_id() );
|
WC_Helper_Order::delete_order( $order->get_id() );
|
||||||
|
@ -444,13 +462,15 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
public function test_update_order_invalid_id() {
|
public function test_update_order_invalid_id() {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/orders/999999' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/orders/999999' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'payment_method' => 'test-update',
|
'payment_method' => 'test-update',
|
||||||
'billing' => array(
|
'billing' => array(
|
||||||
'first_name' => 'Fish',
|
'first_name' => 'Fish',
|
||||||
'last_name' => 'Face',
|
'last_name' => 'Face',
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$this->assertEquals( 400, $response->get_status() );
|
$this->assertEquals( 400, $response->get_status() );
|
||||||
}
|
}
|
||||||
|
@ -507,7 +527,8 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
$order3 = WC_Helper_Order::create_order();
|
$order3 = WC_Helper_Order::create_order();
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/orders/batch' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/orders/batch' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'update' => array(
|
'update' => array(
|
||||||
array(
|
array(
|
||||||
'id' => $order1->get_id(),
|
'id' => $order1->get_id(),
|
||||||
|
@ -518,7 +539,8 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
||||||
$order2->get_id(),
|
$order2->get_id(),
|
||||||
$order3->get_id(),
|
$order3->get_id(),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,11 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->endpoint = new WC_REST_Product_Reviews_Controller();
|
$this->endpoint = new WC_REST_Product_Reviews_Controller();
|
||||||
$this->user = $this->factory->user->create( array(
|
$this->user = $this->factory->user->create(
|
||||||
|
array(
|
||||||
'role' => 'administrator',
|
'role' => 'administrator',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +50,8 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
$this->assertEquals( 200, $response->get_status() );
|
$this->assertEquals( 200, $response->get_status() );
|
||||||
$this->assertEquals( 10, count( $product_reviews ) );
|
$this->assertEquals( 10, count( $product_reviews ) );
|
||||||
$this->assertContains( array(
|
$this->assertContains(
|
||||||
|
array(
|
||||||
'id' => $review_id,
|
'id' => $review_id,
|
||||||
'date_created' => $product_reviews[0]['date_created'],
|
'date_created' => $product_reviews[0]['date_created'],
|
||||||
'date_created_gmt' => $product_reviews[0]['date_created_gmt'],
|
'date_created_gmt' => $product_reviews[0]['date_created_gmt'],
|
||||||
|
@ -74,7 +77,8 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), $product_reviews );
|
), $product_reviews
|
||||||
|
);
|
||||||
|
|
||||||
$product->delete( true );
|
$product->delete( true );
|
||||||
}
|
}
|
||||||
|
@ -117,7 +121,8 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
$this->assertEquals( 200, $response->get_status() );
|
$this->assertEquals( 200, $response->get_status() );
|
||||||
$this->assertEquals( array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'id' => $product_review_id,
|
'id' => $product_review_id,
|
||||||
'date_created' => $data['date_created'],
|
'date_created' => $data['date_created'],
|
||||||
'date_created_gmt' => $data['date_created_gmt'],
|
'date_created_gmt' => $data['date_created_gmt'],
|
||||||
|
@ -126,7 +131,8 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
'name' => 'admin',
|
'name' => 'admin',
|
||||||
'email' => 'woo@woo.local',
|
'email' => 'woo@woo.local',
|
||||||
'verified' => false,
|
'verified' => false,
|
||||||
), $data );
|
), $data
|
||||||
|
);
|
||||||
$product->delete( true );
|
$product->delete( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,17 +172,20 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
$product = WC_Helper_Product::create_simple_product();
|
$product = WC_Helper_Product::create_simple_product();
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/reviews' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/reviews' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'review' => 'Hello world.',
|
'review' => 'Hello world.',
|
||||||
'name' => 'Admin',
|
'name' => 'Admin',
|
||||||
'email' => 'woo@woo.local',
|
'email' => 'woo@woo.local',
|
||||||
'rating' => '5',
|
'rating' => '5',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
$this->assertEquals( 201, $response->get_status() );
|
$this->assertEquals( 201, $response->get_status() );
|
||||||
$this->assertEquals( array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'id' => $data['id'],
|
'id' => $data['id'],
|
||||||
'date_created' => $data['date_created'],
|
'date_created' => $data['date_created'],
|
||||||
'date_created_gmt' => $data['date_created_gmt'],
|
'date_created_gmt' => $data['date_created_gmt'],
|
||||||
|
@ -185,7 +194,8 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
'name' => 'Admin',
|
'name' => 'Admin',
|
||||||
'email' => 'woo@woo.local',
|
'email' => 'woo@woo.local',
|
||||||
'verified' => false,
|
'verified' => false,
|
||||||
), $data );
|
), $data
|
||||||
|
);
|
||||||
$product->delete( true );
|
$product->delete( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,10 +210,12 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// missing review
|
// missing review
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/reviews' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/reviews' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'name' => 'Admin',
|
'name' => 'Admin',
|
||||||
'email' => 'woo@woo.local',
|
'email' => 'woo@woo.local',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -211,10 +223,12 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// missing name
|
// missing name
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/reviews' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/reviews' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'review' => 'Hello world.',
|
'review' => 'Hello world.',
|
||||||
'email' => 'woo@woo.local',
|
'email' => 'woo@woo.local',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -222,10 +236,12 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// missing email
|
// missing email
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/reviews' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/reviews' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'review' => 'Hello world.',
|
'review' => 'Hello world.',
|
||||||
'name' => 'Admin',
|
'name' => 'Admin',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -251,12 +267,14 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
$this->assertEquals( 0, $data['rating'] );
|
$this->assertEquals( 0, $data['rating'] );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/reviews/' . $product_review_id );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/reviews/' . $product_review_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'review' => 'Hello world - updated.',
|
'review' => 'Hello world - updated.',
|
||||||
'name' => 'Justin',
|
'name' => 'Justin',
|
||||||
'email' => 'woo2@woo.local',
|
'email' => 'woo2@woo.local',
|
||||||
'rating' => 3,
|
'rating' => 3,
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
$this->assertEquals( 'Hello world - updated.', $data['review'] );
|
$this->assertEquals( 'Hello world - updated.', $data['review'] );
|
||||||
|
@ -277,11 +295,13 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
$product_review_id = WC_Helper_Product::create_product_review( $product->get_id() );
|
$product_review_id = WC_Helper_Product::create_product_review( $product->get_id() );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/reviews/' . $product_review_id );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/reviews/' . $product_review_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'review' => 'Hello world.',
|
'review' => 'Hello world.',
|
||||||
'name' => 'Admin',
|
'name' => 'Admin',
|
||||||
'email' => 'woo@woo.dev',
|
'email' => 'woo@woo.dev',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -299,11 +319,13 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
$product = WC_Helper_Product::create_simple_product();
|
$product = WC_Helper_Product::create_simple_product();
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/reviews/0' );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/reviews/0' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'review' => 'Hello world.',
|
'review' => 'Hello world.',
|
||||||
'name' => 'Admin',
|
'name' => 'Admin',
|
||||||
'email' => 'woo@woo.dev',
|
'email' => 'woo@woo.dev',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -376,7 +398,8 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
$review_4_id = WC_Helper_Product::create_product_review( $product->get_id() );
|
$review_4_id = WC_Helper_Product::create_product_review( $product->get_id() );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/reviews/batch' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/reviews/batch' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'update' => array(
|
'update' => array(
|
||||||
array(
|
array(
|
||||||
'id' => $review_1_id,
|
'id' => $review_1_id,
|
||||||
|
@ -394,7 +417,8 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
||||||
'email' => 'woo3@woo.local',
|
'email' => 'woo3@woo.local',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,11 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->endpoint = new WC_REST_Product_Variations_Controller();
|
$this->endpoint = new WC_REST_Product_Variations_Controller();
|
||||||
$this->user = $this->factory->user->create( array(
|
$this->user = $this->factory->user->create(
|
||||||
|
array(
|
||||||
'role' => 'administrator',
|
'role' => 'administrator',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,13 +173,24 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
$this->assertEquals( 'small', $variation['attributes'][0]['option'] );
|
$this->assertEquals( 'small', $variation['attributes'][0]['option'] );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'sku' => 'FIXED-SKU',
|
'sku' => 'FIXED-SKU',
|
||||||
'sale_price' => '8',
|
'sale_price' => '8',
|
||||||
'description' => 'O_O',
|
'description' => 'O_O',
|
||||||
'image' => array( 'position' => 0, 'src' => 'https://cldup.com/Dr1Bczxq4q.png', 'alt' => 'test upload image' ),
|
'image' => array(
|
||||||
'attributes' => array( array( 'name' => 'pa_size', 'option' => 'medium' ) ),
|
'position' => 0,
|
||||||
) );
|
'src' => 'https://cldup.com/Dr1Bczxq4q.png',
|
||||||
|
'alt' => 'test upload image',
|
||||||
|
),
|
||||||
|
'attributes' => array(
|
||||||
|
array(
|
||||||
|
'name' => 'pa_size',
|
||||||
|
'option' => 'medium',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$variation = $response->get_data();
|
$variation = $response->get_data();
|
||||||
|
|
||||||
|
@ -204,9 +217,11 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
$variation_id = $children[0];
|
$variation_id = $children[0];
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'sku' => 'FIXED-SKU-NO-PERMISSION',
|
'sku' => 'FIXED-SKU-NO-PERMISSION',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$this->assertEquals( 401, $response->get_status() );
|
$this->assertEquals( 401, $response->get_status() );
|
||||||
$product->delete( true );
|
$product->delete( true );
|
||||||
|
@ -221,9 +236,11 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
$product = WC_Helper_Product::create_variation_product();
|
$product = WC_Helper_Product::create_variation_product();
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/0' );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/0' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'sku' => 'FIXED-SKU-NO-PERMISSION',
|
'sku' => 'FIXED-SKU-NO-PERMISSION',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$this->assertEquals( 400, $response->get_status() );
|
$this->assertEquals( 400, $response->get_status() );
|
||||||
$product->delete( true );
|
$product->delete( true );
|
||||||
|
@ -243,12 +260,19 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
$this->assertEquals( 2, count( $variations ) );
|
$this->assertEquals( 2, count( $variations ) );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/variations' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/variations' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'sku' => 'DUMMY SKU VARIABLE MEDIUM',
|
'sku' => 'DUMMY SKU VARIABLE MEDIUM',
|
||||||
'regular_price' => '12',
|
'regular_price' => '12',
|
||||||
'description' => 'A medium size.',
|
'description' => 'A medium size.',
|
||||||
'attributes' => array( array( 'name' => 'pa_size', 'option' => 'medium' ) ),
|
'attributes' => array(
|
||||||
) );
|
array(
|
||||||
|
'name' => 'pa_size',
|
||||||
|
'option' => 'medium',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$variation = $response->get_data();
|
$variation = $response->get_data();
|
||||||
|
|
||||||
|
@ -275,12 +299,19 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
$product = WC_Helper_Product::create_variation_product();
|
$product = WC_Helper_Product::create_variation_product();
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/variations' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/variations' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'sku' => 'DUMMY SKU VARIABLE MEDIUM',
|
'sku' => 'DUMMY SKU VARIABLE MEDIUM',
|
||||||
'regular_price' => '12',
|
'regular_price' => '12',
|
||||||
'description' => 'A medium size.',
|
'description' => 'A medium size.',
|
||||||
'attributes' => array( array( 'name' => 'pa_size', 'option' => 'medium' ) ),
|
'attributes' => array(
|
||||||
) );
|
array(
|
||||||
|
'name' => 'pa_size',
|
||||||
|
'option' => 'medium',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$this->assertEquals( 401, $response->get_status() );
|
$this->assertEquals( 401, $response->get_status() );
|
||||||
$product->delete( true );
|
$product->delete( true );
|
||||||
|
@ -294,12 +325,17 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
$product = WC_Helper_Product::create_variation_product();
|
$product = WC_Helper_Product::create_variation_product();
|
||||||
$children = $product->get_children();
|
$children = $product->get_children();
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/variations/batch' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products/' . $product->get_id() . '/variations/batch' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'update' => array(
|
'update' => array(
|
||||||
array(
|
array(
|
||||||
'id' => $children[0],
|
'id' => $children[0],
|
||||||
'description' => 'Updated description.',
|
'description' => 'Updated description.',
|
||||||
'image' => array( 'position' => 0, 'src' => 'https://cldup.com/Dr1Bczxq4q.png', 'alt' => 'test upload image' ),
|
'image' => array(
|
||||||
|
'position' => 0,
|
||||||
|
'src' => 'https://cldup.com/Dr1Bczxq4q.png',
|
||||||
|
'alt' => 'test upload image',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'delete' => array(
|
'delete' => array(
|
||||||
|
@ -310,10 +346,16 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
'sku' => 'DUMMY SKU VARIABLE MEDIUM',
|
'sku' => 'DUMMY SKU VARIABLE MEDIUM',
|
||||||
'regular_price' => '12',
|
'regular_price' => '12',
|
||||||
'description' => 'A medium size.',
|
'description' => 'A medium size.',
|
||||||
'attributes' => array( array( 'name' => 'pa_size', 'option' => 'medium' ) ),
|
'attributes' => array(
|
||||||
|
array(
|
||||||
|
'name' => 'pa_size',
|
||||||
|
'option' => 'medium',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) );
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -399,9 +441,11 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// Set stock to true.
|
// Set stock to true.
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'manage_stock' => true,
|
'manage_stock' => true,
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$variation = $response->get_data();
|
$variation = $response->get_data();
|
||||||
|
@ -411,9 +455,11 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// Set stock to false.
|
// Set stock to false.
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'manage_stock' => false,
|
'manage_stock' => false,
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$variation = $response->get_data();
|
$variation = $response->get_data();
|
||||||
|
@ -425,9 +471,11 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
||||||
$product->set_manage_stock( true );
|
$product->set_manage_stock( true );
|
||||||
$product->save();
|
$product->save();
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() . '/variations/' . $variation_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'manage_stock' => false,
|
'manage_stock' => false,
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$variation = $response->get_data();
|
$variation = $response->get_data();
|
||||||
|
|
|
@ -14,9 +14,11 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->endpoint = new WC_REST_Products_Controller();
|
$this->endpoint = new WC_REST_Products_Controller();
|
||||||
$this->user = $this->factory->user->create( array(
|
$this->user = $this->factory->user->create(
|
||||||
|
array(
|
||||||
'role' => 'administrator',
|
'role' => 'administrator',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,14 +91,16 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
$product = $response->get_data();
|
$product = $response->get_data();
|
||||||
|
|
||||||
$this->assertEquals( 200, $response->get_status() );
|
$this->assertEquals( 200, $response->get_status() );
|
||||||
$this->assertContains( array(
|
$this->assertContains(
|
||||||
|
array(
|
||||||
'id' => $simple->get_id(),
|
'id' => $simple->get_id(),
|
||||||
'name' => 'Dummy External Product',
|
'name' => 'Dummy External Product',
|
||||||
'type' => 'simple',
|
'type' => 'simple',
|
||||||
'status' => 'publish',
|
'status' => 'publish',
|
||||||
'sku' => 'DUMMY EXTERNAL SKU',
|
'sku' => 'DUMMY EXTERNAL SKU',
|
||||||
'regular_price' => 10,
|
'regular_price' => 10,
|
||||||
), $product );
|
), $product
|
||||||
|
);
|
||||||
$simple->delete( true );
|
$simple->delete( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,12 +183,20 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
$this->assertEmpty( $data['sale_price'] );
|
$this->assertEmpty( $data['sale_price'] );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'sku' => 'FIXED-SKU',
|
'sku' => 'FIXED-SKU',
|
||||||
'sale_price' => '8',
|
'sale_price' => '8',
|
||||||
'description' => 'Testing',
|
'description' => 'Testing',
|
||||||
'images' => array( array( 'position' => 0, 'src' => 'https://cldup.com/Dr1Bczxq4q.png', 'alt' => 'test upload image' ) ),
|
'images' => array(
|
||||||
) );
|
array(
|
||||||
|
'position' => 0,
|
||||||
|
'src' => 'https://cldup.com/Dr1Bczxq4q.png',
|
||||||
|
'alt' => 'test upload image',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -205,12 +217,25 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
$this->assertEquals( array( 'small' ), $data['attributes'][0]['options'] );
|
$this->assertEquals( array( 'small' ), $data['attributes'][0]['options'] );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'attributes' => array(
|
'attributes' => array(
|
||||||
array( 'id' => 0, 'name' => 'pa_color', 'options' => array( 'red', 'yellow' ), 'visible' => false, 'variation' => 1 ),
|
array(
|
||||||
array( 'name' => 'pa_size', 'options' => array( 'small' ), 'visible' => false, 'variation' => 1 ),
|
'id' => 0,
|
||||||
|
'name' => 'pa_color',
|
||||||
|
'options' => array( 'red', 'yellow' ),
|
||||||
|
'visible' => false,
|
||||||
|
'variation' => 1,
|
||||||
),
|
),
|
||||||
) );
|
array(
|
||||||
|
'name' => 'pa_size',
|
||||||
|
'options' => array( 'small' ),
|
||||||
|
'visible' => false,
|
||||||
|
'variation' => 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -227,10 +252,12 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
$this->assertEquals( 'http://woocommerce.com', $data['external_url'] );
|
$this->assertEquals( 'http://woocommerce.com', $data['external_url'] );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'button_text' => 'Test API Update',
|
'button_text' => 'Test API Update',
|
||||||
'external_url' => 'http://automattic.com',
|
'external_url' => 'http://automattic.com',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -248,9 +275,11 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( 0 );
|
wp_set_current_user( 0 );
|
||||||
$product = WC_Helper_Product::create_simple_product();
|
$product = WC_Helper_Product::create_simple_product();
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/' . $product->get_id() );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'sku' => 'FIXED-SKU-NO-PERMISSION',
|
'sku' => 'FIXED-SKU-NO-PERMISSION',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$this->assertEquals( 401, $response->get_status() );
|
$this->assertEquals( 401, $response->get_status() );
|
||||||
$product->delete( true );
|
$product->delete( true );
|
||||||
|
@ -265,9 +294,11 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
$product = WC_Helper_Product::create_simple_product();
|
$product = WC_Helper_Product::create_simple_product();
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/0' );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/products/0' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'sku' => 'FIXED-SKU-INVALID-ID',
|
'sku' => 'FIXED-SKU-INVALID-ID',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$this->assertEquals( 400, $response->get_status() );
|
$this->assertEquals( 400, $response->get_status() );
|
||||||
$product->delete( true );
|
$product->delete( true );
|
||||||
|
@ -282,22 +313,26 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products/shipping_classes' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products/shipping_classes' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'name' => 'Test',
|
'name' => 'Test',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
$shipping_class_id = $data['id'];
|
$shipping_class_id = $data['id'];
|
||||||
|
|
||||||
// Create simple
|
// Create simple
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'type' => 'simple',
|
'type' => 'simple',
|
||||||
'name' => 'Test Simple Product',
|
'name' => 'Test Simple Product',
|
||||||
'sku' => 'DUMMY SKU SIMPLE API',
|
'sku' => 'DUMMY SKU SIMPLE API',
|
||||||
'regular_price' => '10',
|
'regular_price' => '10',
|
||||||
'shipping_class' => 'test',
|
'shipping_class' => 'test',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -311,14 +346,16 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// Create external
|
// Create external
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'type' => 'external',
|
'type' => 'external',
|
||||||
'name' => 'Test External Product',
|
'name' => 'Test External Product',
|
||||||
'sku' => 'DUMMY SKU EXTERNAL API',
|
'sku' => 'DUMMY SKU EXTERNAL API',
|
||||||
'regular_price' => '10',
|
'regular_price' => '10',
|
||||||
'button_text' => 'Test Button',
|
'button_text' => 'Test Button',
|
||||||
'external_url' => 'https://wordpress.org',
|
'external_url' => 'https://wordpress.org',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -333,7 +370,8 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// Create variable
|
// Create variable
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'type' => 'variable',
|
'type' => 'variable',
|
||||||
'name' => 'Test Variable Product',
|
'name' => 'Test Variable Product',
|
||||||
'sku' => 'DUMMY SKU VARIABLE API',
|
'sku' => 'DUMMY SKU VARIABLE API',
|
||||||
|
@ -349,7 +387,8 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
'variation' => 1,
|
'variation' => 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -372,10 +411,12 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( 0 );
|
wp_set_current_user( 0 );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'name' => 'Test Product',
|
'name' => 'Test Product',
|
||||||
'regular_price' => '12',
|
'regular_price' => '12',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$this->assertEquals( 401, $response->get_status() );
|
$this->assertEquals( 401, $response->get_status() );
|
||||||
}
|
}
|
||||||
|
@ -388,7 +429,8 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
$product = WC_Helper_Product::create_simple_product();
|
$product = WC_Helper_Product::create_simple_product();
|
||||||
$product_2 = WC_Helper_Product::create_simple_product();
|
$product_2 = WC_Helper_Product::create_simple_product();
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/products/batch' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/products/batch' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'update' => array(
|
'update' => array(
|
||||||
array(
|
array(
|
||||||
'id' => $product->get_id(),
|
'id' => $product->get_id(),
|
||||||
|
@ -413,7 +455,8 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
'type' => 'simple',
|
'type' => 'simple',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -445,10 +488,12 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
||||||
for ( $i = 0; $i < 8; $i++ ) {
|
for ( $i = 0; $i < 8; $i++ ) {
|
||||||
$product = WC_Helper_Product::create_simple_product();
|
$product = WC_Helper_Product::create_simple_product();
|
||||||
if ( 0 === $i % 2 ) {
|
if ( 0 === $i % 2 ) {
|
||||||
wp_update_post( array(
|
wp_update_post(
|
||||||
|
array(
|
||||||
'ID' => $product->get_id(),
|
'ID' => $product->get_id(),
|
||||||
'post_status' => 'draft',
|
'post_status' => 'draft',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,11 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->endpoint = new WC_REST_Shipping_Zones_Controller();
|
$this->endpoint = new WC_REST_Shipping_Zones_Controller();
|
||||||
$this->user = $this->factory->user->create( array(
|
$this->user = $this->factory->user->create(
|
||||||
|
array(
|
||||||
'role' => 'administrator',
|
'role' => 'administrator',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$this->zones = array();
|
$this->zones = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +84,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
$this->assertEquals( 200, $response->get_status() );
|
$this->assertEquals( 200, $response->get_status() );
|
||||||
$this->assertEquals( count( $data ), 1 );
|
$this->assertEquals( count( $data ), 1 );
|
||||||
$this->assertContains( array(
|
$this->assertContains(
|
||||||
|
array(
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
'name' => 'Locations not covered by your other zones',
|
'name' => 'Locations not covered by your other zones',
|
||||||
'order' => 0,
|
'order' => 0,
|
||||||
|
@ -103,7 +106,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), $data );
|
), $data
|
||||||
|
);
|
||||||
|
|
||||||
// Create a zone and make sure it's in the response
|
// Create a zone and make sure it's in the response
|
||||||
$this->create_shipping_zone( 'Zone 1' );
|
$this->create_shipping_zone( 'Zone 1' );
|
||||||
|
@ -113,7 +117,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
$this->assertEquals( 200, $response->get_status() );
|
$this->assertEquals( 200, $response->get_status() );
|
||||||
$this->assertEquals( count( $data ), 2 );
|
$this->assertEquals( count( $data ), 2 );
|
||||||
$this->assertContains( array(
|
$this->assertContains(
|
||||||
|
array(
|
||||||
'id' => 1,
|
'id' => 1,
|
||||||
'name' => 'Zone 1',
|
'name' => 'Zone 1',
|
||||||
'order' => 0,
|
'order' => 0,
|
||||||
|
@ -134,7 +139,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), $data );
|
), $data
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,15 +193,18 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'name' => 'Test Zone',
|
'name' => 'Test Zone',
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
$this->assertEquals( 201, $response->get_status() );
|
$this->assertEquals( 201, $response->get_status() );
|
||||||
$this->assertEquals( array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'id' => $data['id'],
|
'id' => $data['id'],
|
||||||
'name' => 'Test Zone',
|
'name' => 'Test Zone',
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
|
@ -216,7 +225,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), $data );
|
), $data
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,10 +237,12 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( 0 );
|
wp_set_current_user( 0 );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'name' => 'Test Zone',
|
'name' => 'Test Zone',
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$this->assertEquals( 401, $response->get_status() );
|
$this->assertEquals( 401, $response->get_status() );
|
||||||
}
|
}
|
||||||
|
@ -245,15 +257,18 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
$zone = $this->create_shipping_zone( 'Test Zone' );
|
$zone = $this->create_shipping_zone( 'Test Zone' );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/shipping/zones/' . $zone->get_id() );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/shipping/zones/' . $zone->get_id() );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'name' => 'Zone Test',
|
'name' => 'Zone Test',
|
||||||
'order' => 2,
|
'order' => 2,
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
$this->assertEquals( 200, $response->get_status() );
|
$this->assertEquals( 200, $response->get_status() );
|
||||||
$this->assertEquals( array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'id' => $zone->get_id(),
|
'id' => $zone->get_id(),
|
||||||
'name' => 'Zone Test',
|
'name' => 'Zone Test',
|
||||||
'order' => 2,
|
'order' => 2,
|
||||||
|
@ -274,7 +289,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), $data );
|
), $data
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -285,10 +301,12 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/shipping/zones/555555' );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/shipping/zones/555555' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'name' => 'Zone Test',
|
'name' => 'Zone Test',
|
||||||
'order' => 2,
|
'order' => 2,
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
|
|
||||||
$this->assertEquals( 404, $response->get_status() );
|
$this->assertEquals( 404, $response->get_status() );
|
||||||
|
@ -347,7 +365,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
$this->assertEquals( 200, $response->get_status() );
|
$this->assertEquals( 200, $response->get_status() );
|
||||||
$this->assertEquals( array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'id' => $zone->get_id(),
|
'id' => $zone->get_id(),
|
||||||
'name' => 'Test Zone',
|
'name' => 'Test Zone',
|
||||||
'order' => 0,
|
'order' => 0,
|
||||||
|
@ -368,7 +387,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), $data );
|
), $data
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -391,19 +411,22 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
|
|
||||||
// Create a zone
|
// Create a zone
|
||||||
$zone = $this->create_shipping_zone( 'Zone 1', 0, array(
|
$zone = $this->create_shipping_zone(
|
||||||
|
'Zone 1', 0, array(
|
||||||
array(
|
array(
|
||||||
'code' => 'US',
|
'code' => 'US',
|
||||||
'type' => 'country',
|
'type' => 'country',
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/shipping/zones/' . $zone->get_id() . '/locations' ) );
|
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/shipping/zones/' . $zone->get_id() . '/locations' ) );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
$this->assertEquals( 200, $response->get_status() );
|
$this->assertEquals( 200, $response->get_status() );
|
||||||
$this->assertEquals( count( $data ), 1 );
|
$this->assertEquals( count( $data ), 1 );
|
||||||
$this->assertEquals( array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
array(
|
array(
|
||||||
'code' => 'US',
|
'code' => 'US',
|
||||||
'type' => 'country',
|
'type' => 'country',
|
||||||
|
@ -420,7 +443,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), $data );
|
), $data
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -446,7 +470,9 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'PUT', '/wc/v2/shipping/zones/' . $zone->get_id() . '/locations' );
|
$request = new WP_REST_Request( 'PUT', '/wc/v2/shipping/zones/' . $zone->get_id() . '/locations' );
|
||||||
$request->add_header( 'Content-Type', 'application/json' );
|
$request->add_header( 'Content-Type', 'application/json' );
|
||||||
$request->set_body( json_encode( array(
|
$request->set_body(
|
||||||
|
json_encode(
|
||||||
|
array(
|
||||||
array(
|
array(
|
||||||
'code' => 'UK',
|
'code' => 'UK',
|
||||||
'type' => 'country',
|
'type' => 'country',
|
||||||
|
@ -461,12 +487,15 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
array(
|
array(
|
||||||
'type' => 'continent', // test that locations missing "code" aren't saved
|
'type' => 'continent', // test that locations missing "code" aren't saved
|
||||||
),
|
),
|
||||||
) ) );
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
$this->assertEquals( 3, count( $data ) );
|
$this->assertEquals( 3, count( $data ) );
|
||||||
$this->assertEquals( array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
array(
|
array(
|
||||||
'code' => 'UK',
|
'code' => 'UK',
|
||||||
'type' => 'country',
|
'type' => 'country',
|
||||||
|
@ -515,7 +544,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), $data );
|
), $data
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -659,11 +689,13 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// Update a single value
|
// Update a single value
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'settings' => array(
|
'settings' => array(
|
||||||
'cost' => 5,
|
'cost' => 5,
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -676,12 +708,14 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// Test multiple settings
|
// Test multiple settings
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'settings' => array(
|
'settings' => array(
|
||||||
'cost' => 10,
|
'cost' => 10,
|
||||||
'tax_status' => 'none',
|
'tax_status' => 'none',
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -694,12 +728,14 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
|
|
||||||
// Test bogus
|
// Test bogus
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'settings' => array(
|
'settings' => array(
|
||||||
'cost' => 10,
|
'cost' => 10,
|
||||||
'tax_status' => 'this_is_not_a_valid_option',
|
'tax_status' => 'this_is_not_a_valid_option',
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$this->assertEquals( 400, $response->get_status() );
|
$this->assertEquals( 400, $response->get_status() );
|
||||||
|
|
||||||
|
@ -708,10 +744,12 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
$this->assertEquals( 1, $data['order'] );
|
$this->assertEquals( 1, $data['order'] );
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones/' . $zone->get_id() . '/methods/' . $instance_id );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'enabled' => false,
|
'enabled' => false,
|
||||||
'order' => 2,
|
'order' => 2,
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
@ -729,11 +767,13 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
||||||
wp_set_current_user( $this->user );
|
wp_set_current_user( $this->user );
|
||||||
$zone = $this->create_shipping_zone( 'Zone 1' );
|
$zone = $this->create_shipping_zone( 'Zone 1' );
|
||||||
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones/' . $zone->get_id() . '/methods' );
|
$request = new WP_REST_Request( 'POST', '/wc/v2/shipping/zones/' . $zone->get_id() . '/methods' );
|
||||||
$request->set_body_params( array(
|
$request->set_body_params(
|
||||||
|
array(
|
||||||
'method_id' => 'flat_rate',
|
'method_id' => 'flat_rate',
|
||||||
'enabled' => false,
|
'enabled' => false,
|
||||||
'order' => 2,
|
'order' => 2,
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
$response = $this->server->dispatch( $request );
|
$response = $this->server->dispatch( $request );
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue