Unit Tests: Added test_add_discount method.
This commit is contained in:
parent
e2df8e9b87
commit
1bfab57e29
|
@ -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 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue