]> granicus.if.org Git - php/commitdiff
Added and fixed tests given eb346ef
authorGustavo André dos Santos Lopes <cataphract@php.net>
Sun, 3 Jun 2012 22:02:35 +0000 (00:02 +0200)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Sun, 3 Jun 2012 22:02:35 +0000 (00:02 +0200)
17 files changed:
ext/intl/tests/bug50590.phpt
ext/intl/tests/bug62017.phpt
ext/intl/tests/bug62081.phpt
ext/intl/tests/dateformat___construct_bad_tz_cal.phpt [new file with mode: 0644]
ext/intl/tests/dateformat_calendars.phpt
ext/intl/tests/dateformat_create_cal_arg.phpt [new file with mode: 0644]
ext/intl/tests/dateformat_format.phpt
ext/intl/tests/dateformat_format_parse.phpt
ext/intl/tests/dateformat_getCalendarObject_error.phpt [new file with mode: 0644]
ext/intl/tests/dateformat_getTimeZone_error.phpt [new file with mode: 0644]
ext/intl/tests/dateformat_get_set_calendar.phpt
ext/intl/tests/dateformat_get_set_timezone.phpt [new file with mode: 0644]
ext/intl/tests/dateformat_get_timezone_id.phpt
ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt [new file with mode: 0644]
ext/intl/tests/dateformat_setTimeZone_error.phpt [new file with mode: 0644]
ext/intl/tests/dateformat_set_timezone_id2.phpt
ext/intl/tests/dateformat_timezone_arg_variations.phpt [new file with mode: 0644]

index c39c333b23ad764d0affaa948b0f70926ff7a0b1..4784d378773e3d45054f570ccf629e782cd69405 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 Bug #50590 (IntlDateFormatter::parse result is limited to the integer range)
+--INI--
+date.timezone=Atlantic/Azores
 --SKIPIF--
 <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
 --FILE--
index 13c4fe5df0be716ed8c027b59029ceff6c264186..50aeae48061a43a908b434e3284cf58aaaeeba6c 100644 (file)
@@ -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
index 7d9e2cec47ff4ada5c73f2776e53a337ab85e11a..44ad4beec7fab21cb179153b222190a84ee88047 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 Bug #62081: IntlDateFormatter leaks memory if called twice
+--INI--
+date.timezone=Atlantic/Azores
 --SKIPIF--
 <?php
 if (!extension_loaded('intl'))
@@ -7,8 +9,8 @@ if (!extension_loaded('intl'))
 --FILE--
 <?php
 ini_set('intl.error_level', E_WARNING);
-$x = new IntlDateFormatter(1,1,1,1,1);
-var_dump($x->__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 (file)
index 0000000..1f682dd
--- /dev/null
@@ -0,0 +1,28 @@
+--TEST--
+IntlDateFormatter::__construct(): bad timezone or calendar
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone'));
+
+var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3));
+
+var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass));
+
+
+?>
+==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==
index 27f380c7184572109799755c539c7cd7abe68dfa..6af02e51c14e6929637867889a80a56b75da9e4e 100644 (file)
@@ -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 (file)
index 0000000..8e5f942
--- /dev/null
@@ -0,0 +1,49 @@
+--TEST--
+IntlDateFormatter: several forms of the calendar arg
+--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==
+--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==
index e5548196d10316eeab7e9d69cb20e52cb6e735eb..98f9d34c03ab95fa87c1c0e0c4f878071e71484a 100755 (executable)
@@ -5,6 +5,8 @@ datefmt_format_code()
 --FILE--
 <?php
 
+//ini_set("intl.error_level", E_WARNING);
+
 /*
  * Test for the datefmt_format  function
  */
@@ -12,7 +14,7 @@ datefmt_format_code()
 
 function ut_main()
 {
-       $timezone = 'GMT-10';
+       $timezone = 'GMT-10:00';
 
        $locale_arr = array (
                'en_US'
index bd41d715b9e63c1baad5f14ba3bae015934517bc..6bd3d8a8ff9ef838b6d6b87188d50795ee5edcd0 100755 (executable)
@@ -12,7 +12,7 @@ datefmt_format_code() and datefmt_parse_code()
 
 function ut_main()
 {
-       $timezone = 'GMT+5'; 
+       $timezone = 'GMT+05:00'; 
 
        $locale_arr = array (
                'en_US'
diff --git a/ext/intl/tests/dateformat_getCalendarObject_error.phpt b/ext/intl/tests/dateformat_getCalendarObject_error.phpt
new file mode 100644 (file)
index 0000000..22f12cb
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+IntlDateFormatter::getCalendarObject(): bad args
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$df = new IntlDateFormatter(NULL, 0, 0);
+
+var_dump($df->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 (file)
index 0000000..c9d49fd
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+IntlDateFormatter::getTimeZone(): bad args
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$df = new IntlDateFormatter(NULL, 0, 0);
+
+var_dump($df->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==
index bfd4e578e1ca55e116c1ae6b9da23cfecaaf5fca..e792ea379933c35e8c0435a5869e430f23a2541b 100755 (executable)
@@ -1,60 +1,51 @@
 --TEST--
-datefmt_get_calendar_code() datefmt_set_calendar_code()
---SKIPIF--
-<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
 --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";
+}
 
-/*
- * 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 (file)
index 0000000..50b036e
--- /dev/null
@@ -0,0 +1,58 @@
+--TEST--
+IntlDateFormatter: get/setTimeZone()
+--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==
+--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==
index 80cbdbbf0fc1add45f8caa14296bf0b300b7d16e..a9701c38687ea4b97f07ee7bc4ae1889d687e8aa 100755 (executable)
@@ -1,5 +1,8 @@
 --TEST--
 datefmt_get_timezone_id_code()
+--INI--
+date.timezone=Atlantic/Azores
+intl.error_level=E_WARNING
 --SKIPIF--
 <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
 --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 (file)
index 0000000..ccc477d
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+IntlDateFormatter: setTimeZoneID() deprecation
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk');
+
+$df->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 (file)
index 0000000..8200197
--- /dev/null
@@ -0,0 +1,49 @@
+--TEST--
+IntlDateFormatter::setTimeZone() bad args
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$df = new IntlDateFormatter(NULL, 0, 0);
+
+var_dump($df->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==
index 23aacda90aeb24b262660f154de5660c2ef6e314..ce9b89d1fdbbf6ff8488f66d41ecc32c0c1b88bf 100644 (file)
@@ -1,11 +1,16 @@
 --TEST--
 datefmt_set_timezone_id_code() icu >= 4.8
+--INI--
+date.timezone=Atlantic/Azores
 --SKIPIF--
 <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
 <?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
 --FILE--
 <?php
 
+ini_set("intl.error_level", E_WARNING);
+ini_set("error_reporting", ~E_DEPRECATED);
+
 /*
  * Test for the datefmt_set_timezone_id  function
  */
@@ -23,7 +28,7 @@ function ut_main()
 
        $res_str = '';
 
-       $fmt = ut_datefmt_create( "en_US",  IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/San_Francisco' , IntlDateFormatter::GREGORIAN  );
+       $fmt = ut_datefmt_create( "en_US",  IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'US/Pacific' , IntlDateFormatter::GREGORIAN  );
        $timezone_id = ut_datefmt_get_timezone_id( $fmt );
        $res_str .= "\nAfter creation of the dateformatter :  timezone_id= $timezone_id\n";
 
@@ -52,8 +57,13 @@ include_once( 'ut_common.inc' );
 // Run the test
 ut_run();
 ?>
---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 (file)
index 0000000..df3ebd8
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+IntlDateFormatter: several forms of the timezone arg
+--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%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