Tests for wc_get_coupon_code_by_id()

This commit is contained in:
Claudio Sanches 2016-08-24 14:17:58 -03:00
parent 3633960165
commit 2b7e725928
1 changed files with 18 additions and 0 deletions

View File

@ -44,4 +44,22 @@ class WC_Tests_Functions extends WC_Unit_Test_Case {
$this->assertEquals( apply_filters( 'woocommerce_coupons_enabled', get_option( 'woocommerce_enable_coupons' ) == 'yes' ), wc_coupons_enabled() ); $this->assertEquals( apply_filters( 'woocommerce_coupons_enabled', get_option( 'woocommerce_enable_coupons' ) == 'yes' ), wc_coupons_enabled() );
} }
/**
* Test wc_get_coupon_code_by_id().
*
* @since 2.7.0
*/
public function test_wc_get_coupon_code_by_id() {
// Create coupon.
$code = 'testcoupon';
$coupon = WC_Helper_Coupon::create_coupon( $code );
$this->assertEquals( $code, wc_get_coupon_code_by_id( $coupon->get_id() ) );
// Delete coupon.
WC_Helper_Coupon::delete_coupon( $coupon->get_id() );
$this->assertEmpty( wc_get_coupon_code_by_id( 0 ) );
}
} }