/** * @param AddressInterface|null $shippingAddress * * @return ZoneInterface|null */ private function getTaxZone(AddressInterface $shippingAddress = null) { $zone = null; if (null !== $shippingAddress) { $zone = $this->zoneMatcher->match($shippingAddress); } return $zone ?: $this->defaultTaxZoneProvider->getZone(); }
/** * @param OrderInterface $order * * @return ZoneInterface|null */ private function getTaxZone(OrderInterface $order) { $shippingAddress = $order->getShippingAddress(); $zone = null; if (null !== $shippingAddress) { $zone = $this->zoneMatcher->match($shippingAddress); } return $zone ?: $this->defaultTaxZoneProvider->getZone($order); }
function it_does_not_process_taxes_if_there_is_no_tax_zone(ZoneProviderInterface $defaultTaxZoneProvider, ZoneMatcherInterface $zoneMatcher, PrioritizedServiceRegistryInterface $strategyRegistry, OrderInterface $order, OrderItemInterface $orderItem, AddressInterface $address) { $order->getItems()->willReturn([$orderItem]); $order->isEmpty()->willReturn(false); $order->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled(); $orderItem->removeAdjustmentsRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled(); $order->getShippingAddress()->willReturn($address); $zoneMatcher->match($address)->willReturn(null); $defaultTaxZoneProvider->getZone($order)->willReturn(null); $strategyRegistry->all()->shouldNotBeCalled(); $this->process($order); }
function it_does_not_process_taxes_if_there_is_no_tax_zone(ZoneProviderInterface $defaultTaxZoneProvider, ZoneMatcherInterface $zoneMatcher, AddressInterface $address, \Iterator $itemsIterator, Collection $items, OrderInterface $order, OrderItemInterface $orderItem, PrioritizedServiceRegistryInterface $strategyRegistry) { $order->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled(); $order->getItems()->willReturn($items); $order->isEmpty()->willReturn(false); $items->count()->willReturn(1); $items->getIterator()->willReturn($itemsIterator); $itemsIterator->rewind()->shouldBeCalled(); $itemsIterator->valid()->willReturn(true, false)->shouldBeCalled(); $itemsIterator->current()->willReturn($orderItem); $itemsIterator->next()->shouldBeCalled(); $orderItem->removeAdjustmentsRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled(); $order->getShippingAddress()->willReturn($address); $zoneMatcher->match($address)->willReturn(null); $defaultTaxZoneProvider->getZone($order)->willReturn(null); $strategyRegistry->all()->shouldNotBeCalled(); $this->process($order); }