mirror of
https://github.com/php/php-src.git
synced 2026-04-05 07:02:33 +02:00
fix tests for ICU >= 52.1
This commit is contained in:
@@ -6,8 +6,8 @@ date.timezone=Atlantic/Azores
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
|
||||
die('skip for ICU 4.4+');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.4') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0)
|
||||
die('skip for ICU >= 4.4 and ICU < 52.1');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
@@ -31,4 +31,4 @@ int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
==DONE==
|
||||
==DONE==
|
||||
|
||||
34
ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt
Normal file
34
ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt
Normal file
@@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
IntlCalendar::getDayOfWeekType() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '52.1') < 0)
|
||||
die('skip for ICU >= 52.1');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->setTime(strtotime('2012-02-29 00:00:00 +0000') * 1000);
|
||||
var_dump(
|
||||
intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY),
|
||||
$intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY),
|
||||
$intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY),
|
||||
$intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY),
|
||||
$intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY)
|
||||
);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
==DONE==
|
||||
@@ -3,7 +3,7 @@ IntlDateFormatter: several forms of the calendar arg
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) die('skip for ICU >= 51.2 and < 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
53
ext/intl/tests/dateformat_create_cal_arg_variant3.phpt
Normal file
53
ext/intl/tests/dateformat_create_cal_arg_variant3.phpt
Normal file
@@ -0,0 +1,53 @@
|
||||
--TEST--
|
||||
IntlDateFormatter: several forms of the calendar arg
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "pt_PT");
|
||||
ini_set("date.timezone", 'Atlantic/Azores');
|
||||
|
||||
$ts = strtotime('2012-01-01 00:00:00 UTC');
|
||||
|
||||
$cal = new IntlGregorianCalendar('UTC', NULL);
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal);
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
$cal = IntlCalendar::createInstance('UTC', 'en@calendar=islamic');
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal);
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
//override calendar's timezone
|
||||
$cal = new IntlGregorianCalendar('UTC', NULL);
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Madrid', $cal);
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
//default calendar is gregorian
|
||||
$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0);
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
//try now with traditional
|
||||
$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, NULL, IntlDateFormatter::TRADITIONAL);
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
//the timezone can be overridden when not specifying a calendar
|
||||
$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, 'UTC', IntlDateFormatter::TRADITIONAL);
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, 'UTC', 0);
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECTF--
|
||||
domingo%S 1 de enero de 2012, 0:00:00 (GMT)
|
||||
domingo%S 8 de Safar de 1433, 0:00:00 (GMT)
|
||||
domingo%S 1 de enero de 2012, 1:00:00 (Hora estándar de Europa central)
|
||||
sábado%S 31 de diciembre de 2011 d. C., 23:00:00 (Hora estándar %Sde las Azores)
|
||||
sábado%S 7 de Safar de 1433 AH, 23:00:00 (Hora estándar %Sde las Azores)
|
||||
domingo%S 8 de Safar de 1433 AH, 0:00:00 (GMT)
|
||||
domingo%S 1 de enero de 2012, 0:00:00 (GMT)
|
||||
==DONE==
|
||||
@@ -3,7 +3,7 @@ IntlDateFormatter::formatObject(): IntlCalendar tests
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) die('skip for ICU >= 51.2 and < 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
--TEST--
|
||||
IntlDateFormatter::formatObject(): IntlCalendar tests
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "pt_PT");
|
||||
ini_set("date.timezone", "Europe/Lisbon");
|
||||
|
||||
$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00'); //Europe/Lisbon
|
||||
echo IntlDateFormatter::formatObject($cal), "\n";
|
||||
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
|
||||
echo IntlDateFormatter::formatObject($cal, null, "en-US"), "\n";
|
||||
echo IntlDateFormatter::formatObject($cal, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
|
||||
echo IntlDateFormatter::formatObject($cal, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
|
||||
|
||||
$cal = IntlCalendar::fromDateTime('2012-01-01 05:00:00+03:00');
|
||||
echo datefmt_format_object($cal, IntlDateFormatter::FULL), "\n";
|
||||
|
||||
$cal = IntlCalendar::createInstance(null,'en-US@calendar=islamic-civil');
|
||||
$cal->setTime(strtotime('2012-01-01 00:00:00')*1000.);
|
||||
echo IntlDateFormatter::formatObject($cal), "\n";
|
||||
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n";
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
|
||||
--EXPECTF--
|
||||
01/01/2012, 00:00:00
|
||||
domingo, 1 de Janeiro de 2012 às 00:00:00 Hora Padrão %Sda Europa Ocidental
|
||||
Jan 1, 2012, 12:00:00 AM
|
||||
1/1/12, 12:00:00 AM Western European Standard %STime
|
||||
Sun 2012-01-1 00,00,00.000 Portugal Time
|
||||
domingo, 1 de Janeiro de 2012 às 05:00:00 GMT+03:00
|
||||
06/02/1433, 00:00:00
|
||||
Sunday, Safar 6, 1433 at 12:00:00 AM Western European Standard Time
|
||||
==DONE==
|
||||
@@ -3,7 +3,7 @@ IntlDateFormatter::formatObject(): DateTime tests
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) die('skip for ICU >= 51.2 and < 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
IntlDateFormatter::formatObject(): DateTime tests
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "pt_PT");
|
||||
ini_set("date.timezone", "Europe/Lisbon");
|
||||
|
||||
$dt = new DateTime('2012-01-01 00:00:00'); //Europe/Lisbon
|
||||
echo IntlDateFormatter::formatObject($dt), "\n";
|
||||
echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
|
||||
echo IntlDateFormatter::formatObject($dt, null, "en-US"), "\n";
|
||||
echo IntlDateFormatter::formatObject($dt, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
|
||||
echo IntlDateFormatter::formatObject($dt, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
|
||||
|
||||
$dt = new DateTime('2012-01-01 05:00:00+03:00');
|
||||
echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
|
||||
--EXPECTF--
|
||||
01/01/2012, 00:00:00
|
||||
domingo, 1 de Janeiro de 2012 às 00:00:00 Hora Padrão %Sda Europa Ocidental
|
||||
Jan 1, 2012, 12:00:00 AM
|
||||
1/1/12, 12:00:00 AM Western European Standard %STime
|
||||
Sun 2012-01-1 00,00,00.000 Portugal Time
|
||||
domingo, 1 de Janeiro de 2012 às 05:00:00 GMT+03:00
|
||||
==DONE==
|
||||
@@ -3,7 +3,7 @@ IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) die('skip for ICU >= 51.2 and < 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
55
ext/intl/tests/dateformat_get_set_calendar_variant3.phpt
Normal file
55
ext/intl/tests/dateformat_get_set_calendar_variant3.phpt
Normal file
@@ -0,0 +1,55 @@
|
||||
--TEST--
|
||||
IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "pt_PT");
|
||||
ini_set("date.timezone", 'Atlantic/Azores');
|
||||
|
||||
$ts = strtotime('2012-01-01 00:00:00 UTC');
|
||||
|
||||
function d(IntlDateFormatter $df) {
|
||||
global $ts;
|
||||
echo $df->format($ts), "\n";
|
||||
var_dump($df->getCalendar(),
|
||||
$df->getCalendarObject()->getType(),
|
||||
$df->getCalendarObject()->getTimeZone()->getId());
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk');
|
||||
d($df);
|
||||
|
||||
|
||||
//changing the calendar with a cal type should not change tz
|
||||
$df->setCalendar(IntlDateFormatter::TRADITIONAL);
|
||||
d($df);
|
||||
|
||||
//but changing with an actual calendar should
|
||||
$cal = IntlCalendar::createInstance("UTC");
|
||||
$df->setCalendar($cal);
|
||||
d($df);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
dimanche 1 janvier 2012 ap. J.-C. à 03:00:00 UTC+03:00
|
||||
int(1)
|
||||
string(9) "gregorian"
|
||||
string(12) "Europe/Minsk"
|
||||
|
||||
dimanche 8 safar 1433 AH à 03:00:00 UTC+03:00
|
||||
int(0)
|
||||
string(7) "islamic"
|
||||
string(12) "Europe/Minsk"
|
||||
|
||||
dimanche 1 janvier 2012 ap. J.-C. à 00:00:00 UTC
|
||||
bool(false)
|
||||
string(9) "gregorian"
|
||||
string(3) "UTC"
|
||||
|
||||
==DONE==
|
||||
@@ -3,7 +3,7 @@ IntlDateFormatter: get/setTimeZone()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) die('skip for ICU >= 51.2 and < 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
62
ext/intl/tests/dateformat_get_set_timezone_variant3.phpt
Normal file
62
ext/intl/tests/dateformat_get_set_timezone_variant3.phpt
Normal file
@@ -0,0 +1,62 @@
|
||||
--TEST--
|
||||
IntlDateFormatter: get/setTimeZone()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "pt_PT");
|
||||
ini_set("date.timezone", 'Atlantic/Azores');
|
||||
|
||||
$ts = strtotime('2012-01-01 00:00:00 UTC');
|
||||
|
||||
function d(IntlDateFormatter $df) {
|
||||
global $ts;
|
||||
echo $df->format($ts), "\n";
|
||||
var_dump(
|
||||
$df->getTimeZoneID(),
|
||||
$df->getTimeZone()->getID());
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk');
|
||||
d($df);
|
||||
|
||||
$df->setTimeZone(NULL);
|
||||
d($df);
|
||||
|
||||
$df->setTimeZone('Europe/Madrid');
|
||||
d($df);
|
||||
|
||||
$df->setTimeZone(IntlTimeZone::createTimeZone('Europe/Paris'));
|
||||
d($df);
|
||||
|
||||
$df->setTimeZone(new DateTimeZone('Europe/Amsterdam'));
|
||||
d($df);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECTF--
|
||||
domingo, 1 de Janeiro de 2012 às 03:00:00 GMT+03:00
|
||||
string(12) "Europe/Minsk"
|
||||
string(12) "Europe/Minsk"
|
||||
|
||||
sábado, 31 de Dezembro de 2011 às 23:00:00 Hor%s Padrão %Sdos Açores
|
||||
string(15) "Atlantic/Azores"
|
||||
string(15) "Atlantic/Azores"
|
||||
|
||||
domingo, 1 de Janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central
|
||||
string(13) "Europe/Madrid"
|
||||
string(13) "Europe/Madrid"
|
||||
|
||||
domingo, 1 de Janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central
|
||||
string(12) "Europe/Paris"
|
||||
string(12) "Europe/Paris"
|
||||
|
||||
domingo, 1 de Janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central
|
||||
string(16) "Europe/Amsterdam"
|
||||
string(16) "Europe/Amsterdam"
|
||||
|
||||
==DONE==
|
||||
@@ -3,7 +3,7 @@ IntlDateFormatter: several forms of the timezone arg
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) die('skip for ICU >= 51.2 and < 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
45
ext/intl/tests/dateformat_timezone_arg_variations3.phpt
Normal file
45
ext/intl/tests/dateformat_timezone_arg_variations3.phpt
Normal file
@@ -0,0 +1,45 @@
|
||||
--TEST--
|
||||
IntlDateFormatter: several forms of the timezone arg
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("date.timezone", 'Atlantic/Azores');
|
||||
|
||||
$ts = strtotime('2012-01-01 00:00:00 UTC');
|
||||
|
||||
//should use Atlantic/Azores
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, NULL);
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam');
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, new DateTimeZone('Europe/Lisbon'));
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, IntlTimeZone::createTimeZone('America/New_York'));
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
//time zone has priority
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', new IntlGregorianCalendar('Europe/Lisbon'));
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
//calendar has priority
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, NULL, new IntlGregorianCalendar('Europe/Lisbon'));
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', 0);
|
||||
echo $df->format($ts), "\n";
|
||||
|
||||
--EXPECTF--
|
||||
sábado%S 31 de diciembre de 2011, 23:00:00 (Hora estándar de las Azores)
|
||||
domingo%S 1 de enero de 2012, 1:00:00 (Hora estándar de Europa central)
|
||||
domingo%S 1 de enero de 2012, 0:00:00 (Hora%S estándar de Europa occidental)
|
||||
sábado%S 31 de diciembre de 2011, 19:00:00 (Hora estándar oriental)
|
||||
domingo%S 1 de enero de 2012, 1:00:00 (Hora estándar de Europa central)
|
||||
domingo%S 1 de enero de 2012, 0:00:00 (Hora%S estándar de Europa occidental)
|
||||
domingo%S 1 de enero de 2012, 1:00:00 (Hora estándar de Europa central)
|
||||
@@ -2,7 +2,7 @@
|
||||
numfmt_format() icu >= 4.8
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
130
ext/intl/tests/formatter_format3.phpt
Normal file
130
ext/intl/tests/formatter_format3.phpt
Normal file
@@ -0,0 +1,130 @@
|
||||
--TEST--
|
||||
numfmt_format() icu >= 52.1
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '52.1') < 0) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Format a number using misc locales/patterns.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO: doesn't pass on ICU 3.6 because 'ru' and 'de' locales changed
|
||||
* currency and percent formatting.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$styles = array(
|
||||
NumberFormatter::PATTERN_DECIMAL => '##.#####################',
|
||||
NumberFormatter::DECIMAL => '',
|
||||
NumberFormatter::CURRENCY => '',
|
||||
NumberFormatter::PERCENT => '',
|
||||
NumberFormatter::SCIENTIFIC => '',
|
||||
NumberFormatter::SPELLOUT => '@@@@@@@',
|
||||
NumberFormatter::ORDINAL => '',
|
||||
NumberFormatter::DURATION => '',
|
||||
NumberFormatter::PATTERN_RULEBASED => '#####.###',
|
||||
1234999, // bad one
|
||||
);
|
||||
|
||||
$integer = array(
|
||||
NumberFormatter::ORDINAL => '',
|
||||
NumberFormatter::DURATION => '',
|
||||
);
|
||||
$locales = array(
|
||||
'en_US',
|
||||
'ru_UA',
|
||||
'de',
|
||||
'fr',
|
||||
'en_UK'
|
||||
);
|
||||
|
||||
$str_res = '';
|
||||
$number = 1234567.891234567890000;
|
||||
|
||||
foreach( $locales as $locale )
|
||||
{
|
||||
$str_res .= "\nLocale is: $locale\n";
|
||||
foreach( $styles as $style => $pattern )
|
||||
{
|
||||
$fmt = ut_nfmt_create( $locale, $style, $pattern );
|
||||
|
||||
if(!$fmt) {
|
||||
$str_res .= "Bad formatter!\n";
|
||||
continue;
|
||||
}
|
||||
$str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n";
|
||||
}
|
||||
}
|
||||
return $str_res;
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
|
||||
// Run the test
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
Locale is: en_US
|
||||
'1234567.89123457'
|
||||
'1,234,567.891'
|
||||
'\$1,234,567.89'
|
||||
'123,456,789%'
|
||||
'1.23456789123457E6'
|
||||
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven'
|
||||
'1,234,567(th|ᵗʰ)'
|
||||
'342:56:07'
|
||||
'#####.###'
|
||||
Bad formatter!
|
||||
|
||||
Locale is: ru_UA
|
||||
'1234567,89123457'
|
||||
'1 234 567,891'
|
||||
'1 234 567,89 ?(грн\.|₴)'
|
||||
'123 456 789 ?%'
|
||||
'1,23456789123457E6'
|
||||
'один миллион двести тридцать четыре тысяч пятьсот шестьдесят семь запятая восемь девять один два три четыре пять семь'
|
||||
'1 234 567.?'
|
||||
'1 234 567'
|
||||
'#####.###'
|
||||
Bad formatter!
|
||||
|
||||
Locale is: de
|
||||
'1234567,89123457'
|
||||
'1.234.567,891'
|
||||
'(¤ )?1.234.567,89( ¤)?'
|
||||
'123\.456\.789 %'
|
||||
'1,23456789123457E6'
|
||||
'eine Million zweihundertvierunddreißigtausendfünfhundertsiebenundsechzig Komma acht neun eins zwei drei vier fünf sieben'
|
||||
'1.234.567.?'
|
||||
'1.234.567'
|
||||
'#####.###'
|
||||
Bad formatter!
|
||||
|
||||
Locale is: fr
|
||||
'1234567,89123457'
|
||||
'1 234 567,891'
|
||||
'1 234 567,89 ¤'
|
||||
'123 456 789 ?%'
|
||||
'1,23456789123457E6'
|
||||
'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq sept'
|
||||
'1 234 567e'
|
||||
'1 234 567'
|
||||
'#####.###'
|
||||
Bad formatter!
|
||||
|
||||
Locale is: en_UK
|
||||
'1234567.89123457'
|
||||
'1,234,567.891'
|
||||
'¤1,234,567.89'
|
||||
'123,456,789%'
|
||||
'1.23456789123457E6'
|
||||
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven'
|
||||
'1,234,567(th|ᵗʰ)'
|
||||
'342:56:07'
|
||||
'#####.###'
|
||||
Bad formatter!
|
||||
Reference in New Issue
Block a user