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]); }
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); }
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_not_support_shipments_which_has_no_order_defined(ShipmentInterface $shipment) { $shipment->getOrder()->willReturn(null); $this->supports($shipment)->shouldReturn(false); }
/** * @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]); }