/** * @depends testAttemptToOverrideISOCurrency */ public function testAttemptToRemoveISOCurrency() { $euro = ISOCurrencyProvider::getInstance()->getCurrency('EUR'); DefaultCurrencyProvider::getInstance()->removeCurrency($euro); $isoCurrencies = ISOCurrencyProvider::getInstance()->getAvailableCurrencies(); $this->assertCurrencyProviderContains($isoCurrencies, DefaultCurrencyProvider::getInstance()); }
/** * 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); }
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); }