/** * @param OrderInterface $order * * @return OrderInterface */ public function recalculate(OrderInterface $order) { $this->pricesRecalculator->recalculate($order); $this->shippingChargesProcessor->applyShippingCharges($order); $this->promotionProcessor->process($order); $this->taxesApplicator->apply($order); }
/** * @param GenericEvent $event * * @throws UnexpectedTypeException */ public function applyTaxes(GenericEvent $event) { $order = $event->getSubject(); if (!$order instanceof OrderInterface) { throw new UnexpectedTypeException($order, OrderInterface::class); } $this->orderTaxesApplicator->apply($order); }
function it_recalculates_order_promotions_taxes_and_shipping_charges(PromotionProcessorInterface $promotionProcessor, OrderTaxesApplicatorInterface $taxesApplicator, ShippingChargesProcessorInterface $shippingChargesProcessor, OrderInterface $order) { $promotionProcessor->process($order)->shouldBeCalled(); $taxesApplicator->apply($order)->shouldBeCalled(); $shippingChargesProcessor->applyShippingCharges($order)->shouldBeCalled(); $this->recalculate($order); }
function it_calls_taxation_processor_on_order(OrderTaxesApplicatorInterface $orderTaxesApplicator, GenericEvent $event, OrderInterface $order) { $event->getSubject()->willReturn($order); $orderTaxesApplicator->apply($order)->shouldBeCalled(); $this->applyTaxes($event); }