Shipping tests: which address is used
What this covers
The merchant forces shipping to the billing address, and the shopper should not be shown a second form. PHP and client.
Expected behaviour
- The shipping address is used by default
- The billing address can be made the default
- Forcing billing hides the separate form, merges the heading, and writes the billing address onto the order as shipping
- Choosing pickup also hides the form
Where it breaks
- Forced billing with an incomplete billing address
- The setting changed while a shopper is mid-checkout
- Forced billing and pickup at once
Already covered
Checkout.php holds three: test_omitted_shipping_address_falls_back_to_billing_address, test_provided_shipping_address_is_used_when_cart_needs_shipping and test_shipping_address_is_ignored_when_cart_does_not_need_shipping, plus test_local_pickup_country_validation and test_local_pickup_invalid_billing_country. The first asserts the order's shipping name, street, city, postcode and country all come from the billing address when the client omits a shipping address, so the server-side fallback is already pinned and is not part of this issue.
ShippingControllerTest::test_has_full_shipping_address_returns_correctly covers the completeness check. legacy/unit-tests/cart/cart.php::test_needs_shipping_address exists but recomputes the expected value with the same condition and filter it is asserting, so it adds little.
Not covered
The forced-billing setting itself. woocommerce_ship_to_destination is touched behaviourally in exactly one place, legacy/unit-tests/order/class-wc-tests-order-functions.php, and otherwise only in REST settings CRUD tests that assert persistence:
- Forcing billing hides the separate form and merges the heading
- The billing address is written onto the order as shipping
- The billing address can be made the default without forcing it
- An incomplete billing address under forced billing
- The setting changed while a shopper is mid-checkout
- Forced billing and pickup at once
Conventions
Integration and unit tests only, no E2E.
Source: woocommerce/woocommerce