Permalink
Browse files

Fix bug #61448 intl tests fail with icu >= 4.8

  • Loading branch information...
weltling committed Mar 28, 2012
1 parent 4fa0c2a commit bd928f05921a9c3595181c9b04e8024ad9ab9303
Showing with 2,931 additions and 26 deletions.
  1. +2 −1 ext/intl/tests/collator_create.phpt
  2. +82 −0 ext/intl/tests/collator_create2.phpt
  3. +2 −1 ext/intl/tests/collator_get_locale.phpt
  4. +51 −0 ext/intl/tests/collator_get_locale2.phpt
  5. +2 −1 ext/intl/tests/dateformat_clone.phpt
  6. +37 −0 ext/intl/tests/dateformat_clone2.phpt
  7. +3 −2 ext/intl/tests/dateformat_get_set_pattern.phpt
  8. +85 −0 ext/intl/tests/dateformat_get_set_pattern2.phpt
  9. +2 −1 ext/intl/tests/dateformat_localtime.phpt
  10. +2 −1 ext/intl/tests/dateformat_parse.phpt
  11. +2 −1 ext/intl/tests/dateformat_parse_localtime_parsepos.phpt
  12. +2 −1 ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt
  13. +3 −2 ext/intl/tests/dateformat_set_timezone_id.phpt
  14. +76 −0 ext/intl/tests/dateformat_set_timezone_id2.phpt
  15. +3 −2 ext/intl/tests/formatter_format.phpt
  16. +130 −0 ext/intl/tests/formatter_format2.phpt
  17. +3 −2 ext/intl/tests/formatter_format_currency.phpt
  18. +50 −0 ext/intl/tests/formatter_format_currency2.phpt
  19. +2 −1 ext/intl/tests/formatter_get_set_attribute.phpt
  20. +194 −0 ext/intl/tests/formatter_get_set_attribute2.phpt
  21. +2 −1 ext/intl/tests/formatter_get_set_symbol.phpt
  22. +190 −0 ext/intl/tests/formatter_get_set_symbol2.phpt
  23. +2 −1 ext/intl/tests/locale_filter_matches.phpt
  24. +366 −0 ext/intl/tests/locale_filter_matches2.phpt
  25. +2 −1 ext/intl/tests/locale_get_display_name.phpt
  26. +342 −0 ext/intl/tests/locale_get_display_name2.phpt
  27. +2 −1 ext/intl/tests/locale_get_display_region.phpt
  28. +275 −0 ext/intl/tests/locale_get_display_region2.phpt
  29. +3 −2 ext/intl/tests/locale_get_display_script.phpt
  30. +275 −0 ext/intl/tests/locale_get_display_script2.phpt
  31. +2 −1 ext/intl/tests/locale_get_display_variant.phpt
  32. +275 −0 ext/intl/tests/locale_get_display_variant2.phpt
  33. +2 −1 ext/intl/tests/locale_get_keywords.phpt
  34. +151 −0 ext/intl/tests/locale_get_keywords2.phpt
  35. +2 −1 ext/intl/tests/locale_parse_locale.phpt
  36. +203 −0 ext/intl/tests/locale_parse_locale2.phpt
  37. +2 −1 ext/intl/tests/msgfmt_fail.phpt
  38. +102 −0 ext/intl/tests/msgfmt_fail2.phpt
