Unit Tests: split cart check methods.

This commit is contained in:
Barry Kooij 2014-10-25 00:27:14 +02:00
parent 1a3d15ad4c
commit 75484c6d43
1 changed files with 23 additions and 14 deletions

View File

@ -122,6 +122,29 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
WC_Helper_Product::delete_product( $product->id );
}
/**
* Check if we can add a trashed product to the cart
*/
public function test_add_to_cart_trashed() {
// Create dummy product
$product = WC_Helper_Product::create_simple_product();
// Trash product
wp_trash_post( $product->id );
// Refetch product, to be sure
$product = wc_get_product($product->id);
// Add product to cart
$this->assertFalse(WC()->cart->add_to_cart( $product->id, 1 ));
// Clean up the cart
WC()->cart->empty_cart();
// Clean up product
WC_Helper_Product::delete_product( $product->id );
}
/**
* Test add to cart variable product
*
@ -294,8 +317,6 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
*/
public function test_check_cart_item_validity() {
$this->markTestSkipped( 'Skipping as it fails on Travis.' );
// Create dummy product
$product = WC_Helper_Product::create_simple_product();
@ -305,18 +326,6 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
// Check cart validity, should pass
$this->assertTrue( WC()->cart->check_cart_item_validity() );
// Trash product
wp_trash_post( $product->id );
// Clean up the cart
WC()->cart->empty_cart();
// Re-add item to cart
WC()->cart->add_to_cart( $product->id, 1 );
// Check cart validity, should fail
$this->assertIsWPError( WC()->cart->check_cart_item_validity() );
// Clean up the cart
WC()->cart->empty_cart();