コード例 #1
0
ファイル: CurrencyTest.php プロジェクト: msooon/hubzilla
 /**
  * @covers ::getName
  * @covers ::setName
  */
 public function testName()
 {
     $this->currency->setName('US Dollar');
     $this->assertEquals('US Dollar', $this->currency->getName());
 }
コード例 #2
0
 /**
  * Helper for initiating a new Currency object.
  */
 protected function createCurrency(array $definition, $locale = 'en')
 {
     $default = ['fraction_digits' => 2];
     $format = array_merge($default, $definition);
     $currency = new Currency();
     $currency->setCurrencyCode($format['code']);
     $currency->setName($format['name']);
     $currency->setNumericCode($format['numeric_code']);
     $currency->setFractionDigits($format['fraction_digits']);
     $currency->setSymbol($format['symbol']);
     $currency->setLocale($locale);
     return $currency;
 }
コード例 #3
0
 /**
  * Creates a currency object from the provided definition.
  *
  * @param array  $definition The currency definition.
  * @param string $locale     The locale of the currency definition.
  *
  * @return Currency
  */
 protected function createCurrencyFromDefinition(array $definition, $locale)
 {
     if (!isset($definition['fraction_digits'])) {
         $definition['fraction_digits'] = 2;
     }
     $currency = new Currency();
     $currency->setCurrencyCode($definition['code']);
     $currency->setName($definition['name']);
     $currency->setNumericCode($definition['numeric_code']);
     $currency->setFractionDigits($definition['fraction_digits']);
     $currency->setSymbol($definition['symbol']);
     $currency->setLocale($locale);
     return $currency;
 }