function it_allows_to_convert_and_format_prices_in_different_currencies(CurrencyContextInterface $currencyContext, CurrencyConverterInterface $converter, MoneyFormatterInterface $moneyFormatter) { $currencyContext->getCurrencyCode()->willReturn('PLN'); $converter->convertFromBase(15, 'USD')->willReturn(19); $converter->convertFromBase(2500, 'USD')->willReturn(1913); $converter->convertFromBase(312, 'PLN')->willReturn(407); $converter->convertFromBase(500, 'PLN')->willReturn(653); $moneyFormatter->format(19, 'USD')->willReturn('$0.19'); $moneyFormatter->format(1913, 'USD')->willReturn('$19.13'); $moneyFormatter->format(407, 'PLN')->willReturn('4.07 zł'); $moneyFormatter->format(653, 'PLN')->willReturn('6.53 zł'); $this->convertAndFormatAmount(15, 'USD')->shouldReturn('$0.19'); $this->convertAndFormatAmount(2500, 'USD')->shouldReturn('$19.13'); $this->convertAndFormatAmount(312, 'PLN')->shouldReturn('4.07 zł'); $this->convertAndFormatAmount(500)->shouldReturn('6.53 zł'); }
/** * {@inheritdoc} */ public function formatAmount($amount, $currencyCode, $localeCode) { return $this->moneyFormatter->format($amount, $currencyCode, $localeCode); }
function it_formats_money_using_given_currency_and_locale(MoneyFormatterInterface $moneyFormatter) { $moneyFormatter->format(2500, 'EUR', 'fr_FR')->willReturn('€25.00'); $this->formatAmount(2500, 'EUR', 'fr_FR')->shouldReturn('€25.00'); }
/** * {@inheritdoc} */ public function formatAmount($amount, $currencyCode = null, $locale = null) { $locale = $locale ?: $this->defaultLocale; $currencyCode = $currencyCode ?: $this->defaultCurrencyCode; return $this->moneyFormatter->format($amount, $currencyCode, $locale); }
/** * {@inheritdoc} */ public function formatAmount($amount, $currencyCode = null, $locale = null) { $locale = $locale ?: $this->localeContext->getDefaultLocale(); $currencyCode = $currencyCode ?: $this->currencyContext->getCurrencyCode(); return $this->moneyFormatter->format($amount, $currencyCode, $locale); }
/** * {@inheritdoc} */ public function convertAndFormatAmount($amount, $currencyCode = null) { $currencyCode = $currencyCode ?: $this->currencyContext->getCurrencyCode(); $amount = $this->currencyConverter->convertFromBase($amount, $currencyCode); return $this->moneyFormatter->format($amount, $currencyCode); }