From fd0d3e05ddb3763742e0a3d58e20a42c0707e482 Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Thu, 21 Apr 2022 16:37:13 +0530 Subject: [PATCH] Applied PR feedback. --- .../rest-api/Helpers/OrderHelper.php | 29 ++++++++++--------- .../Orders/OrdersTableDataStoreTests.php | 9 ------ 2 files changed, 16 insertions(+), 22 deletions(-) delete mode 100644 plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php diff --git a/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Helpers/OrderHelper.php b/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Helpers/OrderHelper.php index 70c652b9a69..5d88a610ecf 100644 --- a/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Helpers/OrderHelper.php +++ b/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Helpers/OrderHelper.php @@ -1,12 +1,15 @@ - '', ); - $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // Required, else wc_create_order throws an exception + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // Required, else wc_create_order throws an exception. $order = wc_create_order( $order_data ); - // Add order products + // Add order products. $item = new WC_Order_Item_Product(); $item->set_props( array( @@ -83,7 +86,7 @@ class OrderHelper { $item->save(); $order->add_item( $item ); - // Set billing address + // Set billing address. $order->set_billing_first_name( 'Jeroen' ); $order->set_billing_last_name( 'Sormani' ); $order->set_billing_company( 'WooCompany' ); @@ -96,7 +99,7 @@ class OrderHelper { $order->set_billing_email( 'admin@example.org' ); $order->set_billing_phone( '555-32123' ); - // Add shipping costs + // Add shipping costs. $shipping_taxes = WC_Tax::calc_shipping_tax( '10', WC_Tax::get_shipping_tax_rates() ); $rate = new WC_Shipping_Rate( 'flat_rate_shipping', 'Flat rate shipping', '10', $shipping_taxes, 'flat_rate' ); $item = new WC_Order_Item_Shipping(); @@ -113,17 +116,17 @@ class OrderHelper { } $order->add_item( $item ); - // Set payment gateway + // Set payment gateway. $payment_gateways = WC()->payment_gateways->payment_gateways(); $order->set_payment_method( $payment_gateways['bacs'] ); - // Set totals + // Set totals. $order->set_shipping_total( 10 ); $order->set_discount_total( 0 ); $order->set_discount_tax( 0 ); $order->set_cart_tax( 0 ); $order->set_shipping_tax( 0 ); - $order->set_total( 50 ); // 4 x $10 simple helper product + $order->set_total( 50 ); // 4 x $10 simple helper product. $order->save(); return $order; @@ -134,7 +137,7 @@ class OrderHelper { */ public static function create_order_custom_table_if_not_exist() { $order_table_controller = wc_get_container() - ->get( 'Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController' ); + ->get( CustomOrdersTableController::class ); $order_table_controller->show_feature(); $synchronizer = wc_get_container() ->get( DataSynchronizer::class ); @@ -166,7 +169,7 @@ class OrderHelper { ShippingHelper::create_simple_flat_rate(); - $order = OrderHelper::create_order(); + $order = self::create_order(); // Make sure this is a wp_post order. $post = get_post( $order->get_id() ); assert( isset( $post ) ); diff --git a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php deleted file mode 100644 index 595f93d38f9..00000000000 --- a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php +++ /dev/null @@ -1,9 +0,0 @@ -