@@ -1,7 +1,8 @@
--TEST--
-create()
+create() icu <= 4.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
--FILE--
<?php
@@ -0,0 +1,82 @@
+--TEST--
+create() icu >= 4.8
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try creating collator with different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $locales = array(
+ 'EN-US-ODESSA',
+ 'UK_UA_ODESSA',
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ '',
+ 'root',
+ 'uk@currency=EURO',
+ '1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799'
+ );
+
+ foreach( $locales as $locale )
+ {
+ // Create Collator with the current locale.
+ $coll = ut_coll_create( $locale );
+ if( !is_object($coll) )
+ {
+ $res_str .= "Error creating collator with '$locale' locale: " .
+ intl_get_error_message() . "\n";
+ continue;
+ }
+
+ // Get the requested, valid and actual locales.
+ $vloc = ut_coll_get_locale( $coll, Locale::VALID_LOCALE );
+ $aloc = ut_coll_get_locale( $coll, Locale::ACTUAL_LOCALE );
+
+ // Show them.
+ $res_str .= "Locale: '$locale'\n" .
+ " ULOC_REQUESTED_LOCALE = '$locale'\n" .
+ " ULOC_VALID_LOCALE = '$vloc'\n" .
+ " ULOC_ACTUAL_LOCALE = '$aloc'\n";
+ }
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTF--
+Locale: 'EN-US-ODESSA'
+ ULOC_REQUESTED_LOCALE = 'EN-US-ODESSA'
+ ULOC_VALID_LOCALE = 'en_US'
+ ULOC_ACTUAL_LOCALE = 'root'
+Locale: 'UK_UA_ODESSA'
+ ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA'
+ ULOC_VALID_LOCALE = 'uk_UA'
+ ULOC_ACTUAL_LOCALE = 'uk'
+Locale: 'uk-ua_CALIFORNIA@currency=;currency=GRN'
+ ULOC_REQUESTED_LOCALE = 'uk-ua_CALIFORNIA@currency=;currency=GRN'
+ ULOC_VALID_LOCALE = 'uk_UA'
+ ULOC_ACTUAL_LOCALE = 'uk'
+Locale: ''
+ ULOC_REQUESTED_LOCALE = ''
+ ULOC_VALID_LOCALE = '%s'
+ ULOC_ACTUAL_LOCALE = '%s'
+Locale: 'root'
+ ULOC_REQUESTED_LOCALE = 'root'
+ ULOC_VALID_LOCALE = 'root'
+ ULOC_ACTUAL_LOCALE = 'root'
+Locale: 'uk@currency=EURO'
+ ULOC_REQUESTED_LOCALE = 'uk@currency=EURO'
+ ULOC_VALID_LOCALE = 'uk'
+ ULOC_ACTUAL_LOCALE = 'uk'
+Error creating collator with '1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than 80 characters: U_ILLEGAL_ARGUMENT_ERROR
@@ -1,7 +1,8 @@
--TEST--
-get_locale()
+get_locale() icu <= 4.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
--FILE--
<?php
@@ -0,0 +1,51 @@
+--TEST--
+get_locale() icu >= 4.8
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try to specify valid and invalid locale types when getting locale.
+ */
+
+function ut_main()
+{
+ $locales = array(
+ Locale::VALID_LOCALE,
+ Locale::ACTUAL_LOCALE,
+ 100,
+ -100,
+ -9999999999999,
+ 9999999999999,
+ 1.2,
+ );
+
+ $coll = ut_coll_create( 'en_US' );
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $rc = ut_coll_get_locale( $coll, $locale );
+
+ $res_str .= sprintf(
+ "Locale of type %s is %s\n",
+ dump( $locale ),
+ dump( $rc ) );
+ }
+
+ return $res_str . "\n";
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+Locale of type 1 is 'en_US'
+Locale of type 0 is 'root'
+Locale of type 100 is false
+Locale of type -100 is false
+Locale of type -9999999999999 is false
+Locale of type 9999999999999 is false
+Locale of type 1.2 is 'en_US'
@@ -1,7 +1,8 @@
--TEST--
-Cloning datefmt
+Cloning datefmt icu <= 4.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
--FILE--
<?php
include_once( 'ut_common.inc' );
@@ -0,0 +1,37 @@
+--TEST--
+Cloning datefmt icu >= 4.8
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
+--FILE--
+<?php
+include_once( 'ut_common.inc' );
+$GLOBALS['oo-mode'] = true;
+$res_str = '';
+/*
+ * Clone
+ */
+$start_pattern = 'dd-MM-YY';
+$fmt = ut_datefmt_create( "en-US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
+
+$formatted = ut_datefmt_format($fmt,0);
+$res_str .= "\nResult of formatting timestamp=0 is : \n$formatted";
+
+$fmt_clone = clone $fmt;
+ut_datefmt_set_pattern( $fmt , 'yyyy-DDD.hh:mm:ss z' );
+
+$formatted = ut_datefmt_format($fmt,0);
+$res_str .= "\nResult of formatting timestamp=0 is : \n$formatted";
+$formatted = ut_datefmt_format($fmt_clone,0);
+$res_str .= "\nResult of clone formatting timestamp=0 is : \n$formatted";
+
+echo $res_str;
+
+?>
+--EXPECTF--
+Result of formatting timestamp=0 is :
+31-12-70
+Result of formatting timestamp=0 is :
+1969-365.07:00:00 EST
+Result of clone formatting timestamp=0 is :
+31-12-70
@@ -1,7 +1,8 @@
--TEST--
-datefmt_get_pattern_code and datefmt_set_pattern_code()
+datefmt_get_pattern_code and datefmt_set_pattern_code() icu <= 4.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
--FILE--
<?php
@@ -81,4 +82,4 @@ Result of formatting timestamp=0 with the new pattern is :
Setting IntlDateFormatter with pattern = yyyyMMdd
After call to get_pattern : pattern= yyyyMMdd
Result of formatting timestamp=0 with the new pattern is :
-19691231
+19691231
@@ -0,0 +1,85 @@
+--TEST--
+datefmt_get_pattern_code and datefmt_set_pattern_code() icu >= 4.8
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
+--FILE--
+
+<?php
+
+/*
+ * Test for the datefmt_get_pattern & datefmt_set_pattern function
+ */
+
+
+function ut_main()
+{
+ $pattern_arr = array (
+ 'DD-MM-YYYY hh:mm:ss',
+ 'yyyy-DDD.hh:mm:ss z',
+ "yyyy/MM/dd",
+ "yyyyMMdd"
+ );
+
+ $res_str = '';
+
+ $start_pattern = 'dd-MM-YY';
+ $res_str .= "\nCreating IntlDateFormatter with pattern = $start_pattern ";
+ //$fmt = ut_datefmt_create( "en-US", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT , 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
+ $fmt = ut_datefmt_create( "en-US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
+ $pattern = ut_datefmt_get_pattern( $fmt);
+ $res_str .= "\nAfter call to get_pattern : pattern= $pattern";
+ $formatted = ut_datefmt_format($fmt,0);
+ $res_str .= "\nResult of formatting timestamp=0 is : \n$formatted";
+
+
+ foreach( $pattern_arr as $pattern_entry )
+ {
+ $res_str .= "\n-------------------";
+ $res_str .= "\nSetting IntlDateFormatter with pattern = $pattern_entry ";
+ ut_datefmt_set_pattern( $fmt , $pattern_entry );
+ $pattern = ut_datefmt_get_pattern( $fmt);
+ $res_str .= "\nAfter call to get_pattern : pattern= $pattern";
+ $formatted = ut_datefmt_format($fmt,0);
+ $res_str .= "\nResult of formatting timestamp=0 with the new pattern is : \n$formatted";
+ $res_str .= "\n";
+
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+Creating IntlDateFormatter with pattern = dd-MM-YY
+After call to get_pattern : pattern= dd-MM-YY
+Result of formatting timestamp=0 is :
+31-12-70
+-------------------
+Setting IntlDateFormatter with pattern = DD-MM-YYYY hh:mm:ss
+After call to get_pattern : pattern= DD-MM-YYYY hh:mm:ss
+Result of formatting timestamp=0 with the new pattern is :
+365-12-1970 07:00:00
+
+-------------------
+Setting IntlDateFormatter with pattern = yyyy-DDD.hh:mm:ss z
+After call to get_pattern : pattern= yyyy-DDD.hh:mm:ss z
+Result of formatting timestamp=0 with the new pattern is :
+1969-365.07:00:00 EST
+
+-------------------
+Setting IntlDateFormatter with pattern = yyyy/MM/dd
+After call to get_pattern : pattern= yyyy/MM/dd
+Result of formatting timestamp=0 with the new pattern is :
+1969/12/31
+
+-------------------
+Setting IntlDateFormatter with pattern = yyyyMMdd
+After call to get_pattern : pattern= yyyyMMdd
+Result of formatting timestamp=0 with the new pattern is :
+19691231
@@ -1,7 +1,8 @@
--TEST--
-datefmt_localtime_code()
+datefmt_localtime_code() icu <= 4.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
--FILE--
<?php
@@ -1,7 +1,8 @@
--TEST--
-datefmt_parse_code()
+datefmt_parse_code() icu <= 4.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
--INI--
date.timezone="America/Los_Angeles"
--FILE--
@@ -1,7 +1,8 @@
--TEST--
-datefmt_parse_localtime() with parse pos
+datefmt_parse_localtime() with parse pos icu <= 4.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
--FILE--
<?php
@@ -1,7 +1,8 @@
--TEST--
-datefmt_parse_timestamp_code() with parse pos
+datefmt_parse_timestamp_code() with parse pos icu <= 4.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
--INI--
datetime.timezone="America/Los_Angeles"
--ENV--
@@ -1,7 +1,8 @@
--TEST--
-datefmt_set_timezone_id_code()
+datefmt_set_timezone_id_code() icu <= 4.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
--FILE--
<?php
@@ -72,4 +73,4 @@ Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM C
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+00:00
-Formatting timestamp=3600 resulted in Thursday, January 1, 1970 1:00:00 AM GMT+00:00
+Formatting timestamp=3600 resulted in Thursday, January 1, 1970 1:00:00 AM GMT+00:00
Oops, something went wrong.

0 comments on commit bd928f0

Please sign in to comment.