function it_calls_taxation_processor_on_order(TaxationProcessorInterface $taxationProcessor, GenericEvent $event, OrderInterface $order) { $event->getSubject()->willReturn($order); $taxationProcessor->applyTaxes($order)->shouldBeCalled(); $order->calculateTotal()->shouldBeCalled(); $this->applyTaxes($event); }
/** * @param GenericEvent $event * * @throws UnexpectedTypeException */ public function applyTaxes(GenericEvent $event) { $order = $event->getSubject(); if (!$order instanceof OrderInterface) { throw new UnexpectedTypeException($order, OrderInterface::class); } $this->taxationProcessor->applyTaxes($order); }
/** * Get the order from event and run the taxation processor on it. * * @param GenericEvent $event * * @throws UnexpectedTypeException */ public function applyTaxes(GenericEvent $event) { $order = $event->getSubject(); if (!$order instanceof OrderInterface) { throw new UnexpectedTypeException($order, 'Sylius\\Component\\Core\\Model\\OrderInterface'); } $this->taxationProcessor->applyTaxes($order); $order->calculateTotal(); }