Unit Tests: Added test_add_discount method.

This commit is contained in:
Barry Kooij 2014-10-28 11:52:44 +01:00
parent e2df8e9b87
commit 1bfab57e29
1 changed files with 26 additions and 1 deletions

View File

@ -428,6 +428,31 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( apply_filters( 'woocommerce_cart_needs_shipping_address', $needs_shipping_address ), WC()->cart->needs_shipping_address() );
}
/**
* DISCOUNT TESTS
*/
/**
* Test add_discount method
*/
public function test_add_discount() {
// Create coupon
$coupon = WC_Helper_Coupon::create_coupon();
// Add coupon, test return statement
$this->assertTrue( WC()->cart->add_discount( $coupon->code ) );
// Test if total amount of coupons is 1
$this->assertEquals( 1, count( WC()->cart->get_applied_coupons() ) );
// Clean up the cart
WC()->cart->empty_cart();
// Delete coupon
WC_Helper_Coupon::delete_coupon( $coupon->id );
}
}