Commit 76ade0f6 by Serge Bezborodov Committed by Carsten Brandt

Changed order of attributes setting in Formatter

close #5261
parent 0818c9bb
......@@ -1097,18 +1097,18 @@ class Formatter extends Component
$formatter->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, $decimals);
}
foreach ($this->numberFormatterOptions as $name => $value) {
$formatter->setAttribute($name, $value);
}
foreach ($options as $name => $value) {
$formatter->setAttribute($name, $value);
}
foreach ($this->numberFormatterTextOptions as $name => $attribute) {
$formatter->setTextAttribute($name, $attribute);
}
foreach ($textOptions as $name => $attribute) {
$formatter->setTextAttribute($name, $attribute);
}
foreach ($this->numberFormatterOptions as $name => $value) {
$formatter->setAttribute($name, $value);
}
foreach ($options as $name => $value) {
$formatter->setAttribute($name, $value);
}
return $formatter;
}
}
......@@ -756,6 +756,21 @@ class FormatterTest extends TestCase
$this->assertSame($this->formatter->nullDisplay, $this->formatter->asCurrency(null));
}
/**
* https://github.com/yiisoft/yii2/pull/5261
*/
public function testIntlIssue5261()
{
$this->formatter->locale = 'en-US';
$this->formatter->numberFormatterOptions = [
\NumberFormatter::FRACTION_DIGITS => 0
];
$this->formatter->numberFormatterTextOptions = [
\NumberFormatter::CURRENCY_CODE => 'EUR'
];
$this->assertSame('€100', $this->formatter->asCurrency(100, 'EUR'));
}
public function testAsCurrency()
{
$this->formatter->currencyCode = 'USD';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment