function it_throws_an_exception_if_there_is_no_enabled_shipping_methods(ShippingMethodRepositoryInterface $shippingMethodRepository, ShipmentInterface $shipment, ChannelInterface $channel, OrderInterface $order)
 {
     $shipment->getOrder()->willReturn($order);
     $order->getChannel()->willReturn($channel);
     $shippingMethodRepository->findEnabledForChannel($channel)->willReturn([]);
     $this->shouldThrow(UnresolvedDefaultShippingMethodException::class)->during('getDefaultShippingMethod', [$shipment]);
 }
Beispiel #2
0
 function it_calculates_the_flat_rate_amount_configured_on_the_method(ShipmentInterface $shipment, OrderInterface $order, ChannelInterface $channel)
 {
     $shipment->getOrder()->willReturn($order);
     $order->getChannel()->willReturn($channel);
     $channel->getCode()->willReturn('WEB');
     $this->calculate($shipment, ['WEB' => ['amount' => 1500]])->shouldReturn(1500);
 }
 function it_calculates_the_total_with_the_per_unit_amount_configured_on_the_method(ShipmentInterface $shipment, OrderInterface $order, ChannelInterface $channel)
 {
     $shipment->getOrder()->willReturn($order);
     $order->getChannel()->willReturn($channel);
     $channel->getCode()->willReturn('WEB');
     $shipment->getShippingUnitCount()->willReturn(10);
     $this->calculate($shipment, ['WEB' => ['amount' => 200]])->shouldReturn(2000);
 }
Beispiel #4
0
 function it_should_remove_shipment_properly(ShipmentInterface $shipment)
 {
     $shipment->setOrder($this)->shouldBeCalled();
     $this->addShipment($shipment);
     $this->hasShipment($shipment)->shouldReturn(true);
     $shipment->setOrder(null)->shouldBeCalled();
     $this->removeShipment($shipment);
     $this->hasShipment($shipment)->shouldReturn(false);
 }
Beispiel #5
0
 function it_marks_order_as_returned_if_all_shipments_were_returned(OrderInterface $order, ShipmentInterface $shipment1, ShipmentInterface $shipment2)
 {
     $order->isBackorder()->shouldBeCalled()->willReturn(false);
     $order->getShipments()->willReturn(array($shipment1, $shipment2));
     $shipment1->getState()->willReturn(ShipmentInterface::STATE_RETURNED);
     $shipment2->getState()->willReturn(ShipmentInterface::STATE_RETURNED);
     $order->setShippingState(OrderShippingStates::RETURNED)->shouldBeCalled();
     $this->resolveShippingState($order);
 }
 function it_should_delegate_calculation_to_a_calculator_defined_on_shipping_method($registry, ShipmentInterface $shipment, ShippingMethodInterface $method, CalculatorInterface $calculator)
 {
     $shipment->getMethod()->willReturn($method);
     $method->getCalculator()->willReturn('default');
     $method->getConfiguration()->willReturn(array());
     $registry->get('default')->willReturn($calculator);
     $calculator->calculate($shipment, array())->shouldBeCalled()->willReturn(1000);
     $this->calculate($shipment, array())->shouldReturn(1000);
 }
 function it_throws_exception_if_there_is_no_enabled_shipping_methods_for_channel(ChannelInterface $channel, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $firstShippingMethod, ShippingMethodInterface $secondShippingMethod, ShippingMethodInterface $thirdShippingMethod, ShippingMethodRepositoryInterface $shippingMethodRepository)
 {
     $shippingMethodRepository->findBy(['enabled' => true])->willReturn([$firstShippingMethod, $secondShippingMethod, $thirdShippingMethod]);
     $shipment->getOrder()->willReturn($order);
     $order->getChannel()->willReturn($channel);
     $channel->hasShippingMethod($firstShippingMethod)->willReturn(false);
     $channel->hasShippingMethod($secondShippingMethod)->willReturn(false);
     $channel->hasShippingMethod($thirdShippingMethod)->willReturn(false);
     $this->shouldThrow(UnresolvedDefaultShippingMethodException::class)->during('getDefaultShippingMethod', [$shipment]);
 }
 function it_does_nothing_if_tax_rate_cannot_be_resolved(CalculatorInterface $calculator, TaxRateResolverInterface $taxRateResolver, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $shippingMethod, ZoneInterface $zone)
 {
     $order->getShippingTotal()->willReturn(100);
     $order->getShipments()->willReturn(new ArrayCollection([$shipment->getWrappedObject()]));
     $shipment->getMethod()->willReturn($shippingMethod);
     $taxRateResolver->resolve($shippingMethod, ['zone' => $zone])->willReturn(null);
     $calculator->calculate(Argument::any())->shouldNotBeCalled();
     $order->addAdjustment(Argument::any())->shouldNotBeCalled();
     $this->apply($order, $zone);
 }
 function it_does_not_mark_an_order_if_it_is_already_in_this_shipping_state(FactoryInterface $stateMachineFactory, OrderInterface $order, ShipmentInterface $shipment1, ShipmentInterface $shipment2, StateMachineInterface $orderStateMachine)
 {
     $shipments = new ArrayCollection();
     $shipments->add($shipment1->getWrappedObject());
     $shipments->add($shipment2->getWrappedObject());
     $order->getShipments()->willReturn($shipments);
     $order->getShippingState()->willReturn(OrderShippingStates::STATE_SHIPPED);
     $stateMachineFactory->get($order, OrderShippingTransitions::GRAPH)->willReturn($orderStateMachine);
     $shipment1->getState()->willReturn(ShipmentInterface::STATE_SHIPPED);
     $shipment2->getState()->willReturn(ShipmentInterface::STATE_SHIPPED);
     $orderStateMachine->apply(OrderShippingTransitions::TRANSITION_SHIP)->shouldNotBeCalled();
     $this->resolve($order);
 }
 function it_does_not_support_shipments_which_has_no_order_defined(ShipmentInterface $shipment)
 {
     $shipment->getOrder()->willReturn(null);
     $this->supports($shipment)->shouldReturn(false);
 }
Beispiel #11
0
 function it_adds_and_removes_shipments(ShipmentInterface $shipment)
 {
     $shipment->setOrder($this)->shouldBeCalled();
     $this->addShipment($shipment);
     $this->shouldHaveShipment($shipment);
     $shipment->setOrder(null)->shouldBeCalled();
     $this->removeShipment($shipment);
     $this->shouldNotHaveShipment($shipment);
 }
Beispiel #12
0
 /**
  * @param ShipmentInterface $shipment
  */
 public function sendConfirmationEmail(ShipmentInterface $shipment)
 {
     /** @var \Sylius\Component\Core\Model\OrderInterface $order */
     $order = $shipment->getOrder();
     $this->emailSender->send(Emails::SHIPMENT_CONFIRMATION, [$order->getCustomer()->getEmail()], ['shipment' => $shipment, 'order' => $order]);
 }