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_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); }