Unit Tests: Made coupon tests non depend on each other. Added correct cleaning of coupons.
This commit is contained in:
parent
3d7108278d
commit
5fcc2554cb
|
@ -21,6 +21,9 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
|
|||
// Clean up the cart
|
||||
WC()->cart->empty_cart();
|
||||
|
||||
// Remove coupons
|
||||
WC()->cart->remove_coupons();
|
||||
|
||||
// Delete coupon
|
||||
WC_Helper_Coupon::delete_coupon( $coupon->id );
|
||||
}
|
||||
|
@ -36,7 +39,7 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
|
|||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
|
||||
// Add coupon
|
||||
WC()->cart->add_discount( $coupon->code );
|
||||
$this->assertTrue( WC()->cart->add_discount( $coupon->code ) );
|
||||
|
||||
// Add coupon again, test return statement
|
||||
$this->assertFalse( WC()->cart->add_discount( $coupon->code ) );
|
||||
|
@ -50,6 +53,9 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
|
|||
// Clean up the cart
|
||||
WC()->cart->empty_cart();
|
||||
|
||||
// Remove coupons
|
||||
WC()->cart->remove_coupons();
|
||||
|
||||
// Delete coupon
|
||||
WC_Helper_Coupon::delete_coupon( $coupon->id );
|
||||
}
|
||||
|
@ -98,6 +104,9 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
|
|||
// Clean up the cart
|
||||
WC()->cart->empty_cart();
|
||||
|
||||
// Remove coupons
|
||||
WC()->cart->remove_coupons();
|
||||
|
||||
// Delete the flat rate method
|
||||
WC()->session->set( 'chosen_shipping_methods', array() );
|
||||
WC_Helper_Shipping::delete_simple_flat_rate();
|
||||
|
@ -153,6 +162,9 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
|
|||
// Clean up the cart
|
||||
WC()->cart->empty_cart();
|
||||
|
||||
// Remove coupons
|
||||
WC()->cart->remove_coupons();
|
||||
|
||||
// Delete the flat rate method
|
||||
WC()->session->set( 'chosen_shipping_methods', array() );
|
||||
WC_Helper_Shipping::delete_simple_flat_rate();
|
||||
|
@ -211,6 +223,9 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
|
|||
// Clean up the cart
|
||||
WC()->cart->empty_cart();
|
||||
|
||||
// Remove coupons
|
||||
WC()->cart->remove_coupons();
|
||||
|
||||
// Remove fee
|
||||
WC_Helper_Fee::remove_cart_fee();
|
||||
|
||||
|
@ -272,6 +287,9 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
|
|||
// Clean up the cart
|
||||
WC()->cart->empty_cart();
|
||||
|
||||
// Remove coupons
|
||||
WC()->cart->remove_coupons();
|
||||
|
||||
// Remove fee
|
||||
WC_Helper_Fee::remove_cart_fee();
|
||||
|
||||
|
@ -285,4 +303,5 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
|
|||
// Delete product
|
||||
WC_Helper_Product::delete_product( $product->id );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue