/**
  * @depends testAttemptToOverrideISOCurrency
  */
 public function testAttemptToRemoveISOCurrency()
 {
     $euro = ISOCurrencyProvider::getInstance()->getCurrency('EUR');
     DefaultCurrencyProvider::getInstance()->removeCurrency($euro);
     $isoCurrencies = ISOCurrencyProvider::getInstance()->getAvailableCurrencies();
     $this->assertCurrencyProviderContains($isoCurrencies, DefaultCurrencyProvider::getInstance());
 }
Beispiel #2
0
 /**
  * Returns a Currency instance of the given parameter.
  *
  * This method resolves currency codes using the DefaultCurrencyProvider.
  * By default, only ISO currencies are available; additional currencies can be registered
  * with the DefaultCurrencyProvider and will be made available here.
  *
  * @param Currency|string $currency
  *
  * @return Currency
  *
  * @throws UnknownCurrencyException If an unknown currency code is given.
  */
 public static function of($currency)
 {
     if ($currency instanceof Currency) {
         return $currency;
     }
     return DefaultCurrencyProvider::getInstance()->getCurrency($currency);
 }
Beispiel #3
0
 public function testParseWithCustomCurrency()
 {
     $bitCoin = Currency::create('BTC', 0, 'BitCoin', 8);
     DefaultCurrencyProvider::getInstance()->addCurrency($bitCoin);
     try {
         $money = Money::parse('BTC 1.23456789');
     } finally {
         DefaultCurrencyProvider::getInstance()->removeCurrency($bitCoin);
     }
     $this->assertMoneyEquals('1.23456789', 'BTC', $money);
 }