From: Gustavo André dos Santos Lopes Date: Sun, 3 Jun 2012 22:02:35 +0000 (+0200) Subject: Added and fixed tests given eb346ef X-Git-Tag: php-5.5.0alpha1~129^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=758f0686d41cd39176f5055c50f0b094580cbbf0;p=php Added and fixed tests given eb346ef --- diff --git a/ext/intl/tests/bug50590.phpt b/ext/intl/tests/bug50590.phpt index c39c333b23..4784d37877 100644 --- a/ext/intl/tests/bug50590.phpt +++ b/ext/intl/tests/bug50590.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #50590 (IntlDateFormatter::parse result is limited to the integer range) +--INI-- +date.timezone=Atlantic/Azores --SKIPIF-- --FILE-- diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt index 13c4fe5df0..50aeae4806 100644 --- a/ext/intl/tests/bug62017.phpt +++ b/ext/intl/tests/bug62017.phpt @@ -14,7 +14,7 @@ var_dump( new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon", IntlDateFormatter::GREGORIAN, "\x80")); --EXPECTF-- -Warning: datefmt_create(): datefmt_create: error converting timezone_str to UTF-16 in %s on line %d +Warning: datefmt_create(): datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d NULL Warning: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d diff --git a/ext/intl/tests/bug62081.phpt b/ext/intl/tests/bug62081.phpt index 7d9e2cec47..44ad4beec7 100644 --- a/ext/intl/tests/bug62081.phpt +++ b/ext/intl/tests/bug62081.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #62081: IntlDateFormatter leaks memory if called twice +--INI-- +date.timezone=Atlantic/Azores --SKIPIF-- __construct(1,1,1,1,1)); +$x = new IntlDateFormatter('en', 1, 1); +var_dump($x->__construct('en', 1, 1)); --EXPECTF-- Warning: IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice in %s on line %d NULL diff --git a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt new file mode 100644 index 0000000000..1f682ddb4a --- /dev/null +++ b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlDateFormatter::__construct(): bad timezone or calendar +--FILE-- + +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::__construct(): datefmt_create: no such time zone: 'bad timezone' in %s on line %d +NULL + +Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d +NULL + +Warning: IntlDateFormatter::__construct(): datefmt_create: Invalid calendar argument; should be an integer or an IntlCalendar instance in %s on line %d +NULL +==DONE== diff --git a/ext/intl/tests/dateformat_calendars.phpt b/ext/intl/tests/dateformat_calendars.phpt index 27f380c718..6af02e51c1 100644 --- a/ext/intl/tests/dateformat_calendars.phpt +++ b/ext/intl/tests/dateformat_calendars.phpt @@ -41,5 +41,5 @@ string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12" string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12" string(42) "Sunday, Tevet 6, 5772 5:12:00 AM GMT+05:12" -Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN in %s on line %d +Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d ==DONE== diff --git a/ext/intl/tests/dateformat_create_cal_arg.phpt b/ext/intl/tests/dateformat_create_cal_arg.phpt new file mode 100644 index 0000000000..8e5f942a6b --- /dev/null +++ b/ext/intl/tests/dateformat_create_cal_arg.phpt @@ -0,0 +1,49 @@ +--TEST-- +IntlDateFormatter: several forms of the calendar arg +--FILE-- +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== +--EXPECT-- +domingo, 1 de enero de 2012 00:00:00 GMT +domingo, 8 de Safar de 1433 00:00:00 GMT +domingo, 1 de enero de 2012 01:00:00 Hora estándar de Europa Central +sábado, 31 de diciembre de 2011 d.C. 23:00:00 Hora estándar de las Azores +sábado, 7 de Safar de 1433 AH 23:00:00 Hora estándar de las Azores +domingo, 8 de Safar de 1433 AH 00:00:00 GMT +domingo, 1 de enero de 2012 00:00:00 GMT +==DONE== diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt index e5548196d1..98f9d34c03 100755 --- a/ext/intl/tests/dateformat_format.phpt +++ b/ext/intl/tests/dateformat_format.phpt @@ -5,6 +5,8 @@ datefmt_format_code() --FILE-- getCalendarObject(9)); +var_dump(datefmt_get_calendar_object($df, 9)); +var_dump(datefmt_get_calendar_object($df, 9)); +var_dump(datefmt_get_calendar_object(new stdclass)); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::getCalendarObject() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlDateFormatter::getCalendarObject(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_calendar_object() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_calendar_object() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_calendar_object() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d + +Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/dateformat_getTimeZone_error.phpt b/ext/intl/tests/dateformat_getTimeZone_error.phpt new file mode 100644 index 0000000000..c9d49fde43 --- /dev/null +++ b/ext/intl/tests/dateformat_getTimeZone_error.phpt @@ -0,0 +1,39 @@ +--TEST-- +IntlDateFormatter::getTimeZone(): bad args +--FILE-- +getTimeZone(9)); +var_dump(datefmt_get_timezone($df, 9)); +var_dump(datefmt_get_timezone($df, 9)); +var_dump(datefmt_get_timezone(new stdclass)); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::getTimeZone() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlDateFormatter::getTimeZone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_timezone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_timezone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_timezone() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d + +Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/dateformat_get_set_calendar.phpt b/ext/intl/tests/dateformat_get_set_calendar.phpt index bfd4e578e1..e792ea3799 100755 --- a/ext/intl/tests/dateformat_get_set_calendar.phpt +++ b/ext/intl/tests/dateformat_get_set_calendar.phpt @@ -1,60 +1,51 @@ --TEST-- -datefmt_get_calendar_code() datefmt_set_calendar_code() ---SKIPIF-- - +IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject() --FILE-- format($ts), "\n"; +var_dump($df->getCalendar(), +$df->getCalendarObject()->getType(), +$df->getCalendarObject()->getTimeZone()->getId()); +echo "\n"; +} -/* - * Test for the datefmt_get_calendar and datefmt_set_calendar functions - */ - - -function ut_main() -{ - $calendar_arr = array ( - IntlDateFormatter::GREGORIAN, - IntlDateFormatter::TRADITIONAL, - 3 - ); - - $res_str = ''; - - $start_calendar = IntlDateFormatter::GREGORIAN; - $res_str .= "\nCreating IntlDateFormatter with calendar = $start_calendar"; - $fmt = ut_datefmt_create( "de-DE", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT ,'America/Los_Angeles', IntlDateFormatter::GREGORIAN); - $calendar = ut_datefmt_get_calendar( $fmt); - $res_str .= "\nAfter call to get_calendar : calendar= $calendar"; - $res_str .= "\n-------------------"; - - foreach( $calendar_arr as $calendar_entry ) - { - $res_str .= "\nSetting IntlDateFormatter with calendar = $calendar_entry"; - ut_datefmt_set_calendar( $fmt, $calendar_entry); - $calendar = ut_datefmt_get_calendar( $fmt); - $res_str .= "\nAfter call to get_calendar : calendar= $calendar"; - $res_str .= "\n-------------------"; - } - - return $res_str; +$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk'); +d($df); -} -include_once( 'ut_common.inc' ); +//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); -// Run the test -ut_run(); ?> +==DONE== --EXPECT-- -Creating IntlDateFormatter with calendar = 1 -After call to get_calendar : calendar= 1 -------------------- -Setting IntlDateFormatter with calendar = 1 -After call to get_calendar : calendar= 1 -------------------- -Setting IntlDateFormatter with calendar = 0 -After call to get_calendar : calendar= 0 -------------------- -Setting IntlDateFormatter with calendar = 3 -After call to get_calendar : calendar= 0 -------------------- \ No newline at end of file +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== diff --git a/ext/intl/tests/dateformat_get_set_timezone.phpt b/ext/intl/tests/dateformat_get_set_timezone.phpt new file mode 100644 index 0000000000..50b036e36e --- /dev/null +++ b/ext/intl/tests/dateformat_get_set_timezone.phpt @@ -0,0 +1,58 @@ +--TEST-- +IntlDateFormatter: get/setTimeZone() +--FILE-- +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== +--EXPECT-- +Domingo, 1 de Janeiro de 2012 3:00:00 GMT+03:00 +string(12) "Europe/Minsk" +string(12) "Europe/Minsk" + +Sábado, 31 de Dezembro de 2011 23:00:00 Hora Padrão dos Açores +string(15) "Atlantic/Azores" +string(15) "Atlantic/Azores" + +Domingo, 1 de Janeiro de 2012 1:00:00 Hora Padrão da Europa Central +string(13) "Europe/Madrid" +string(13) "Europe/Madrid" + +Domingo, 1 de Janeiro de 2012 1:00:00 Hora Padrão da Europa Central +string(12) "Europe/Paris" +string(12) "Europe/Paris" + +Domingo, 1 de Janeiro de 2012 1:00:00 Hora Padrão da Europa Central +string(16) "Europe/Amsterdam" +string(16) "Europe/Amsterdam" + +==DONE== diff --git a/ext/intl/tests/dateformat_get_timezone_id.phpt b/ext/intl/tests/dateformat_get_timezone_id.phpt index 80cbdbbf0f..a9701c3868 100755 --- a/ext/intl/tests/dateformat_get_timezone_id.phpt +++ b/ext/intl/tests/dateformat_get_timezone_id.phpt @@ -1,5 +1,8 @@ --TEST-- datefmt_get_timezone_id_code() +--INI-- +date.timezone=Atlantic/Azores +intl.error_level=E_WARNING --SKIPIF-- --FILE-- @@ -14,8 +17,8 @@ function ut_main() { $timezone_id_arr = array ( 'America/New_York', - 'America/Los_Angeles', - 'America/Dallas' + 'US/Pacific', + 'US/Central' ); $res_str = ''; @@ -42,8 +45,8 @@ ut_run(); Creating IntlDateFormatter with timezone_id = America/New_York After call to get_timezone_id : timezone_id= America/New_York -Creating IntlDateFormatter with timezone_id = America/Los_Angeles -After call to get_timezone_id : timezone_id= America/Los_Angeles +Creating IntlDateFormatter with timezone_id = US/Pacific +After call to get_timezone_id : timezone_id= US/Pacific -Creating IntlDateFormatter with timezone_id = America/Dallas -After call to get_timezone_id : timezone_id= America/Dallas +Creating IntlDateFormatter with timezone_id = US/Central +After call to get_timezone_id : timezone_id= US/Central diff --git a/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt b/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt new file mode 100644 index 0000000000..ccc477d075 --- /dev/null +++ b/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt @@ -0,0 +1,18 @@ +--TEST-- +IntlDateFormatter: setTimeZoneID() deprecation +--FILE-- +setTimeZoneId('Europe/Madrid'); + +?> +==DONE== +--EXPECTF-- + +Deprecated: IntlDateFormatter::setTimeZoneId(): Use datefmt_set_timezone() instead, which also accepts a plain time zone identifier and for which this function is now an alias in %s on line %d +==DONE== diff --git a/ext/intl/tests/dateformat_setTimeZone_error.phpt b/ext/intl/tests/dateformat_setTimeZone_error.phpt new file mode 100644 index 0000000000..8200197948 --- /dev/null +++ b/ext/intl/tests/dateformat_setTimeZone_error.phpt @@ -0,0 +1,49 @@ +--TEST-- +IntlDateFormatter::setTimeZone() bad args +--FILE-- +setTimeZone()); +var_dump(datefmt_set_timezone()); +var_dump($df->setTimeZone(array())); +var_dump($df->setTimeZone(1, 2)); +var_dump($df->setTimeZone('non existing timezone')); +var_dump(datefmt_set_timezone(new stdclass, 'UTC')); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::setTimeZone() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_set_timezone() expects exactly 2 parameters, 0 given in %s on line %d + +Warning: datefmt_set_timezone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) + +Notice: Array to string conversion in %s on line %d + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: no such time zone: 'Array' in %s on line %d +bool(false) + +Warning: IntlDateFormatter::setTimeZone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: no such time zone: 'non existing timezone' in %s on line %d +bool(false) + +Warning: datefmt_set_timezone() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d + +Warning: datefmt_set_timezone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/dateformat_set_timezone_id2.phpt b/ext/intl/tests/dateformat_set_timezone_id2.phpt index 23aacda90a..ce9b89d1fd 100644 --- a/ext/intl/tests/dateformat_set_timezone_id2.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id2.phpt @@ -1,11 +1,16 @@ --TEST-- datefmt_set_timezone_id_code() icu >= 4.8 +--INI-- +date.timezone=Atlantic/Azores --SKIPIF-- --FILE-- ---EXPECT-- -After creation of the dateformatter : timezone_id= America/San_Francisco +--EXPECTF-- + +Warning: IntlDateFormatter::setTimeZoneId(): datefmt_set_timezone: no such time zone: 'CN' in %s on line %d + +Warning: datefmt_set_timezone_id(): datefmt_set_timezone: no such time zone: 'CN' in %s on line %d + +After creation of the dateformatter : timezone_id= US/Pacific ----------- Trying to set timezone_id= America/New_York After call to set_timezone_id : timezone_id= America/New_York @@ -71,6 +81,6 @@ Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Cent Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time ----------- Trying to set timezone_id= CN -After call to set_timezone_id : timezone_id= CN -Formatting timestamp=0 resulted in Thursday, January 1, 1970 12:00:00 AM GMT -Formatting timestamp=3600 resulted in Thursday, January 1, 1970 1:00:00 AM GMT +After call to set_timezone_id : timezone_id= America/Chicago +Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Central Standard Time +Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time diff --git a/ext/intl/tests/dateformat_timezone_arg_variations.phpt b/ext/intl/tests/dateformat_timezone_arg_variations.phpt new file mode 100644 index 0000000000..df3ebd853d --- /dev/null +++ b/ext/intl/tests/dateformat_timezone_arg_variations.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlDateFormatter: several forms of the timezone arg +--FILE-- +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%S de las Azores +domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central +domingo%S 1 de enero de 2012 00:00:00 Hora%S 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 01:00:00 Hora estándar de Europa Central +domingo%S 1 de enero de 2012 00:00:00 Hora%S de Europa Occidental +domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central