get_cart_item_quantities & get_cart_contents_weight tests
This commit is contained in:
parent
4eb971e81d
commit
6560dd42ab
|
@ -40,6 +40,7 @@ class WC_Helper_Product {
|
|||
update_post_meta( $product, '_downloadable', 'no' );
|
||||
update_post_meta( $product, '_virtual', 'no' );
|
||||
update_post_meta( $product, '_stock_status', 'instock' );
|
||||
update_post_meta( $product, '_weight', '1.1' );
|
||||
wp_set_object_terms( $product, 'simple', 'product_type' );
|
||||
|
||||
return new WC_Product_Simple( $product );
|
||||
|
|
|
@ -936,17 +936,6 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
update_option( 'woocommerce_calc_taxes', 'no' );
|
||||
}
|
||||
|
||||
public function test_get_cart_item_quantities() {
|
||||
// Create dummy product.
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
WC()->cart->add_to_cart( $product->get_id(), 1 );
|
||||
$this->assetEquals( 1, WC()->cart->get_cart_item_quantities() );
|
||||
// Clean up the cart.
|
||||
WC()->cart->empty_cart();
|
||||
// Clean up product.
|
||||
WC_Helper_Product::delete_product( $product->get_id() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test needs_shipping_address method.
|
||||
*/
|
||||
|
@ -1328,4 +1317,26 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
$cart = new WC_Cart();
|
||||
$this->assertInstanceOf( 'WC_Cart', $cart );
|
||||
}
|
||||
|
||||
public function test_get_cart_item_quantities() {
|
||||
// Create dummy product.
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
WC()->cart->add_to_cart( $product->get_id(), 1 );
|
||||
$this->assertEquals( 1, array_sum( WC()->cart->get_cart_item_quantities() ) );
|
||||
// Clean up the cart.
|
||||
WC()->cart->empty_cart();
|
||||
// Clean up product.
|
||||
WC_Helper_Product::delete_product( $product->get_id() );
|
||||
}
|
||||
|
||||
public function test_get_cart_contents_weight() {
|
||||
// Create dummy product.
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
WC()->cart->add_to_cart( $product->get_id(), 1 );
|
||||
$this->assertEquals( 1.1, WC()->cart->get_cart_contents_weight() );
|
||||
// Clean up the cart.
|
||||
WC()->cart->empty_cart();
|
||||
// Clean up product.
|
||||
WC_Helper_Product::delete_product( $product->get_id() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue