Test unit for PR #36885
This commit is contained in:
parent
072e9a043c
commit
cf3c0c4c98
|
@ -269,4 +269,44 @@ class WC_Abstract_Order_Test extends WC_Unit_Test_Case {
|
|||
$this->assertEquals( $coupon->get_id(), $coupon_data['id'] );
|
||||
$this->assertEquals( $coupon_code, $coupon_data['code'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for get_discount_to_display which must return a value
|
||||
* with and without tax whatever the setting of the options
|
||||
*
|
||||
* Issue :https://github.com/woocommerce/woocommerce/issues/36794
|
||||
*/
|
||||
public function test_get_discount_to_display() {
|
||||
// Set dummy data
|
||||
$tax_rate = array(
|
||||
'tax_rate_country' => '',
|
||||
'tax_rate_state' => '',
|
||||
'tax_rate' => '20.0000',
|
||||
'tax_rate_name' => 'tax',
|
||||
'tax_rate_priority' => '1',
|
||||
'tax_rate_order' => '1',
|
||||
);
|
||||
WC_Tax::_insert_tax_rate( $tax_rate );
|
||||
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
|
||||
$order = new WC_Order();
|
||||
$order->add_product( $product );
|
||||
$order->apply_coupon( $coupon );
|
||||
$order->calculate_totals();
|
||||
$order->save();
|
||||
|
||||
// Test
|
||||
update_option( 'woocommerce_currency', 'USD' );
|
||||
update_option( 'woocommerce_currency_pos', 'right' );
|
||||
update_option( 'woocommerce_price_thousand_sep', '' );
|
||||
update_option( 'woocommerce_price_decimal_sep', '.' );
|
||||
update_option( 'woocommerce_price_num_decimals', 2 );
|
||||
|
||||
update_option( 'woocommerce_tax_display_cart', 'incl' );
|
||||
$this->assertEquals( '1.00$', strip_tags( $order->get_discount_to_display( 'excl' ) ) );
|
||||
$this->assertEquals( '1.20$', strip_tags( $order->get_discount_to_display( 'incl' ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue