Merge pull request #17428 from woocommerce/fix/17424
Fix order methods and add tests
This commit is contained in:
commit
3b43657932
|
@ -848,7 +848,7 @@ class WC_Order extends WC_Abstract_Order {
|
|||
* @return boolean
|
||||
*/
|
||||
public function has_billing_address() {
|
||||
return $this->get_shipping_address_1() || $this->get_shipping_address_2();
|
||||
return $this->get_billing_address_1() || $this->get_billing_address_2();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1037,6 +1037,46 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
$this->assertEquals( $set_to, $object->get_shipping_country() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_formatted_billing_address and has_billing_address.
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
function test_get_has_formatted_billing_address() {
|
||||
$order = new WC_Order;
|
||||
|
||||
$this->assertEquals( 'none', $order->get_formatted_billing_address( 'none' ) );
|
||||
|
||||
$order->set_billing_address_1( '123 Test St.' );
|
||||
$order->set_billing_country( 'US' );
|
||||
$order->set_billing_city( 'Portland' );
|
||||
$order->set_billing_postcode( '97266' );
|
||||
$this->assertEquals( '123 Test St.<br/>Portland, 97266<br/>United States (US)', $order->get_formatted_billing_address( 'none' ) );
|
||||
|
||||
$this->assertTrue( $order->has_billing_address() );
|
||||
$this->assertFalse( $order->has_shipping_address() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_formatted_shipping_address and has_shipping_address.
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
function test_get_has_formatted_shipping_address() {
|
||||
$order = new WC_Order;
|
||||
|
||||
$this->assertEquals( 'none', $order->get_formatted_shipping_address( 'none' ) );
|
||||
|
||||
$order->set_shipping_address_1( '123 Test St.' );
|
||||
$order->set_shipping_country( 'US' );
|
||||
$order->set_shipping_city( 'Portland' );
|
||||
$order->set_shipping_postcode( '97266' );
|
||||
$this->assertEquals( '123 Test St.<br/>Portland, 97266<br/>United States (US)', $order->get_formatted_shipping_address( 'none' ) );
|
||||
|
||||
$this->assertFalse( $order->has_billing_address() );
|
||||
$this->assertTrue( $order->has_shipping_address() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test: Setting/getting shipping settings after an order is saved
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue