From 2b7e725928be7e5fa9b21269d5b2dbaf157a0497 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Wed, 24 Aug 2016 14:17:58 -0300 Subject: [PATCH] Tests for wc_get_coupon_code_by_id() --- tests/unit-tests/coupon/functions.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unit-tests/coupon/functions.php b/tests/unit-tests/coupon/functions.php index 5dd4f74358d..a91c03048f5 100644 --- a/tests/unit-tests/coupon/functions.php +++ b/tests/unit-tests/coupon/functions.php @@ -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() ); } + /** + * 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 ) ); + } + }