/** * {@inheritdoc} */ public function getCurrencyCode() { $availableCurrenciesCodes = $this->currencyProvider->getAvailableCurrenciesCodes(); $currencyCode = $this->currencyStorage->get($this->channelContext->getChannel()); if (!in_array($currencyCode, $availableCurrenciesCodes, true)) { throw CurrencyNotFoundException::notAvailable($currencyCode, $availableCurrenciesCodes); } return $currencyCode; }
function it_throws_an_exception_if_currency_taken_from_storage_is_not_available(ChannelContextInterface $channelContext, CurrencyStorageInterface $currencyStorage, CurrencyProviderInterface $currencyProvider, ChannelInterface $channel) { $channelContext->getChannel()->willReturn($channel); $currencyStorage->get($channel)->willReturn('BTC'); $currencyProvider->getAvailableCurrenciesCodes()->willReturn(['LTC', 'PLN']); $this->shouldThrow(CurrencyNotFoundException::class)->during('getCurrencyCode'); }