From 84a930a607a4ef5cbfeb200565abfecd58472dfb Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 5 Dec 2016 18:51:29 +0000 Subject: [PATCH] Variations are returned newest to oldest in tests. Ensure dates differ. --- tests/framework/helpers/class-wc-helper-product.php | 11 ++--------- tests/unit-tests/api/product-variations.php | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/framework/helpers/class-wc-helper-product.php b/tests/framework/helpers/class-wc-helper-product.php index a98310fc7cc..17415cb4b43 100644 --- a/tests/framework/helpers/class-wc-helper-product.php +++ b/tests/framework/helpers/class-wc-helper-product.php @@ -26,12 +26,10 @@ class WC_Helper_Product { */ public static function create_simple_product() { // Create the product - $product_count = wp_count_posts( 'product' ); - $product = wp_insert_post( array( + $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' ); @@ -57,12 +55,10 @@ 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' ); @@ -84,12 +80,10 @@ 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 ); @@ -120,12 +114,10 @@ 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. @@ -177,6 +169,7 @@ class WC_Helper_Product { 'post_parent' => $product_id, 'post_status' => 'publish', 'menu_order' => 1, + 'post_date' => date( 'Y-m-d H:i:s', time() - 30 ), // Makes sure post dates differ if super quick. ) ); // Price related meta diff --git a/tests/unit-tests/api/product-variations.php b/tests/unit-tests/api/product-variations.php index 0356165eff6..96c6b42c273 100644 --- a/tests/unit-tests/api/product-variations.php +++ b/tests/unit-tests/api/product-variations.php @@ -43,7 +43,7 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case { $variations = $response->get_data(); $this->assertEquals( 200, $response->get_status() ); $this->assertEquals( 2, count( $variations ) ); - $this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variations[0]['sku'] ); + $this->assertEquals( 'DUMMY SKU VARIABLE LARGE', $variations[0]['sku'] ); $this->assertEquals( 'size', $variations[0]['attributes'][0]['name'] ); $product->delete( true ); }