diff --git a/tests/unit-tests/api/orders.php b/tests/unit-tests/api/orders.php index a13e31932f3..dcedb963518 100644 --- a/tests/unit-tests/api/orders.php +++ b/tests/unit-tests/api/orders.php @@ -333,12 +333,15 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case { /** * Tests updating an order and adding a coupon. * - * @since 3.0.0 + * @since 3.3.0 */ public function test_update_order_add_coupons() { wp_set_current_user( $this->user ); $order = WC_Helper_Order::create_order(); - + $order_item = current( $order->get_items() ); + $coupon = WC_Helper_Coupon::create_coupon( 'fake-coupon' ); + $coupon->set_amount( 5 ); + $coupon->save(); $request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() ); $request->set_body_params( array( 'coupon_lines' => array( @@ -348,6 +351,13 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case { 'discount_tax' => '0', ), ), + 'line_items' => array( + array( + 'id' => $order_item->get_id(), + 'product_id' => $order_item->get_product_id(), + 'total' => '35.00', + ), + ), ) ); $response = $this->server->dispatch( $request ); $data = $response->get_data(); @@ -362,11 +372,12 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case { /** * Tests updating an order and removing a coupon. * - * @since 3.0.0 + * @since 3.3.0 */ public function test_update_order_remove_coupons() { wp_set_current_user( $this->user ); $order = WC_Helper_Order::create_order(); + $order_item = current( $order->get_items() ); $coupon = WC_Helper_Coupon::create_coupon( 'fake-coupon' ); $coupon->set_amount( 5 ); $coupon->save(); @@ -387,6 +398,13 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case { 'code' => null, ), ), + 'line_items' => array( + array( + 'id' => $order_item->get_id(), + 'product_id' => $order_item->get_product_id(), + 'total' => '40.00', + ), + ), ) ); $response = $this->server->dispatch( $request ); $data = $response->get_data();