From ca2ca5a5caf2c6d7d4e0fb47038c11428a47e4f3 Mon Sep 17 00:00:00 2001 From: Joel Rowley Date: Fri, 3 Nov 2017 22:20:41 -0400 Subject: [PATCH] Add unit test to demonstrate type conversion precision bug --- tests/unit-tests/discounts/discounts.php | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/unit-tests/discounts/discounts.php b/tests/unit-tests/discounts/discounts.php index 86d2d915658..734bc6eca83 100644 --- a/tests/unit-tests/discounts/discounts.php +++ b/tests/unit-tests/discounts/discounts.php @@ -1282,6 +1282,37 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case { 'expected_total_discount' => 20, ), ), + array( + array( + 'desc' => 'Test single fixed product coupon on one item to illustrate type conversion precision bug.', + 'tax_rate' => array( + 'tax_rate_country' => '', + 'tax_rate_state' => '', + 'tax_rate' => '20.0000', + 'tax_rate_name' => 'VAT', + 'tax_rate_priority' => '1', + 'tax_rate_compound' => '0', + 'tax_rate_shipping' => '1', + 'tax_rate_order' => '1', + 'tax_rate_class' => '', + ), + 'prices_include_tax' => false, + 'cart' => array( + array( + 'price' => 8.95, + 'qty' => 1, + ), + ), + 'coupons' => array( + array( + 'code' => 'test', + 'discount_type' => 'fixed_product', + 'amount' => '10', + ), + ), + 'expected_total_discount' => 8.95, + ), + ), array( array( 'desc' => 'Test multiple coupons with limits of 1.',