test wc_get_price_decimals, wc_get_price_decimal_separator, wc_get_price_thousand_separator

This commit is contained in:
Nicola Mustone 2015-04-09 17:35:35 +02:00
parent 58f86eddf9
commit d4ff494a3f
1 changed files with 63 additions and 0 deletions

View File

@ -365,6 +365,69 @@ class Functions extends \WC_Unit_Test_Case {
update_option( 'woocommerce_currency_pos', $currency_pos );
}
/**
* Test wc_get_price_thousand_separator()
*
* @since 2.4
*/
public function test_wc_get_price_thousand_separator() {
$separator = get_option( 'woocommerce_price_thousand_sep' );
// defualt value
$this->assertEquals( ',', wc_get_price_thousand_separator() );
update_option( 'woocommerce_price_thousand_sep', '.' );
$this->assertEquals( '.', wc_get_price_thousand_separator() );
update_option( 'woocommerce_price_thousand_sep', '<.>' );
$this->assertEquals( '<.>', wc_get_price_thousand_separator() );
update_option( 'woocommerce_price_thousand_sep', $separator );
}
/**
* Test wc_get_price_decimal_separator()
*
* @since 2.4
*/
public function test_wc_get_price_decimal_separator() {
$separator = get_option( 'woocommerce_price_decimal_sep' );
// defualt value
$this->assertEquals( '.', wc_get_price_decimal_separator() );
update_option( 'woocommerce_price_decimal_sep', ',' );
$this->assertEquals( ',', wc_get_price_decimal_separator() );
update_option( 'woocommerce_price_decimal_sep', '&lt;.&gt;' );
$this->assertEquals( '<.>', wc_get_price_decimal_separator() );
update_option( 'woocommerce_price_decimal_sep', $separator );
}
/**
* Test wc_get_price_decimals()
*
* @since 2.4
*/
public function test_wc_get_price_decimals() {
$decimals = get_option( 'woocommerce_price_num_decimals' );
// defualt value
$this->assertEquals( 2, wc_get_price_decimals() );
update_option( 'woocommerce_price_num_decimals', '1' );
$this->assertEquals( 1, wc_get_price_decimals() );
update_option( 'woocommerce_price_num_decimals', '-2' );
$this->assertEquals( 2, wc_get_price_decimals() );
update_option( 'woocommerce_price_num_decimals', '2.50' );
$this->assertEquals( 2, wc_get_price_decimals() );
update_option( 'woocommerce_price_num_decimals', $decimals );
}
/**
* Test wc_price()
*