2017-09-06 23:25:41 +00:00
|
|
|
<?php
|
2017-09-05 19:52:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Functions.
|
|
|
|
*
|
|
|
|
* @package WooCommerce\Tests\Core
|
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
class WC_Tests_WooCommerce_Functions extends WC_Unit_Test_Case {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests wc_maybe_define_constant().
|
|
|
|
*
|
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
public function test_wc_maybe_define_constant() {
|
|
|
|
$this->assertFalse( defined( 'WC_TESTING_DEFINE_FUNCTION' ) );
|
|
|
|
|
|
|
|
// Check if defined.
|
|
|
|
wc_maybe_define_constant( 'WC_TESTING_DEFINE_FUNCTION', true );
|
|
|
|
$this->assertTrue( defined( 'WC_TESTING_DEFINE_FUNCTION' ) );
|
|
|
|
|
|
|
|
// Check value.
|
|
|
|
wc_maybe_define_constant( 'WC_TESTING_DEFINE_FUNCTION', false );
|
|
|
|
$this->assertTrue( WC_TESTING_DEFINE_FUNCTION );
|
|
|
|
}
|
2017-09-07 20:50:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests wc_create_order() and wc_update_order() currency handling.
|
|
|
|
*
|
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
public function test_wc_create_update_order_currency() {
|
|
|
|
$old_currency = get_woocommerce_currency();
|
|
|
|
$new_currency = 'BGN';
|
|
|
|
|
|
|
|
update_option( 'woocommerce_currency', $new_currency );
|
|
|
|
|
|
|
|
// New order should be created using shop currency.
|
|
|
|
$order = wc_create_order( array(
|
|
|
|
'status' => 'pending',
|
|
|
|
'customer_id' => 1,
|
|
|
|
) );
|
|
|
|
$this->assertEquals( $new_currency, $order->get_currency() );
|
|
|
|
|
|
|
|
update_option( 'woocommerce_currency', $old_currency );
|
|
|
|
|
|
|
|
// Currency should not change when order is updated.
|
|
|
|
$order = wc_update_order( array(
|
|
|
|
'customer_id' => 2,
|
|
|
|
'order_id' => $order->get_id(),
|
|
|
|
) );
|
|
|
|
$this->assertEquals( $new_currency, $order->get_currency() );
|
|
|
|
}
|
2017-09-05 19:52:20 +00:00
|
|
|
}
|