From 5fcc2554cb30db7a65784df6db50adb543d1e9f8 Mon Sep 17 00:00:00 2001 From: Barry Kooij Date: Tue, 11 Nov 2014 14:29:40 +0100 Subject: [PATCH] Unit Tests: Made coupon tests non depend on each other. Added correct cleaning of coupons. --- tests/unit-tests/coupon.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/unit-tests/coupon.php b/tests/unit-tests/coupon.php index f9ace1a51e4..e2020409157 100644 --- a/tests/unit-tests/coupon.php +++ b/tests/unit-tests/coupon.php @@ -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 ); } + }