/** * {@inheritdoc} */ public function update(OrderInterface $order) { /** @var CurrencyInterface $currency */ $currency = $this->currencyRepository->findOneBy(['code' => $this->currencyContext->getCurrencyCode()]); $order->setCurrencyCode($currency->getCode()); $order->setExchangeRate($currency->getExchangeRate()); }
function it_updates_order_exchange_rate(OrderInterface $order, CurrencyContextInterface $currencyContext, RepositoryInterface $currencyRepository, CurrencyInterface $currency, ChannelInterface $channel) { $order->getChannel()->willReturn($channel); $currencyContext->getCurrencyCode()->willReturn('GBP'); $currencyRepository->findOneBy(['code' => 'GBP'])->willReturn($currency); $currency->getExchangeRate()->willReturn(3.5); $currency->getCode()->willReturn('GBP'); $order->setCurrencyCode('GBP')->shouldBeCalled(); $order->setExchangeRate(3.5)->shouldBeCalled(); $this->update($order); }