4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Intl\Tests\NumberFormatter
;
14 use Symfony\Component\Intl\Globals\IntlGlobals
;
15 use Symfony\Component\Intl\Intl
;
16 use Symfony\Component\Intl\Locale
;
17 use Symfony\Component\Intl\NumberFormatter\NumberFormatter
;
18 use Symfony\Component\Intl\Util\IntlTestHelper
;
21 * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known
24 abstract class AbstractNumberFormatterTest
extends \PHPUnit_Framework_TestCase
27 * @dataProvider formatCurrencyWithDecimalStyleProvider
29 public function testFormatCurrencyWithDecimalStyle($value, $currency, $expected)
31 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
32 $this->assertEquals($expected, $formatter->formatCurrency($value, $currency));
35 public function formatCurrencyWithDecimalStyleProvider()
38 array(100, 'ALL', '100'),
39 array(100, 'BRL', '100.00'),
40 array(100, 'CRC', '100'),
41 array(100, 'JPY', '100'),
42 array(100, 'CHF', '100'),
43 array(-100, 'ALL', '-100'),
44 array(-100, 'BRL', '-100'),
45 array(-100, 'CRC', '-100'),
46 array(-100, 'JPY', '-100'),
47 array(-100, 'CHF', '-100'),
48 array(1000.12, 'ALL', '1,000.12'),
49 array(1000.12, 'BRL', '1,000.12'),
50 array(1000.12, 'CRC', '1,000.12'),
51 array(1000.12, 'JPY', '1,000.12'),
52 array(1000.12, 'CHF', '1,000.12')
57 * @dataProvider formatCurrencyWithCurrencyStyleProvider
59 public function testFormatCurrencyWithCurrencyStyle($value, $currency, $expected)
61 $formatter = $this->getNumberFormatter('en', NumberFormatter
::CURRENCY
);
62 $this->assertEquals($expected, $formatter->formatCurrency($value, $currency));
65 public function formatCurrencyWithCurrencyStyleProvider()
68 array(100, 'ALL', 'ALL100'),
69 array(-100, 'ALL', '(ALL100)'),
70 array(1000.12, 'ALL', 'ALL1,000'),
72 array(100, 'JPY', '¥100'),
73 array(-100, 'JPY', '(¥100)'),
74 array(1000.12, 'JPY', '¥1,000'),
76 array(100, 'EUR', '€100.00'),
77 array(-100, 'EUR', '(€100.00)'),
78 array(1000.12, 'EUR', '€1,000.12'),
83 * @dataProvider formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider
85 public function testFormatCurrencyWithCurrencyStyleCostaRicanColonsRounding($value, $currency, $symbol, $expected)
87 $formatter = $this->getNumberFormatter('en', NumberFormatter
::CURRENCY
);
88 $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
91 public function formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider()
94 array(100, 'CRC', 'CRC', '%s100'),
95 array(-100, 'CRC', 'CRC', '(%s100)'),
96 array(1000.12, 'CRC', 'CRC', '%s1,000'),
101 * @dataProvider formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider
103 public function testFormatCurrencyWithCurrencyStyleBrazilianRealRounding($value, $currency, $symbol, $expected)
105 $formatter = $this->getNumberFormatter('en', NumberFormatter
::CURRENCY
);
106 $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
109 public function formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider()
112 array(100, 'BRL', 'R', '%s$100.00'),
113 array(-100, 'BRL', 'R', '(%s$100.00)'),
114 array(1000.12, 'BRL', 'R', '%s$1,000.12'),
117 array(1000.121, 'BRL', 'R', '%s$1,000.12'),
118 array(1000.123, 'BRL', 'R', '%s$1,000.12'),
119 array(1000.125, 'BRL', 'R', '%s$1,000.12'),
120 array(1000.127, 'BRL', 'R', '%s$1,000.13'),
121 array(1000.129, 'BRL', 'R', '%s$1,000.13'),
122 array(11.50999, 'BRL', 'R', '%s$11.51'),
123 array(11.9999464, 'BRL', 'R', '%s$12.00')
128 * @dataProvider formatCurrencyWithCurrencyStyleSwissRoundingProvider
130 public function testFormatCurrencyWithCurrencyStyleSwissRounding($value, $currency, $symbol, $expected)
132 $formatter = $this->getNumberFormatter('en', NumberFormatter
::CURRENCY
);
133 $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
136 public function formatCurrencyWithCurrencyStyleSwissRoundingProvider()
139 array(100, 'CHF', 'CHF', '%s100.00'),
140 array(-100, 'CHF', 'CHF', '(%s100.00)'),
141 array(1000.12, 'CHF', 'CHF', '%s1,000.10'),
142 array('1000.12', 'CHF', 'CHF', '%s1,000.10'),
145 array(1000.121, 'CHF', 'CHF', '%s1,000.10'),
146 array(1000.123, 'CHF', 'CHF', '%s1,000.10'),
147 array(1000.125, 'CHF', 'CHF', '%s1,000.10'),
148 array(1000.127, 'CHF', 'CHF', '%s1,000.15'),
149 array(1000.129, 'CHF', 'CHF', '%s1,000.15'),
151 array(1200000.00, 'CHF', 'CHF', '%s1,200,000.00'),
152 array(1200000.1, 'CHF', 'CHF', '%s1,200,000.10'),
153 array(1200000.10, 'CHF', 'CHF', '%s1,200,000.10'),
154 array(1200000.101, 'CHF', 'CHF', '%s1,200,000.10')
158 public function testFormat()
160 $errorCode = IntlGlobals
::U_ZERO_ERROR
;
161 $errorMessage = 'U_ZERO_ERROR';
163 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
164 $this->assertSame('9.555', $formatter->format(9.555));
166 $this->assertSame($errorMessage, $this->getIntlErrorMessage());
167 $this->assertSame($errorCode, $this->getIntlErrorCode());
168 $this->assertFalse($this->isIntlFailure($this->getIntlErrorCode()));
169 $this->assertSame($errorMessage, $formatter->getErrorMessage());
170 $this->assertSame($errorCode, $formatter->getErrorCode());
171 $this->assertFalse($this->isIntlFailure($formatter->getErrorCode()));
174 public function testFormatWithCurrencyStyle()
176 $formatter = $this->getNumberFormatter('en', NumberFormatter
::CURRENCY
);
177 $this->assertEquals('¤1.00', $formatter->format(1));
181 * @dataProvider formatTypeInt32Provider
183 public function testFormatTypeInt32($formatter, $value, $expected, $message = '')
185 $formattedValue = $formatter->format($value, NumberFormatter
::TYPE_INT32
);
186 $this->assertEquals($expected, $formattedValue, $message);
189 public function formatTypeInt32Provider()
191 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
193 $message = '->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.';
196 array($formatter, 1, '1'),
197 array($formatter, 1.1, '1'),
198 array($formatter, 2147483648, '-2,147,483,648', $message),
199 array($formatter, -2147483649, '2,147,483,647', $message),
204 * @dataProvider formatTypeInt32WithCurrencyStyleProvider
206 public function testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message = '')
208 $formattedValue = $formatter->format($value, NumberFormatter
::TYPE_INT32
);
209 $this->assertEquals($expected, $formattedValue, $message);
212 public function formatTypeInt32WithCurrencyStyleProvider()
214 $formatter = $this->getNumberFormatter('en', NumberFormatter
::CURRENCY
);
216 $message = '->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.';
219 array($formatter, 1, '¤1.00'),
220 array($formatter, 1.1, '¤1.00'),
221 array($formatter, 2147483648, '(¤2,147,483,648.00)', $message),
222 array($formatter, -2147483649, '¤2,147,483,647.00', $message)
227 * The parse() method works differently with integer out of the 32 bit range. format() works fine.
228 * @dataProvider formatTypeInt64Provider
230 public function testFormatTypeInt64($formatter, $value, $expected)
232 $formattedValue = $formatter->format($value, NumberFormatter
::TYPE_INT64
);
233 $this->assertEquals($expected, $formattedValue);
236 public function formatTypeInt64Provider()
238 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
241 array($formatter, 1, '1'),
242 array($formatter, 1.1, '1'),
243 array($formatter, 2147483648, '2,147,483,648'),
244 array($formatter, -2147483649, '-2,147,483,649'),
249 * @dataProvider formatTypeInt64WithCurrencyStyleProvider
251 public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected)
253 $formattedValue = $formatter->format($value, NumberFormatter
::TYPE_INT64
);
254 $this->assertEquals($expected, $formattedValue);
257 public function formatTypeInt64WithCurrencyStyleProvider()
259 $formatter = $this->getNumberFormatter('en', NumberFormatter
::CURRENCY
);
262 array($formatter, 1, '¤1.00'),
263 array($formatter, 1.1, '¤1.00'),
264 array($formatter, 2147483648, '¤2,147,483,648.00'),
265 array($formatter, -2147483649, '(¤2,147,483,649.00)')
270 * @dataProvider formatTypeDoubleProvider
272 public function testFormatTypeDouble($formatter, $value, $expected)
274 $formattedValue = $formatter->format($value, NumberFormatter
::TYPE_DOUBLE
);
275 $this->assertEquals($expected, $formattedValue);
278 public function formatTypeDoubleProvider()
280 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
283 array($formatter, 1, '1'),
284 array($formatter, 1.1, '1.1'),
289 * @dataProvider formatTypeDoubleWithCurrencyStyleProvider
291 public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected)
293 $formattedValue = $formatter->format($value, NumberFormatter
::TYPE_DOUBLE
);
294 $this->assertEquals($expected, $formattedValue);
297 public function formatTypeDoubleWithCurrencyStyleProvider()
299 $formatter = $this->getNumberFormatter('en', NumberFormatter
::CURRENCY
);
302 array($formatter, 1, '¤1.00'),
303 array($formatter, 1.1, '¤1.10'),
308 * @dataProvider formatTypeCurrencyProvider
309 * @expectedException \PHPUnit_Framework_Error_Warning
311 public function testFormatTypeCurrency($formatter, $value)
313 $formatter->format($value, NumberFormatter
::TYPE_CURRENCY
);
317 * @dataProvider formatTypeCurrencyProvider
319 public function testFormatTypeCurrencyReturn($formatter, $value)
321 $this->assertFalse(@$formatter->format($value, NumberFormatter
::TYPE_CURRENCY
));
324 public function formatTypeCurrencyProvider()
326 $df = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
327 $cf = $this->getNumberFormatter('en', NumberFormatter
::CURRENCY
);
336 * @dataProvider formatFractionDigitsProvider
338 public function testFormatFractionDigits($value, $expected, $fractionDigits = null, $expectedFractionDigits = 1)
340 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
342 if (null !== $fractionDigits) {
343 $attributeRet = $formatter->setAttribute(NumberFormatter
::FRACTION_DIGITS
, $fractionDigits);
346 $formattedValue = $formatter->format($value);
347 $this->assertSame($expected, $formattedValue);
348 $this->assertSame($expectedFractionDigits, $formatter->getAttribute(NumberFormatter
::FRACTION_DIGITS
));
350 if (isset($attributeRet)) {
351 $this->assertTrue($attributeRet);
355 public function formatFractionDigitsProvider()
358 array(1.123, '1.123', null, 0),
359 array(1.123, '1', 0, 0),
360 array(1.123, '1.1', 1, 1),
361 array(1.123, '1.12', 2, 2),
362 array(1.123, '1', -1, 0),
363 array(1.123, '1', 'abc', 0)
368 * @dataProvider formatGroupingUsedProvider
370 public function testFormatGroupingUsed($value, $expected, $groupingUsed = null, $expectedGroupingUsed = 1)
372 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
374 if (null !== $groupingUsed) {
375 $attributeRet = $formatter->setAttribute(NumberFormatter
::GROUPING_USED
, $groupingUsed);
378 $formattedValue = $formatter->format($value);
379 $this->assertSame($expected, $formattedValue);
380 $this->assertSame($expectedGroupingUsed, $formatter->getAttribute(NumberFormatter
::GROUPING_USED
));
382 if (isset($attributeRet)) {
383 $this->assertTrue($attributeRet);
387 public function formatGroupingUsedProvider()
390 array(1000, '1,000', null, 1),
391 array(1000, '1000', 0, 0),
392 array(1000, '1,000', 1, 1),
393 array(1000, '1,000', 2, 1),
394 array(1000, '1000', 'abc', 0),
395 array(1000, '1,000', -1, 1),
400 * @dataProvider formatRoundingModeRoundHalfUpProvider
402 public function testFormatRoundingModeHalfUp($value, $expected)
404 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
405 $formatter->setAttribute(NumberFormatter
::FRACTION_DIGITS
, 2);
407 $formatter->setAttribute(NumberFormatter
::ROUNDING_MODE
, NumberFormatter
::ROUND_HALFUP
);
408 $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFUP rounding mode.');
411 public function formatRoundingModeRoundHalfUpProvider()
413 // The commented value is differently rounded by intl's NumberFormatter in 32 and 64 bit architectures
415 array(1.121, '1.12'),
416 array(1.123, '1.12'),
417 // array(1.125, '1.13'),
418 array(1.127, '1.13'),
419 array(1.129, '1.13'),
424 * @dataProvider formatRoundingModeRoundHalfDownProvider
426 public function testFormatRoundingModeHalfDown($value, $expected)
428 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
429 $formatter->setAttribute(NumberFormatter
::FRACTION_DIGITS
, 2);
431 $formatter->setAttribute(NumberFormatter
::ROUNDING_MODE
, NumberFormatter
::ROUND_HALFDOWN
);
432 $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFDOWN rounding mode.');
435 public function formatRoundingModeRoundHalfDownProvider()
438 array(1.121, '1.12'),
439 array(1.123, '1.12'),
440 array(1.125, '1.12'),
441 array(1.127, '1.13'),
442 array(1.129, '1.13'),
447 * @dataProvider formatRoundingModeRoundHalfEvenProvider
449 public function testFormatRoundingModeHalfEven($value, $expected)
451 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
452 $formatter->setAttribute(NumberFormatter
::FRACTION_DIGITS
, 2);
454 $formatter->setAttribute(NumberFormatter
::ROUNDING_MODE
, NumberFormatter
::ROUND_HALFEVEN
);
455 $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFEVEN rounding mode.');
458 public function formatRoundingModeRoundHalfEvenProvider()
461 array(1.121, '1.12'),
462 array(1.123, '1.12'),
463 array(1.125, '1.12'),
464 array(1.127, '1.13'),
465 array(1.129, '1.13'),
469 public function testGetLocale()
471 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
472 $this->assertEquals('en', $formatter->getLocale());
476 * @dataProvider parseProvider
478 public function testParse($value, $expected, $message = '')
480 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
481 $parsedValue = $formatter->parse($value, NumberFormatter
::TYPE_DOUBLE
);
482 $this->assertSame($expected, $parsedValue, $message);
484 if ($expected === false) {
485 $errorCode = IntlGlobals
::U_PARSE_ERROR
;
486 $errorMessage = 'Number parsing failed: U_PARSE_ERROR';
488 $errorCode = IntlGlobals
::U_ZERO_ERROR
;
489 $errorMessage = 'U_ZERO_ERROR';
492 $this->assertSame($errorMessage, $this->getIntlErrorMessage());
493 $this->assertSame($errorCode, $this->getIntlErrorCode());
494 $this->assertSame($errorCode !== 0, $this->isIntlFailure($this->getIntlErrorCode()));
495 $this->assertSame($errorMessage, $formatter->getErrorMessage());
496 $this->assertSame($errorCode, $formatter->getErrorCode());
497 $this->assertSame($errorCode !== 0, $this->isIntlFailure($formatter->getErrorCode()));
500 public function parseProvider()
503 array('prefix1', false, '->parse() does not parse a number with a string prefix.'),
504 array('1suffix', (float) 1, '->parse() parses a number with a string suffix.'),
509 * @expectedException \PHPUnit_Framework_Error_Warning
511 public function testParseTypeDefault()
513 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
514 $formatter->parse('1', NumberFormatter
::TYPE_DEFAULT
);
518 * @dataProvider parseTypeInt32Provider
520 public function testParseTypeInt32($value, $expected, $message = '')
522 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
523 $parsedValue = $formatter->parse($value, NumberFormatter
::TYPE_INT32
);
524 $this->assertSame($expected, $parsedValue);
527 public function parseTypeInt32Provider()
532 array('2,147,483,647', 2147483647),
533 array('-2,147,483,648', -2147483647 - 1),
534 array('2,147,483,648', false, '->parse() TYPE_INT32 returns false when the number is greater than the integer positive range.'),
535 array('-2,147,483,649', false, '->parse() TYPE_INT32 returns false when the number is greater than the integer negative range.')
539 public function testParseTypeInt64With32BitIntegerInPhp32Bit()
541 IntlTestHelper
::require32Bit($this);
543 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
545 $parsedValue = $formatter->parse('2,147,483,647', NumberFormatter
::TYPE_INT64
);
546 $this->assertInternalType('integer', $parsedValue);
547 $this->assertEquals(2147483647, $parsedValue);
549 $parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter
::TYPE_INT64
);
551 // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
552 // The negative PHP_INT_MAX was being converted to float
554 (version_compare(PHP_VERSION
, '5.4.0', '<') && version_compare(PHP_VERSION
, '5.3.14', '>=')) ||
555 version_compare(PHP_VERSION
, '5.4.4', '>=')
557 $this->assertInternalType('int', $parsedValue);
559 $this->assertInternalType('float', $parsedValue);
562 $this->assertEquals(-2147483648, $parsedValue);
565 public function testParseTypeInt64With32BitIntegerInPhp64Bit()
567 IntlTestHelper
::require64Bit($this);
569 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
571 $parsedValue = $formatter->parse('2,147,483,647', NumberFormatter
::TYPE_INT64
);
572 $this->assertInternalType('integer', $parsedValue);
573 $this->assertEquals(2147483647, $parsedValue);
575 $parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter
::TYPE_INT64
);
576 $this->assertInternalType('integer', $parsedValue);
577 $this->assertEquals(-2147483647 - 1, $parsedValue);
581 * If PHP is compiled in 32bit mode, the returned value for a 64bit integer are float numbers.
583 public function testParseTypeInt64With64BitIntegerInPhp32Bit()
585 IntlTestHelper
::require32Bit($this);
587 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
589 // int 64 using only 32 bit range strangeness
590 $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter
::TYPE_INT64
);
591 $this->assertInternalType('float', $parsedValue);
592 $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range.');
594 $parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter
::TYPE_INT64
);
595 $this->assertInternalType('float', $parsedValue);
596 $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range.');
600 * If PHP is compiled in 64bit mode, the returned value for a 64bit integer are 32bit integer numbers.
602 public function testParseTypeInt64With64BitIntegerInPhp64Bit()
604 IntlTestHelper
::require64Bit($this);
606 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
608 $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter
::TYPE_INT64
);
609 $this->assertInternalType('integer', $parsedValue);
611 // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
612 // A 32 bit integer was being generated instead of a 64 bit integer
614 (version_compare(PHP_VERSION
, '5.3.14', '<')) ||
615 (version_compare(PHP_VERSION
, '5.4.0', '>=') && version_compare(PHP_VERSION
, '5.4.4', '<'))
617 $this->assertEquals(-2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).');
619 $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).');
622 $parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter
::TYPE_INT64
);
623 $this->assertInternalType('integer', $parsedValue);
625 // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
626 // A 32 bit integer was being generated instead of a 64 bit integer
628 (version_compare(PHP_VERSION
, '5.3.14', '<')) ||
629 (version_compare(PHP_VERSION
, '5.4.0', '>=') && version_compare(PHP_VERSION
, '5.4.4', '<'))
631 $this->assertEquals(2147483647, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).');
633 $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).');
638 * @dataProvider parseTypeDoubleProvider
640 public function testParseTypeDouble($value, $expectedValue)
642 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
643 $parsedValue = $formatter->parse($value, NumberFormatter
::TYPE_DOUBLE
);
644 $this->assertSame($expectedValue, $parsedValue);
647 public function parseTypeDoubleProvider()
650 array('1', (float) 1),
652 array('9,223,372,036,854,775,808', 9223372036854775808),
653 array('-9,223,372,036,854,775,809', -9223372036854775809),
658 * @expectedException \PHPUnit_Framework_Error_Warning
660 public function testParseTypeCurrency()
662 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
663 $formatter->parse('1', NumberFormatter
::TYPE_CURRENCY
);
666 public function testParseWithNullPositionValue()
669 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
670 $formatter->parse('123', NumberFormatter
::TYPE_INT32
, $position);
671 $this->assertNull($position);
674 public function testParseWithNotNullPositionValue()
677 $formatter = $this->getNumberFormatter('en', NumberFormatter
::DECIMAL
);
678 $formatter->parse('123', NumberFormatter
::TYPE_DOUBLE
, $position);
679 $this->assertEquals(3, $position);
683 * @param string $locale
685 * @param null $pattern
687 * @return \NumberFormatter
689 abstract protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null);
694 abstract protected function getIntlErrorMessage();
699 abstract protected function getIntlErrorCode();
702 * @param integer $errorCode
706 abstract protected function isIntlFailure($errorCode);