From 8e81526bfc0b68903c4cdaafebb5e48bf8e1a4ab Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 5 Dec 2016 15:43:08 +0000 Subject: [PATCH] Set menu order so products return in correct order for tests. --- tests/framework/helpers/class-wc-helper-product.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/framework/helpers/class-wc-helper-product.php b/tests/framework/helpers/class-wc-helper-product.php index 0ffb604f6c7..a98310fc7cc 100644 --- a/tests/framework/helpers/class-wc-helper-product.php +++ b/tests/framework/helpers/class-wc-helper-product.php @@ -25,12 +25,13 @@ class WC_Helper_Product { * @return WC_Product_Simple */ public static function create_simple_product() { - // Create the product - $product = wp_insert_post( array( + $product_count = wp_count_posts( 'product' ); + $product = wp_insert_post( array( 'post_title' => 'Dummy Product', 'post_type' => 'product', 'post_status' => 'publish', + 'menu_order' => $product_count->publish, ) ); update_post_meta( $product, '_price', '10' ); update_post_meta( $product, '_regular_price', '10' ); @@ -56,10 +57,12 @@ class WC_Helper_Product { */ public static function create_external_product() { // Create the product + $product_count = wp_count_posts( 'product' ); $product = wp_insert_post( array( 'post_title' => 'Dummy External Product', 'post_type' => 'product', 'post_status' => 'publish', + 'menu_order' => $product_count->publish, ) ); update_post_meta( $product, '_price', '10' ); update_post_meta( $product, '_regular_price', '10' ); @@ -81,10 +84,12 @@ class WC_Helper_Product { */ public static function create_grouped_product() { // Create the product + $product_count = wp_count_posts( 'product' ); $product = wp_insert_post( array( 'post_title' => 'Dummy Grouped Product', 'post_type' => 'product', 'post_status' => 'publish', + 'menu_order' => $product_count->publish, ) ); $simple_product_1 = self::create_simple_product( $product ); $simple_product_2 = self::create_simple_product( $product ); @@ -115,10 +120,12 @@ class WC_Helper_Product { $attribute_data = self::create_attribute(); // Create the product + $product_count = wp_count_posts( 'product' ); $product_id = wp_insert_post( array( 'post_title' => 'Dummy Product', 'post_type' => 'product', 'post_status' => 'publish', + 'menu_order' => $product_count->publish, ) ); // Set it as variable.