Shipping tests: pickup identity
What this covers
The merchant defines collection points, and the shopper should see one option per open branch, named correctly and treated as pickup everywhere. PHP and client.
Expected behaviour
- One option per enabled location, with the right name and label
- A disabled location produces nothing
- The order summary groups it as collection rather than delivery
- Every part of the system agrees on which methods count as pickup, including the deliberate difference between the canonical list and the registered-methods list
Where it breaks
- The method is enabled but no location is, so the list is empty rather than absent
- A location is deleted while a shopper has it selected
- Disabling a middle location leaves non-contiguous ids, and matching must survive that
- A location with an incomplete address still produces an option, but with empty address fields
Already covered
More than the settings themselves. PickupLocationsRestControllerTest holds 11 tests: a shop manager can update the settings and an editor cannot, method settings and locations persist, incomplete locations are dropped, partial address keys are defaulted, omitted parameters are not overwritten, HTML is stripped from the title and from location fields while safe HTML survives in details, and a cost formula is preserved verbatim. So the save side is guarded, including permissions and sanitisation.
LocalPickupUtilsTest adds 8 tests, every one calling LocalPickupUtils::get_local_pickup_method_locations(), the editor preview helper: builtin locations, placeholders for custom methods that declare pickup support, no placeholder for a regular method, no duplicate for the builtin method, the store base as a placeholder address, and details carrying the method title.
Not covered
The emission side, entirely. Reading the source, PickupLocation::calculate_shipping() should run throughout the Checkout.php suite, since its setUp calls shipping_add_pickup_location() and WC_Shipping::load_shipping_methods() registers non-zone methods into every package (class-wc-shipping.php:180-182). That is inferred rather than observed, and either way nothing asserts what it emits:
- One rate per enabled location
- The id keyed by the original array index rather than a running counter
- The label format
- All rates sharing one cost
- Zero enabled locations yielding zero rates even with the method enabled
- An incomplete address still emitting a rate, but with empty address meta
LocalPickupUtils::get_local_pickup_method_ids()runs on every package calculation, throughShippingController::filter_shipping_packages(), but no test names it or asserts anything it decides. FiveShippingControllermethods and the frontendcollectableMethodIdsflag depend on it
A behaviour to pin with its rationale
The two "is this pickup" lists diverge on purpose. ShippingController.php:499-503 states why: the order path must use the canonical woocommerce_local_pickup_methods list, because relying on currently-registered methods would miss legacy or deregistered methods on existing orders and tax them at the wrong address. The hardcoded local_pickup seed came from woocommerce#56922. Pin the behaviour and carry that rationale into the test docblock rather than treating the divergence as a bug.
Conventions
An assertion that "only these method ids count as pickup" pins a list woocommerce_local_pickup_methods exists to let extensions extend. Assert instead that a method id added through the filter is treated as pickup.
Integration and unit tests only, no E2E.
Source: woocommerce/woocommerce