Update unit tests to reflect new base address

This commit is contained in:
roykho 2021-04-12 14:13:27 -07:00
parent 6c7c420d25
commit ded5c9c7c4
No known key found for this signature in database
GPG Key ID: 7B36C0EA25795714
12 changed files with 80 additions and 80 deletions

View File

@ -17,15 +17,15 @@ class WC_Helper_Customer {
'id' => 0,
'date_modified' => null,
'country' => 'US',
'state' => 'PA',
'postcode' => '19123',
'city' => 'Philadelphia',
'state' => 'CA',
'postcode' => '94110',
'city' => 'San Francisco',
'address' => '123 South Street',
'address_2' => 'Apt 1',
'shipping_country' => 'US',
'shipping_state' => 'PA',
'shipping_postcode' => '19123',
'shipping_city' => 'Philadelphia',
'shipping_state' => 'CA',
'shipping_postcode' => '94110',
'shipping_city' => 'San Francisco',
'shipping_address' => '123 South Street',
'shipping_address_2' => 'Apt 1',
'is_vat_exempt' => false,
@ -46,15 +46,15 @@ class WC_Helper_Customer {
$customer = new WC_Customer();
$customer->set_billing_country( 'US' );
$customer->set_first_name( 'Justin' );
$customer->set_billing_state( 'PA' );
$customer->set_billing_postcode( '19123' );
$customer->set_billing_city( 'Philadelphia' );
$customer->set_billing_state( 'CA' );
$customer->set_billing_postcode( '94110' );
$customer->set_billing_city( 'San Francisco' );
$customer->set_billing_address( '123 South Street' );
$customer->set_billing_address_2( 'Apt 1' );
$customer->set_shipping_country( 'US' );
$customer->set_shipping_state( 'PA' );
$customer->set_shipping_postcode( '19123' );
$customer->set_shipping_city( 'Philadelphia' );
$customer->set_shipping_state( 'CA' );
$customer->set_shipping_postcode( '94110' );
$customer->set_shipping_city( 'San Francisco' );
$customer->set_shipping_address( '123 South Street' );
$customer->set_shipping_address_2( 'Apt 1' );
$customer->set_username( $username );
@ -70,7 +70,7 @@ class WC_Helper_Customer {
* @return array
*/
public static function get_expected_store_location() {
return array( 'GB', '', '', '' );
return array( 'US', 'CA', '', '' );
}
/**

View File

@ -179,7 +179,7 @@ class WC_Tests_Account_Functions extends WC_Unit_Test_Case {
public function test_wc_get_account_formatted_address() {
$customer = WC_Helper_Customer::create_customer();
$this->assertEquals( '123 South Street<br/>Apt 1<br/>Philadelphia, PA 19123<br/>United States (US)', wc_get_account_formatted_address( 'billing', $customer->get_id() ) );
$this->assertEquals( '123 South Street<br/>Apt 1<br/>San Francisco, CA 94110', wc_get_account_formatted_address( 'billing', $customer->get_id() ) );
$customer->delete( true );
}

View File

@ -324,16 +324,16 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
update_option( 'woocommerce_tax_based_on', 'shipping' );
$taxable = $customer->get_taxable_address();
$this->assertEquals( 'US', $taxable[0] );
$this->assertEquals( 'PA', $taxable[1] );
$this->assertEquals( 'CA', $taxable[1] );
$this->assertEquals( '11111', $taxable[2] );
$this->assertEquals( 'Test', $taxable[3] );
update_option( 'woocommerce_tax_based_on', 'billing' );
$taxable = $customer->get_taxable_address();
$this->assertEquals( 'US', $taxable[0] );
$this->assertEquals( 'PA', $taxable[1] );
$this->assertEquals( '19123', $taxable[2] );
$this->assertEquals( 'Philadelphia', $taxable[3] );
$this->assertEquals( 'CA', $taxable[1] );
$this->assertEquals( '94110', $taxable[2] );
$this->assertEquals( 'San Francisco', $taxable[3] );
update_option( 'woocommerce_tax_based_on', 'base' );
$taxable = $customer->get_taxable_address();
@ -431,7 +431,7 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
*/
public function test_customer_is_customer_outside_base() {
$customer = WC_Helper_Customer::create_customer();
$this->assertTrue( $customer->is_customer_outside_base() );
$this->assertFalse( $customer->is_customer_outside_base() );
update_option( 'woocommerce_tax_based_on', 'base' );
$customer->set_billing_address_to_base();
$this->assertFalse( $customer->is_customer_outside_base() );
@ -444,9 +444,9 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
public function test_customer_sessions() {
$session = WC_Helper_Customer::create_mock_customer(); // set into session....
$this->assertEquals( '19123', $session->get_billing_postcode() );
$this->assertEquals( '94110', $session->get_billing_postcode() );
$this->assertEquals( '123 South Street', $session->get_billing_address() );
$this->assertEquals( 'Philadelphia', $session->get_billing_city() );
$this->assertEquals( 'San Francisco', $session->get_billing_city() );
$session->set_billing_address( '124 South Street' );
$session->save();

View File

@ -83,7 +83,7 @@ class WC_Tests_Customer extends WC_Unit_Test_Case {
// Customer is going with the Free Shipping option, and the store calculates tax based on the customer's billing address.
WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) );
WC_Helper_Customer::set_tax_based_on( 'billing' );
$this->assertEquals( $customer->is_customer_outside_base(), true );
$this->assertEquals( $customer->is_customer_outside_base(), false );
// Customer is going with the Free Shipping option, and the store calculates tax based on the store base location.
WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) );

View File

@ -618,7 +618,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
// Ex tax label.
$calc_taxes = get_option( 'woocommerce_calc_taxes' );
update_option( 'woocommerce_calc_taxes', 'yes' );
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">&pound;</span>1,111.17</bdi></span> <small class="woocommerce-Price-taxLabel tax_label">(ex. VAT)</small>', wc_price( '1111.17', array( 'ex_tax_label' => true ) ) );
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">&pound;</span>1,111.17</bdi></span> <small class="woocommerce-Price-taxLabel tax_label">(ex. tax)</small>', wc_price( '1111.17', array( 'ex_tax_label' => true ) ) );
update_option( 'woocommerce_calc_taxes', $calc_taxes );
}

View File

@ -1245,7 +1245,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
$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->assertEquals( '123 Test St.<br/>Portland, 97266', $order->get_formatted_billing_address( 'none' ) );
$this->assertTrue( $order->has_billing_address() );
$this->assertFalse( $order->has_shipping_address() );
@ -1265,7 +1265,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
$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->assertEquals( '123 Test St.<br/>Portland, 97266', $order->get_formatted_shipping_address( 'none' ) );
$this->assertFalse( $order->has_billing_address() );
$this->assertTrue( $order->has_shipping_address() );
@ -1498,7 +1498,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
$object->set_billing_state( 'Boulder' );
$object->set_billing_postcode( '00001' );
$object->set_billing_country( 'US' );
$this->assertEquals( 'Fred Flintstone<br/>Bedrock Ltd.<br/>34 Stonepants avenue<br/>Rockville<br/>Bedrock, BOULDER 00001<br/>United States (US)', $object->get_formatted_billing_address() );
$this->assertEquals( 'Fred Flintstone<br/>Bedrock Ltd.<br/>34 Stonepants avenue<br/>Rockville<br/>Bedrock, BOULDER 00001', $object->get_formatted_billing_address() );
}
/**
@ -1515,7 +1515,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
$object->set_shipping_state( 'Boulder' );
$object->set_shipping_postcode( '00001' );
$object->set_shipping_country( 'US' );
$this->assertEquals( 'Barney Rubble<br/>Bedrock Ltd.<br/>34 Stonepants avenue<br/>Rockville<br/>Bedrock, BOULDER 00001<br/>United States (US)', $object->get_formatted_shipping_address() );
$this->assertEquals( 'Barney Rubble<br/>Bedrock Ltd.<br/>34 Stonepants avenue<br/>Rockville<br/>Bedrock, BOULDER 00001', $object->get_formatted_shipping_address() );
}
/**

View File

@ -86,15 +86,15 @@ class WC_Test_Privacy_Export extends WC_Unit_Test_Case {
),
array(
'name' => 'Billing City',
'value' => 'Philadelphia',
'value' => 'San Francisco',
),
array(
'name' => 'Billing Postal/Zip Code',
'value' => '19123',
'value' => '94110',
),
array(
'name' => 'Billing State',
'value' => 'PA',
'value' => 'CA',
),
array(
'name' => 'Billing Country / Region',
@ -114,15 +114,15 @@ class WC_Test_Privacy_Export extends WC_Unit_Test_Case {
),
array(
'name' => 'Shipping City',
'value' => 'Philadelphia',
'value' => 'San Francisco',
),
array(
'name' => 'Shipping Postal/Zip Code',
'value' => '19123',
'value' => '94110',
),
array(
'name' => 'Shipping State',
'value' => 'PA',
'value' => 'CA',
),
array(
'name' => 'Shipping Country / Region',

View File

@ -26,15 +26,15 @@ class CustomerHelper {
'id' => 0,
'date_modified' => null,
'country' => 'US',
'state' => 'PA',
'postcode' => '19123',
'city' => 'Philadelphia',
'state' => 'CA',
'postcode' => '94110',
'city' => 'San Francisco',
'address' => '123 South Street',
'address_2' => 'Apt 1',
'shipping_country' => 'US',
'shipping_state' => 'PA',
'shipping_postcode' => '19123',
'shipping_city' => 'Philadelphia',
'shipping_state' => 'CA',
'shipping_postcode' => '94110',
'shipping_city' => 'San Francisco',
'shipping_address' => '123 South Street',
'shipping_address_2' => 'Apt 1',
'is_vat_exempt' => false,
@ -55,15 +55,15 @@ class CustomerHelper {
$customer = new WC_Customer();
$customer->set_billing_country( 'US' );
$customer->set_first_name( 'Justin' );
$customer->set_billing_state( 'PA' );
$customer->set_billing_postcode( '19123' );
$customer->set_billing_city( 'Philadelphia' );
$customer->set_billing_state( 'CA' );
$customer->set_billing_postcode( '94110' );
$customer->set_billing_city( 'San Francisco' );
$customer->set_billing_address( '123 South Street' );
$customer->set_billing_address_2( 'Apt 1' );
$customer->set_shipping_country( 'US' );
$customer->set_shipping_state( 'PA' );
$customer->set_shipping_postcode( '19123' );
$customer->set_shipping_city( 'Philadelphia' );
$customer->set_shipping_state( 'CA' );
$customer->set_shipping_postcode( '94110' );
$customer->set_shipping_city( 'San Francisco' );
$customer->set_shipping_address( '123 South Street' );
$customer->set_shipping_address_2( 'Apt 1' );
$customer->set_username( $username );
@ -79,7 +79,7 @@ class CustomerHelper {
* @return array
*/
public static function get_expected_store_location() {
return array( 'GB', '', '', '' );
return array( 'US', 'CA', '', '' );
}
/**

View File

@ -70,9 +70,9 @@ class Customers_V2 extends WC_REST_Unit_Test_Case {
'company' => '',
'address_1' => '123 South Street',
'address_2' => 'Apt 1',
'city' => 'Philadelphia',
'state' => 'PA',
'postcode' => '19123',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94110',
'country' => 'US',
'email' => '',
'phone' => '',
@ -83,9 +83,9 @@ class Customers_V2 extends WC_REST_Unit_Test_Case {
'company' => '',
'address_1' => '123 South Street',
'address_2' => 'Apt 1',
'city' => 'Philadelphia',
'state' => 'PA',
'postcode' => '19123',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94110',
'country' => 'US',
),
'is_paying_customer' => false,
@ -315,9 +315,9 @@ class Customers_V2 extends WC_REST_Unit_Test_Case {
'company' => '',
'address_1' => '123 South Street',
'address_2' => 'Apt 1',
'city' => 'Philadelphia',
'state' => 'PA',
'postcode' => '19123',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94110',
'country' => 'US',
'email' => '',
'phone' => '',
@ -328,9 +328,9 @@ class Customers_V2 extends WC_REST_Unit_Test_Case {
'company' => '',
'address_1' => '123 South Street',
'address_2' => 'Apt 1',
'city' => 'Philadelphia',
'state' => 'PA',
'postcode' => '19123',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94110',
'country' => 'US',
),
'is_paying_customer' => false,

View File

@ -77,9 +77,9 @@ class Customers extends WC_REST_Unit_Test_Case {
'company' => '',
'address_1' => '123 South Street',
'address_2' => 'Apt 1',
'city' => 'Philadelphia',
'state' => 'PA',
'postcode' => '19123',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94110',
'country' => 'US',
'email' => '',
'phone' => '',
@ -90,9 +90,9 @@ class Customers extends WC_REST_Unit_Test_Case {
'company' => '',
'address_1' => '123 South Street',
'address_2' => 'Apt 1',
'city' => 'Philadelphia',
'state' => 'PA',
'postcode' => '19123',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94110',
'country' => 'US',
),
'is_paying_customer' => false,
@ -147,9 +147,9 @@ class Customers extends WC_REST_Unit_Test_Case {
'company' => '',
'address_1' => '123 South Street',
'address_2' => 'Apt 1',
'city' => 'Philadelphia',
'state' => 'PA',
'postcode' => '19123',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94110',
'country' => 'US',
'email' => '',
'phone' => '',
@ -160,9 +160,9 @@ class Customers extends WC_REST_Unit_Test_Case {
'company' => '',
'address_1' => '123 South Street',
'address_2' => 'Apt 1',
'city' => 'Philadelphia',
'state' => 'PA',
'postcode' => '19123',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94110',
'country' => 'US',
),
'is_paying_customer' => false,
@ -387,9 +387,9 @@ class Customers extends WC_REST_Unit_Test_Case {
'company' => '',
'address_1' => '123 South Street',
'address_2' => 'Apt 1',
'city' => 'Philadelphia',
'state' => 'PA',
'postcode' => '19123',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94110',
'country' => 'US',
'email' => '',
'phone' => '',
@ -400,9 +400,9 @@ class Customers extends WC_REST_Unit_Test_Case {
'company' => '',
'address_1' => '123 South Street',
'address_2' => 'Apt 1',
'city' => 'Philadelphia',
'state' => 'PA',
'postcode' => '19123',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94110',
'country' => 'US',
),
'is_paying_customer' => false,

View File

@ -117,8 +117,8 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
*/
public function test_get_base_tax_rates() {
$tax_rate = array(
'tax_rate_country' => 'GB',
'tax_rate_state' => '',
'tax_rate_country' => 'US',
'tax_rate_state' => 'CA',
'tax_rate' => '20.0000',
'tax_rate_name' => 'VAT',
'tax_rate_priority' => '1',

View File

@ -348,8 +348,8 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case {
public function test_wc_get_base_location() {
$default = wc_get_base_location();
$this->assertEquals( 'GB', $default['country'] );
$this->assertEquals( '', $default['state'] );
$this->assertEquals( 'US', $default['country'] );
$this->assertEquals( 'CA', $default['state'] );
}
/**