Browse Source

added test for #12345

tags/2.0.11
Carsten Brandt 8 years ago
parent
commit
a51dadc866
No known key found for this signature in database
GPG Key ID: BE4F41DE1DEEEED0
  1. 39
      tests/framework/i18n/FormatterNumberTest.php

39
tests/framework/i18n/FormatterNumberTest.php

@ -310,6 +310,45 @@ class FormatterNumberTest extends TestCase
}
/**
* https://github.com/yiisoft/yii2/issues/12345
*/
public function testIntlCurrencyFraction()
{
$this->formatter->numberFormatterOptions = [
NumberFormatter::MIN_FRACTION_DIGITS => 0,
NumberFormatter::MAX_FRACTION_DIGITS => 0,
];
$this->formatter->locale = 'de-DE';
$this->formatter->currencyCode = null;
$this->assertSame('123 €', $this->formatter->asCurrency('123'));
$this->assertSame('123 €', $this->formatter->asCurrency('123', 'EUR'));
$this->formatter->currencyCode = 'USD';
$this->assertSame('123 $', $this->formatter->asCurrency('123'));
$this->assertSame('123 $', $this->formatter->asCurrency('123', 'USD'));
$this->assertSame('123 €', $this->formatter->asCurrency('123', 'EUR'));
$this->formatter->currencyCode = 'EUR';
$this->assertSame('123 €', $this->formatter->asCurrency('123'));
$this->assertSame('123 $', $this->formatter->asCurrency('123', 'USD'));
$this->assertSame('123 €', $this->formatter->asCurrency('123', 'EUR'));
$this->formatter->locale = 'ru-RU';
$this->formatter->currencyCode = null;
if (version_compare(INTL_ICU_DATA_VERSION, '57.1', '>=')) {
$this->assertSame('123 ₽', $this->formatter->asCurrency('123'));
} else {
$this->assertSame('123 руб.', $this->formatter->asCurrency('123'));
}
$this->formatter->numberFormatterSymbols = [
NumberFormatter::CURRENCY_SYMBOL => '₽',
];
$this->assertSame('123 ₽', $this->formatter->asCurrency('123'));
$this->formatter->numberFormatterSymbols = [];
$this->formatter->currencyCode = 'RUB';
$this->assertSame('123 руб.', $this->formatter->asCurrency('123'));
}
/**
* https://github.com/yiisoft/yii2/pull/5261
*/
public function testIntlIssue5261()

Loading…
Cancel
Save