Set menu order so products return in correct order for tests.

This commit is contained in:
Mike Jolley 2016-12-05 15:43:08 +00:00
parent 162aa986b6
commit 8e81526bfc
1 changed files with 9 additions and 2 deletions

View File

@ -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.