php-src/ext/intl/tests/formatter_format_currency.phpt
2008-09-08 20:49:10 +00:00

49 lines
991 B
PHP
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--TEST--
numfmt_format_currency()
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
<?php
/*
* Format a number using misc currencies/locales.
*/
/*
* TODO: doesn't pass on ICU 3.6 because 'ru' and 'uk' locales changed
* currency formatting.
*/
function ut_main()
{
$locales = array(
'en_UK' => 'GBP',
'en_US' => 'USD',
'ru' => 'RUR',
'uk' => 'UAH',
'en' => 'UAH'
);
$res_str = '';
$number = 1234567.89;
foreach( $locales as $locale => $currency )
{
$fmt = ut_nfmt_create( $locale, NumberFormatter::CURRENCY );
$res_str .= "$locale: " . var_export( ut_nfmt_format_currency( $fmt, $number, $currency ), true ) . "\n";
}
return $res_str;
}
include_once( 'ut_common.inc' );
// Run the test
ut_run();
?>
--EXPECTREGEX--
en_UK: '£1,234,567.89'
en_US: '\$1,234,567.89'
ru: '1 234 567,89 ?р.'
uk: '(грн. )?1 234 567,89( грн.)?'
en: 'UAH1,234,567.89'