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_adds_new_item_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, Collection $shipments, OrderItemUnitInterface $itemUnit, OrderItemUnitInterface $itemUnitWithoutShipment)
 {
     $shipments->first()->willReturn($shipment);
     $order->isEmpty()->willReturn(false);
     $order->hasShipments()->willReturn(true);
     $order->getItemUnits()->willReturn([$itemUnit, $itemUnitWithoutShipment]);
     $order->getShipments()->willReturn($shipments);
     $itemUnit->getShipment()->willReturn($shipment);
     $shipment->addUnit($itemUnitWithoutShipment)->shouldBeCalled();
     $shipment->addUnit($itemUnit)->shouldNotBeCalled();
     $this->process($order);
 }
 /**
  * {@inheritdoc}
  */
 public function process(OrderInterface $order)
 {
     if ($order->isEmpty()) {
         $order->removeShipments();
         return;
     }
     $shipment = $this->getOrderShipment($order);
     if (null === $shipment) {
         return;
     }
     foreach ($order->getItemUnits() as $itemUnit) {
         if (null === $itemUnit->getShipment()) {
             $shipment->addUnit($itemUnit);
         }
     }
 }
 function it_does_not_apply_taxes_if_there_is_no_tax_zone($defaultTaxZoneProvider, $zoneMatcher, $orderItemsTaxesApplicator, AddressInterface $address, \Iterator $iterator, Collection $items, OrderInterface $order, OrderItemInterface $orderItem)
 {
     $order->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled();
     $order->getItems()->willReturn($items);
     $order->isEmpty()->willReturn(false);
     $items->count()->willReturn(1);
     $items->getIterator()->willReturn($iterator);
     $iterator->rewind()->shouldBeCalled();
     $iterator->valid()->willReturn(true, false)->shouldBeCalled();
     $iterator->current()->willReturn($orderItem);
     $iterator->next()->shouldBeCalled();
     $orderItem->removeAdjustmentsRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled();
     $order->getShippingAddress()->willReturn($address);
     $zoneMatcher->match($address)->willReturn(null);
     $defaultTaxZoneProvider->getZone()->willReturn(null);
     $orderItemsTaxesApplicator->apply(Argument::any())->shouldNotBeCalled();
     $this->apply($order);
 }
Example #5
0
 public function addressingAction(Request $request, OrderInterface $order)
 {
     if ($order->isEmpty()) {
         return new Response('Order cannot be empty!', 400);
     }
     if ($request->isMethod('GET')) {
         return new Response('Method not allowed!', 405);
     }
     $this->dispatchCheckoutEvent(SyliusCheckoutEvents::ADDRESSING_INITIALIZE, $order);
     $form = $this->createCheckoutAddressingForm($order);
     if ($form->submit($request)->isValid()) {
         $this->dispatchCheckoutEvent(SyliusCheckoutEvents::ADDRESSING_PRE_COMPLETE, $order);
         $stateMachine = $this->get('sm.factory')->get($order, OrderCheckoutTransitions::GRAPH);
         $stateMachine->apply(OrderCheckoutTransitions::SYLIUS_ADDRESSING);
         $this->getManager()->persist($order);
         $this->getManager()->flush();
         $this->dispatchCheckoutEvent(SyliusCheckoutEvents::ADDRESSING_COMPLETE, $order);
         return $this->handleView($this->view($order));
     }
     return $this->handleView($this->view($form, 400));
 }
 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);
 }