summaryrefslogtreecommitdiff
path: root/ext/intl/tests
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/intl/tests
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/intl/tests')
-rw-r--r--ext/intl/tests/_files/es-bundle.txt21
-rw-r--r--ext/intl/tests/_files/res_index.txt6
-rw-r--r--ext/intl/tests/_files/resourcebundle.txt21
-rw-r--r--ext/intl/tests/_files/resourcebundle/es.resbin0 -> 384 bytes
-rw-r--r--ext/intl/tests/_files/resourcebundle/res_index.resbin0 -> 128 bytes
-rw-r--r--ext/intl/tests/_files/resourcebundle/root.resbin0 -> 388 bytes
-rw-r--r--ext/intl/tests/badargs.phpt25
-rw-r--r--ext/intl/tests/bug12887.phpt29
-rw-r--r--ext/intl/tests/bug14562.phpt28
-rw-r--r--ext/intl/tests/bug48227.phpt21
-rw-r--r--ext/intl/tests/bug50590.phpt13
-rw-r--r--ext/intl/tests/bug53512.phpt25
-rw-r--r--ext/intl/tests/bug55562.phpt13
-rw-r--r--ext/intl/tests/bug59597_32.phpt21
-rw-r--r--ext/intl/tests/bug59597_64.phpt20
-rw-r--r--ext/intl/tests/bug60192-compare.phpt19
-rw-r--r--ext/intl/tests/bug60192-getlocale.phpt20
-rw-r--r--ext/intl/tests/bug60192-getsortkey.phpt20
-rw-r--r--ext/intl/tests/bug60192-sort.phpt21
-rw-r--r--ext/intl/tests/bug60192-sortwithsortkeys.phpt21
-rw-r--r--ext/intl/tests/bug61487.phpt11
-rw-r--r--ext/intl/tests/bug62017.phpt22
-rw-r--r--ext/intl/tests/bug62070.phpt18
-rw-r--r--ext/intl/tests/bug62081.phpt14
-rw-r--r--ext/intl/tests/bug62082.phpt15
-rw-r--r--ext/intl/tests/bug62083.phpt12
-rw-r--r--ext/intl/tests/bug62915-2.phpt33
-rw-r--r--ext/intl/tests/collation_customization.phpt70
-rw-r--r--ext/intl/tests/collator_asort.phpt242
-rw-r--r--ext/intl/tests/collator_compare.phpt134
-rw-r--r--ext/intl/tests/collator_create.phpt82
-rw-r--r--ext/intl/tests/collator_create2.phpt82
-rw-r--r--ext/intl/tests/collator_get_error_code.phpt47
-rw-r--r--ext/intl/tests/collator_get_error_message.phpt36
-rw-r--r--ext/intl/tests/collator_get_locale.phpt51
-rw-r--r--ext/intl/tests/collator_get_locale2.phpt51
-rw-r--r--ext/intl/tests/collator_get_set_attribute.phpt41
-rw-r--r--ext/intl/tests/collator_get_set_strength.phpt41
-rw-r--r--ext/intl/tests/collator_get_sort_key.phpt98
-rw-r--r--ext/intl/tests/collator_sort.phpt247
-rw-r--r--ext/intl/tests/collator_sort_with_sort_keys.phpt189
-rw-r--r--ext/intl/tests/dateformat_calendars.phpt45
-rw-r--r--ext/intl/tests/dateformat_clone.phpt37
-rw-r--r--ext/intl/tests/dateformat_clone2.phpt37
-rw-r--r--ext/intl/tests/dateformat_clone_bad_obj.phpt20
-rw-r--r--ext/intl/tests/dateformat_format.phpt420
-rw-r--r--ext/intl/tests/dateformat_format_parse.phpt294
-rw-r--r--ext/intl/tests/dateformat_get_datetype.phpt57
-rw-r--r--ext/intl/tests/dateformat_get_locale.phpt59
-rw-r--r--ext/intl/tests/dateformat_get_set_calendar.phpt60
-rw-r--r--ext/intl/tests/dateformat_get_set_pattern.phpt85
-rw-r--r--ext/intl/tests/dateformat_get_set_pattern2.phpt85
-rw-r--r--ext/intl/tests/dateformat_get_timetype.phpt57
-rw-r--r--ext/intl/tests/dateformat_get_timezone_id.phpt49
-rw-r--r--ext/intl/tests/dateformat_is_set_lenient.phpt88
-rw-r--r--ext/intl/tests/dateformat_localtime.phpt134
-rw-r--r--ext/intl/tests/dateformat_parse.phpt113
-rw-r--r--ext/intl/tests/dateformat_parse_localtime_parsepos.phpt120
-rw-r--r--ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt157
-rw-r--r--ext/intl/tests/dateformat_set_timezone_id.phpt76
-rw-r--r--ext/intl/tests/dateformat_set_timezone_id2.phpt76
-rw-r--r--ext/intl/tests/formatter_clone.phpt30
-rw-r--r--ext/intl/tests/formatter_clone_bad_obj.phpt20
-rw-r--r--ext/intl/tests/formatter_fail.phpt79
-rw-r--r--ext/intl/tests/formatter_format.phpt130
-rw-r--r--ext/intl/tests/formatter_format2.phpt130
-rw-r--r--ext/intl/tests/formatter_format_conv.phpt24
-rw-r--r--ext/intl/tests/formatter_format_currency.phpt50
-rw-r--r--ext/intl/tests/formatter_format_currency2.phpt50
-rw-r--r--ext/intl/tests/formatter_get_error.phpt31
-rw-r--r--ext/intl/tests/formatter_get_locale.phpt49
-rw-r--r--ext/intl/tests/formatter_get_set_attribute.phpt194
-rw-r--r--ext/intl/tests/formatter_get_set_pattern.phpt52
-rw-r--r--ext/intl/tests/formatter_get_set_symbol.phpt190
-rw-r--r--ext/intl/tests/formatter_get_set_symbol2.phpt190
-rw-r--r--ext/intl/tests/formatter_get_set_text_attribute.phpt121
-rw-r--r--ext/intl/tests/formatter_parse.phpt42
-rw-r--r--ext/intl/tests/formatter_parse_currency.phpt37
-rw-r--r--ext/intl/tests/grapheme.phpt1192
-rw-r--r--ext/intl/tests/idn.phpt18
-rw-r--r--ext/intl/tests/idn_uts46_basic.phpt53
-rw-r--r--ext/intl/tests/idn_uts46_errors.phpt89
-rw-r--r--ext/intl/tests/intl_error_name.phpt25
-rw-r--r--ext/intl/tests/intl_get_error_code.phpt24
-rw-r--r--ext/intl/tests/intl_get_error_message.phpt21
-rw-r--r--ext/intl/tests/intl_icu_data_version_constant.phpt10
-rw-r--r--ext/intl/tests/intl_icu_version_constant.phpt10
-rw-r--r--ext/intl/tests/intl_is_failure.phpt25
-rw-r--r--ext/intl/tests/locale_accept.phpt46
-rw-r--r--ext/intl/tests/locale_compose_locale.phpt189
-rw-r--r--ext/intl/tests/locale_filter_matches.phpt366
-rw-r--r--ext/intl/tests/locale_filter_matches2.phpt366
-rw-r--r--ext/intl/tests/locale_get_all_variants.phpt62
-rw-r--r--ext/intl/tests/locale_get_default.phpt46
-rw-r--r--ext/intl/tests/locale_get_display_language.phpt280
-rw-r--r--ext/intl/tests/locale_get_display_name.phpt342
-rw-r--r--ext/intl/tests/locale_get_display_name2.phpt342
-rw-r--r--ext/intl/tests/locale_get_display_region.phpt275
-rw-r--r--ext/intl/tests/locale_get_display_region2.phpt275
-rw-r--r--ext/intl/tests/locale_get_display_script.phpt275
-rw-r--r--ext/intl/tests/locale_get_display_script2.phpt275
-rw-r--r--ext/intl/tests/locale_get_display_script3.phpt275
-rw-r--r--ext/intl/tests/locale_get_display_variant.phpt275
-rw-r--r--ext/intl/tests/locale_get_display_variant2.phpt275
-rw-r--r--ext/intl/tests/locale_get_keywords.phpt140
-rw-r--r--ext/intl/tests/locale_get_keywords2.phpt151
-rw-r--r--ext/intl/tests/locale_get_primary_language.phpt121
-rw-r--r--ext/intl/tests/locale_get_region.phpt123
-rw-r--r--ext/intl/tests/locale_get_script.phpt122
-rw-r--r--ext/intl/tests/locale_lookup.phpt99
-rw-r--r--ext/intl/tests/locale_parse_locale.phpt203
-rw-r--r--ext/intl/tests/locale_parse_locale2.phpt203
-rw-r--r--ext/intl/tests/locale_set_default.phpt133
-rw-r--r--ext/intl/tests/msgfmt_clone.phpt30
-rw-r--r--ext/intl/tests/msgfmt_clone_bad_obj.phpt20
-rw-r--r--ext/intl/tests/msgfmt_fail.phpt102
-rw-r--r--ext/intl/tests/msgfmt_fail2.phpt102
-rw-r--r--ext/intl/tests/msgfmt_format.phpt70
-rw-r--r--ext/intl/tests/msgfmt_get_error.phpt29
-rw-r--r--ext/intl/tests/msgfmt_get_locale.phpt40
-rw-r--r--ext/intl/tests/msgfmt_get_set_pattern.phpt53
-rw-r--r--ext/intl/tests/msgfmt_parse.phpt114
-rw-r--r--ext/intl/tests/normalizer_normalize.phpt160
-rw-r--r--ext/intl/tests/regression_sort_and_cow.phpt85
-rw-r--r--ext/intl/tests/regression_sort_eq.phpt51
-rw-r--r--ext/intl/tests/regression_sortwsk_and_cow.phpt86
-rw-r--r--ext/intl/tests/regression_sortwsk_eq.phpt51
-rw-r--r--ext/intl/tests/resourcebundle.build33
-rw-r--r--ext/intl/tests/resourcebundle.inc13
-rw-r--r--ext/intl/tests/resourcebundle_arrayaccess.phpt50
-rw-r--r--ext/intl/tests/resourcebundle_create.phpt62
-rw-r--r--ext/intl/tests/resourcebundle_individual.phpt57
-rw-r--r--ext/intl/tests/resourcebundle_internal.phpt19
-rw-r--r--ext/intl/tests/resourcebundle_iterator.phpt73
-rw-r--r--ext/intl/tests/resourcebundle_locales.phpt23
-rw-r--r--ext/intl/tests/resourcebundle_null_mandatory_args.phpt28
-rw-r--r--ext/intl/tests/resourcebundle_traversable.phpt23
-rw-r--r--ext/intl/tests/spoofchecker_001.phpt23
-rw-r--r--ext/intl/tests/spoofchecker_002.phpt20
-rw-r--r--ext/intl/tests/spoofchecker_003.phpt25
-rw-r--r--ext/intl/tests/spoofchecker_004.phpt28
-rw-r--r--ext/intl/tests/symfony_format_type_double_intl1.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_double_intl2.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_double_intl3.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_double_intl4.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_int32_intl1.phpt49
-rw-r--r--ext/intl/tests/symfony_format_type_int32_intl2.phpt33
-rw-r--r--ext/intl/tests/symfony_format_type_int32_intl3.phpt32
-rw-r--r--ext/intl/tests/symfony_format_type_int32_intl4.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_int32_intl5.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_int32_intl6.phpt32
-rw-r--r--ext/intl/tests/symfony_format_type_int32_intl7.phpt32
-rw-r--r--ext/intl/tests/symfony_format_type_int64_intl1.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_int64_intl2.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_int64_intl3.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_int64_intl4.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_int64_intl5.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_int64_intl6.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_int64_intl7.phpt30
-rw-r--r--ext/intl/tests/symfony_format_type_int64_intl8.phpt30
-rw-r--r--ext/intl/tests/transliterator_clone.phpt21
-rw-r--r--ext/intl/tests/transliterator_create_basic.phpt20
-rw-r--r--ext/intl/tests/transliterator_create_error.phpt21
-rw-r--r--ext/intl/tests/transliterator_create_from_rule_basic.phpt28
-rw-r--r--ext/intl/tests/transliterator_create_from_rule_error.phpt53
-rw-r--r--ext/intl/tests/transliterator_create_inverse_basic.phpt32
-rw-r--r--ext/intl/tests/transliterator_create_inverse_error.phpt21
-rw-r--r--ext/intl/tests/transliterator_get_error_code_basic.phpt25
-rw-r--r--ext/intl/tests/transliterator_get_error_code_error.phpt24
-rw-r--r--ext/intl/tests/transliterator_get_error_message_basic.phpt25
-rw-r--r--ext/intl/tests/transliterator_get_error_message_error.phpt24
-rw-r--r--ext/intl/tests/transliterator_list_ids_basic.phpt16
-rw-r--r--ext/intl/tests/transliterator_list_ids_error.phpt18
-rw-r--r--ext/intl/tests/transliterator_property_id.phpt21
-rw-r--r--ext/intl/tests/transliterator_transliterate_basic.phpt20
-rw-r--r--ext/intl/tests/transliterator_transliterate_error.phpt60
-rw-r--r--ext/intl/tests/transliterator_transliterate_variant1.phpt37
-rw-r--r--ext/intl/tests/ut_common.inc416
178 files changed, 15044 insertions, 0 deletions
diff --git a/ext/intl/tests/_files/es-bundle.txt b/ext/intl/tests/_files/es-bundle.txt
new file mode 100644
index 0000000..46399a7
--- /dev/null
+++ b/ext/intl/tests/_files/es-bundle.txt
@@ -0,0 +1,21 @@
+es {
+ teststring:string { "Hola Mundo!" }
+
+ testint:int { 2 }
+
+ testvector:intvector { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }
+
+ testbin:bin { a1b2c3d4e5f67890 }
+
+ testtable:table {
+ major:int { 3 }
+ minor:int { 4 }
+ patch:int { 7 }
+ }
+
+ testarray:array {
+ "cadena 1",
+ "cadena 2",
+ "cadena 3"
+ }
+}
diff --git a/ext/intl/tests/_files/res_index.txt b/ext/intl/tests/_files/res_index.txt
new file mode 100644
index 0000000..a39bea5
--- /dev/null
+++ b/ext/intl/tests/_files/res_index.txt
@@ -0,0 +1,6 @@
+res_index:table(nofallback) {
+ InstalledLocales {
+es {""}
+root {""}
+ }
+} \ No newline at end of file
diff --git a/ext/intl/tests/_files/resourcebundle.txt b/ext/intl/tests/_files/resourcebundle.txt
new file mode 100644
index 0000000..5b081da
--- /dev/null
+++ b/ext/intl/tests/_files/resourcebundle.txt
@@ -0,0 +1,21 @@
+root {
+ teststring:string { "Hello World!" }
+
+ testint:int { 2 }
+
+ testvector:intvector { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }
+
+ testbin:bin { a1b2c3d4e5f67890 }
+
+ testtable:table {
+ major:int { 3 }
+ minor:int { 4 }
+ patch:int { 7 }
+ }
+
+ testarray:array {
+ "string 1",
+ "string 2",
+ "string 3"
+ }
+}
diff --git a/ext/intl/tests/_files/resourcebundle/es.res b/ext/intl/tests/_files/resourcebundle/es.res
new file mode 100644
index 0000000..f9d891d
--- /dev/null
+++ b/ext/intl/tests/_files/resourcebundle/es.res
Binary files differ
diff --git a/ext/intl/tests/_files/resourcebundle/res_index.res b/ext/intl/tests/_files/resourcebundle/res_index.res
new file mode 100644
index 0000000..9dd3df2
--- /dev/null
+++ b/ext/intl/tests/_files/resourcebundle/res_index.res
Binary files differ
diff --git a/ext/intl/tests/_files/resourcebundle/root.res b/ext/intl/tests/_files/resourcebundle/root.res
new file mode 100644
index 0000000..62cb48c
--- /dev/null
+++ b/ext/intl/tests/_files/resourcebundle/root.res
Binary files differ
diff --git a/ext/intl/tests/badargs.phpt b/ext/intl/tests/badargs.phpt
new file mode 100644
index 0000000..9232bbf
--- /dev/null
+++ b/ext/intl/tests/badargs.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Check that bad argumens return the same
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+$funcs = get_extension_funcs("intl");
+function ignore_err() {}
+set_error_handler("ignore_err");
+$arg = new stdClass();
+foreach($funcs as $func) {
+ $rfunc = new ReflectionFunction($func);
+ if($rfunc->getNumberOfRequiredParameters() == 0) {
+ continue;
+ }
+ $res = $func($arg);
+ if($res != false) {
+ echo "$func: ";
+ var_dump($res);
+ }
+}
+echo "OK!\n";
+?>
+--EXPECT--
+OK!
diff --git a/ext/intl/tests/bug12887.phpt b/ext/intl/tests/bug12887.phpt
new file mode 100644
index 0000000..e2fc194
--- /dev/null
+++ b/ext/intl/tests/bug12887.phpt
@@ -0,0 +1,29 @@
+--TEST--
+locale_get_keywords() bug #12887
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+function ut_main()
+{
+ $res_str = '';
+ $keywords_arr = ut_loc_get_keywords( 'de_DE@currency=EUR;collation=PHONEBOOK;sort=PHONEBOOK' );
+ if ($keywords_arr) {
+ foreach( $keywords_arr as $key => $value){
+ $res_str .= "$key = $value\n";
+ }
+ }
+ $res_str .= "\n";
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+collation = PHONEBOOK
+currency = EUR
+sort = PHONEBOOK
diff --git a/ext/intl/tests/bug14562.phpt b/ext/intl/tests/bug14562.phpt
new file mode 100644
index 0000000..3256268
--- /dev/null
+++ b/ext/intl/tests/bug14562.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #14562 NumberFormatter breaks when locale changes
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+function ut_main()
+{
+ $res_str = "";
+ $de_locale="de_DE.UTF-8";
+ $fmt = new NumberFormatter("de", NumberFormatter::DECIMAL );
+ $numeric = $fmt->parse("1234,56");
+ $res_str .= "$numeric\n";
+ setlocale(LC_ALL, $de_locale);
+ $fmt = new NumberFormatter("de", NumberFormatter::DECIMAL );
+ $numeric = $fmt->parse("1234,56");
+ $res_str .= "$numeric\n";
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+1234.56
+1234.56
diff --git a/ext/intl/tests/bug48227.phpt b/ext/intl/tests/bug48227.phpt
new file mode 100644
index 0000000..0ac0d5e
--- /dev/null
+++ b/ext/intl/tests/bug48227.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #48227 (NumberFormatter::format leaks memory)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+$x = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
+var_dump($x->format(''));
+var_dump($x->format(1));
+var_dump($x->format(NULL));
+var_dump($x->format($x));
+
+?>
+--EXPECTF--
+string(1) "0"
+string(1) "1"
+string(1) "0"
+
+Notice: Object of class NumberFormatter could not be converted to int in %s on line %d
+string(1) "1"
diff --git a/ext/intl/tests/bug50590.phpt b/ext/intl/tests/bug50590.phpt
new file mode 100644
index 0000000..c39c333
--- /dev/null
+++ b/ext/intl/tests/bug50590.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #50590 (IntlDateFormatter::parse result is limited to the integer range)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+$fmt = new IntlDateFormatter("en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL);
+var_dump($fmt->parse("Wednesday, January 20, 2038 3:14:07 AM GMT"));
+
+?>
+--EXPECTF--
+%s(2147570047)
diff --git a/ext/intl/tests/bug53512.phpt b/ext/intl/tests/bug53512.phpt
new file mode 100644
index 0000000..a1b1dcf
--- /dev/null
+++ b/ext/intl/tests/bug53512.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #53512 (NumberFormatter::setSymbol crash on bogus $attr values)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+$badvals = array(4294901761, 2147483648, -2147483648, -1);
+
+foreach ($badvals as $val) {
+ $x = numfmt_create("en", NumberFormatter::PATTERN_DECIMAL);
+ var_dump(numfmt_set_symbol($x, $val, ""));
+ var_dump(intl_get_error_message());
+}
+
+?>
+--EXPECTF--
+bool(false)
+string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
+bool(false)
+string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
+bool(false)
+string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
+bool(false)
+string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
diff --git a/ext/intl/tests/bug55562.phpt b/ext/intl/tests/bug55562.phpt
new file mode 100644
index 0000000..dd053c0
--- /dev/null
+++ b/ext/intl/tests/bug55562.phpt
@@ -0,0 +1,13 @@
+--TEST--
+grapheme_substr() - Bug55562 - grapheme_substr() returns false if length parameter is to large
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+var_dump(
+ grapheme_substr('FOK', 1, 20), // expected: OK
+ grapheme_substr('한국어', 1, 20) //expected: 국어
+);
+--EXPECT--
+string(2) "OK"
+string(6) "국어"
diff --git a/ext/intl/tests/bug59597_32.phpt b/ext/intl/tests/bug59597_32.phpt
new file mode 100644
index 0000000..928a235
--- /dev/null
+++ b/ext/intl/tests/bug59597_32.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug#59597 NumberFormatter::parse() with TYPE_INT64 results in a 32 bit integer
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php echo PHP_INT_SIZE == 8 ? "skip 32-bit only" : "OK"; ?>
+--FILE--
+<?php
+
+$formatter = new \NumberFormatter('en', \NumberFormatter::DECIMAL);
+$value = $formatter->parse('2147483647', \NumberFormatter::TYPE_INT32);
+var_dump($value);
+
+$formatter = new \NumberFormatter('en', \NumberFormatter::DECIMAL);
+$value = $formatter->parse('2147483650', \NumberFormatter::TYPE_INT64);
+var_dump($value);
+
+?>
+--EXPECT--
+int(2147483647)
+float(2147483650)
+
diff --git a/ext/intl/tests/bug59597_64.phpt b/ext/intl/tests/bug59597_64.phpt
new file mode 100644
index 0000000..eb70995
--- /dev/null
+++ b/ext/intl/tests/bug59597_64.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug#59597 NumberFormatter::parse() with TYPE_INT64 results in a 32 bit integer
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php echo PHP_INT_SIZE != 8 ? "skip 64-bit only" : "OK"; ?>
+--FILE--
+<?php
+
+$formatter = new \NumberFormatter('en', \NumberFormatter::DECIMAL);
+$value = $formatter->parse('2147483647', \NumberFormatter::TYPE_INT32);
+var_dump($value);
+
+$formatter = new \NumberFormatter('en', \NumberFormatter::DECIMAL);
+$value = $formatter->parse('2147483650', \NumberFormatter::TYPE_INT64);
+var_dump($value);
+
+?>
+--EXPECT--
+int(2147483647)
+int(2147483650)
diff --git a/ext/intl/tests/bug60192-compare.phpt b/ext/intl/tests/bug60192-compare.phpt
new file mode 100644
index 0000000..0fd24cc
--- /dev/null
+++ b/ext/intl/tests/bug60192-compare.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #60192 (SegFault when Collator not constructed properly)
+--SKIPIF--
+<?php
+ if (!extension_loaded('intl')) { die('skip intl extension not available'); }
+?>
+--FILE--
+<?php
+class Collator2 extends Collator{
+ public function __construct() {
+ // ommitting parent::__construct($someLocale);
+ }
+}
+
+$c = new Collator2();
+$a = $c->compare('h', 'H');
+--EXPECTF--
+
+Catchable fatal error: Collator::compare(): Object not initialized in %s on line %d
diff --git a/ext/intl/tests/bug60192-getlocale.phpt b/ext/intl/tests/bug60192-getlocale.phpt
new file mode 100644
index 0000000..50e3ec3
--- /dev/null
+++ b/ext/intl/tests/bug60192-getlocale.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #60192 (SegFault when Collator not constructed properly)
+--SKIPIF--
+<?php
+ if (!extension_loaded('intl')) { die('skip intl extension not available'); }
+?>
+--FILE--
+<?php
+
+class Collator2 extends Collator{
+ public function __construct() {
+ // ommitting parent::__construct($someLocale);
+ }
+}
+
+$c = new Collator2();
+$c->getLocale(Locale::ACTUAL_LOCALE);
+--EXPECTF--
+
+Catchable fatal error: Collator::getLocale(): Object not initialized in %s on line %d
diff --git a/ext/intl/tests/bug60192-getsortkey.phpt b/ext/intl/tests/bug60192-getsortkey.phpt
new file mode 100644
index 0000000..39755ae
--- /dev/null
+++ b/ext/intl/tests/bug60192-getsortkey.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #60192 (SegFault when Collator not constructed properly)
+--SKIPIF--
+<?php
+ if (!extension_loaded('intl')) { die('skip intl extension not available'); }
+?>
+--FILE--
+<?php
+
+class Collator2 extends Collator{
+ public function __construct() {
+ // ommitting parent::__construct($someLocale);
+ }
+}
+
+$c = new Collator2();
+$c->getSortKey('h');
+--EXPECTF--
+
+Catchable fatal error: Collator::getSortKey(): Object not initialized in %s on line %d
diff --git a/ext/intl/tests/bug60192-sort.phpt b/ext/intl/tests/bug60192-sort.phpt
new file mode 100644
index 0000000..5705721
--- /dev/null
+++ b/ext/intl/tests/bug60192-sort.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #60192 (SegFault when Collator not constructed properly)
+--SKIPIF--
+<?php
+ if (!extension_loaded('intl')) { die('skip intl extension not available'); }
+?>
+--FILE--
+<?php
+
+class Collator2 extends Collator{
+ public function __construct() {
+ // ommitting parent::__construct($someLocale);
+ }
+}
+
+$c = new Collator2();
+$a = array('a', 'b');
+$c->sort($a);
+--EXPECTF--
+
+Catchable fatal error: Collator::sort(): Object not initialized in %s on line %d
diff --git a/ext/intl/tests/bug60192-sortwithsortkeys.phpt b/ext/intl/tests/bug60192-sortwithsortkeys.phpt
new file mode 100644
index 0000000..445f4a0
--- /dev/null
+++ b/ext/intl/tests/bug60192-sortwithsortkeys.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #60192 (SegFault when Collator not constructed properly)
+--SKIPIF--
+<?php
+ if (!extension_loaded('intl')) { die('skip intl extension not available'); }
+?>
+--FILE--
+<?php
+
+class Collator2 extends Collator{
+ public function __construct() {
+ // ommitting parent::__construct($someLocale);
+ }
+}
+
+$c = new Collator2();
+$a = array('a', 'b');
+$c->sortWithSortKeys($a);
+--EXPECTF--
+
+Catchable fatal error: Collator::sortWithSortKeys(): Object not initialized in %s on line %d
diff --git a/ext/intl/tests/bug61487.phpt b/ext/intl/tests/bug61487.phpt
new file mode 100644
index 0000000..361debe
--- /dev/null
+++ b/ext/intl/tests/bug61487.phpt
@@ -0,0 +1,11 @@
+--TEST--
+grapheme() str[i]pos limits
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+var_dump(grapheme_stripos(1,1,2147483648));
+var_dump(grapheme_strpos(1,1,2147483648));
+--EXPECT--
+bool(false)
+bool(false)
diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt
new file mode 100644
index 0000000..13c4fe5
--- /dev/null
+++ b/ext/intl/tests/bug62017.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #62017: datefmt_create with incorrectly encoded timezone leaks pattern
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set('intl.error_level', E_WARNING);
+var_dump(
+ datefmt_create('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "\xFF",
+ IntlDateFormatter::GREGORIAN, 'a'));
+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
+NULL
+
+Warning: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d
+NULL
+
diff --git a/ext/intl/tests/bug62070.phpt b/ext/intl/tests/bug62070.phpt
new file mode 100644
index 0000000..3ab0078
--- /dev/null
+++ b/ext/intl/tests/bug62070.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #62070: Collator::getSortKey() returns garbage
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '49') < 0)
+ die('skip ICU >= 49 only');
+--FILE--
+<?php
+$s1 = 'Hello';
+
+$coll = collator_create('en_US');
+$res = collator_get_sort_key($coll, $s1);
+
+echo urlencode($res);
+--EXPECT--
+5%2F%3D%3DC%01%09%01%8F%08
diff --git a/ext/intl/tests/bug62081.phpt b/ext/intl/tests/bug62081.phpt
new file mode 100644
index 0000000..7d9e2ce
--- /dev/null
+++ b/ext/intl/tests/bug62081.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #62081: IntlDateFormatter leaks memory if called twice
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--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));
+--EXPECTF--
+Warning: IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice in %s on line %d
+NULL
diff --git a/ext/intl/tests/bug62082.phpt b/ext/intl/tests/bug62082.phpt
new file mode 100644
index 0000000..e6ca73e
--- /dev/null
+++ b/ext/intl/tests/bug62082.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #62082: Memory corruption in internal get_icu_disp_value_src_php()
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+var_dump(locale_get_display_name(str_repeat("a", 300), null));
+var_dump(locale_get_display_name(str_repeat("a", 512), null));
+var_dump(locale_get_display_name(str_repeat("a", 600), null));
+--EXPECT--
+string(300) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+string(512) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+string(600) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
diff --git a/ext/intl/tests/bug62083.phpt b/ext/intl/tests/bug62083.phpt
new file mode 100644
index 0000000..4baa5c5
--- /dev/null
+++ b/ext/intl/tests/bug62083.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #62083: grapheme_extract() leaks memory
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+$arr1 = array();
+var_dump(grapheme_extract(-1, -1, -1,-1, $arr1));
+--EXPECT--
+bool(false)
diff --git a/ext/intl/tests/bug62915-2.phpt b/ext/intl/tests/bug62915-2.phpt
new file mode 100644
index 0000000..bcb069c
--- /dev/null
+++ b/ext/intl/tests/bug62915-2.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #62915: cloning of several classes is defective
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+class A extends IntlDateFormatter {
+ static $ARGS = array("en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
+ 'America/Los_Angeles', IntlDateFormatter::GREGORIAN);
+}
+class B extends NumberFormatter {
+ static $ARGS = array('de_DE', NumberFormatter::DECIMAL);
+}
+class C extends MessageFormatter {
+ static $ARGS = array("en_US", "foo");
+}
+class D extends Spoofchecker {
+ static $ARGS = array();
+}
+
+foreach (range('A', 'D') as $subclass) {
+ $rc = new ReflectionClass($subclass);
+ $obj = $rc->newInstanceArgs($subclass::$ARGS);
+ $clone = clone $obj;
+ var_dump(get_class($clone));
+}
+--EXPECT--
+string(1) "A"
+string(1) "B"
+string(1) "C"
+string(1) "D"
diff --git a/ext/intl/tests/collation_customization.phpt b/ext/intl/tests/collation_customization.phpt
new file mode 100644
index 0000000..e380380
--- /dev/null
+++ b/ext/intl/tests/collation_customization.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Collation customization
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Check effects of changing misc collattion options.
+ */
+
+
+function cmp_array( &$coll, $a )
+{
+ $res = '';
+ $prev = null;
+ foreach( $a as $i )
+ {
+ if( is_null( $prev ) )
+ $res .= "$i";
+ else
+ {
+ $eqrc = ut_coll_compare( $coll, $prev, $i );
+ $eq = $eqrc < 0 ? "<" : ( $eqrc > 0 ? ">" : "=" );
+ $res .= " $eq $i";
+ }
+
+ $prev = $i;
+ }
+ $res .= "\n";
+
+ return $res;
+}
+
+function check_alternate_handling( &$coll )
+{
+ $res = '';
+
+ ut_coll_set_strength( $coll, Collator::TERTIARY );
+ ut_coll_set_attribute( $coll, Collator::ALTERNATE_HANDLING, Collator::NON_IGNORABLE );
+
+ $res .= cmp_array( $coll, array( 'di Silva', 'Di Silva', 'diSilva', 'U.S.A.', 'USA' ) );
+
+ ut_coll_set_attribute( $coll, Collator::ALTERNATE_HANDLING, Collator::SHIFTED );
+
+ $res .= cmp_array( $coll, array( 'di Silva', 'diSilva', 'Di Silva', 'U.S.A.', 'USA' ) );
+
+ ut_coll_set_strength( $coll, Collator::QUATERNARY );
+
+ $res .= cmp_array( $coll, array( 'di Silva', 'diSilva', 'Di Silva', 'U.S.A.', 'USA' ) );
+ $res .= "\n";
+
+ return $res;
+}
+
+function ut_main()
+{
+ $coll = ut_coll_create( 'en_US' );
+
+ return
+ check_alternate_handling( $coll );
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+di Silva < Di Silva < diSilva < U.S.A. < USA
+di Silva = diSilva < Di Silva < U.S.A. = USA
+di Silva < diSilva < Di Silva < U.S.A. < USA
diff --git a/ext/intl/tests/collator_asort.phpt b/ext/intl/tests/collator_asort.phpt
new file mode 100644
index 0000000..a614ddc
--- /dev/null
+++ b/ext/intl/tests/collator_asort.phpt
@@ -0,0 +1,242 @@
+--TEST--
+asort()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Sort associative arrays using various locales.
+ */
+
+
+$test_num = 1;
+
+/*
+ * Sort various arrays in specified locale.
+ */
+function sort_arrays( $locale, $test_arrays, $sort_flag = Collator::SORT_REGULAR )
+{
+ $res_str = '';
+
+ $coll = ut_coll_create( $locale );
+
+ foreach( $test_arrays as $test_array )
+ {
+ // Try to sort test data.
+ $res_val = ut_coll_asort( $coll, $test_array, $sort_flag );
+
+ // Return output data.
+ $res_dump = "\n" . dump( $test_array ) .
+ "\n Result: " . dump( $res_val );
+
+ // Preppend test signature to output string
+ $md5 = md5( $res_dump );
+
+ global $test_num;
+
+ $res_str .= "\n\n".
+ "Test $test_num.$md5:" .
+ $res_dump;
+ ++$test_num;
+ }
+
+ return $res_str;
+}
+
+/*
+ * Test main function.
+ */
+function ut_main()
+{
+ global $test_num;
+ $test_num = 1;
+ $res_str = '';
+
+ // Sort an array in SORT_REGULAR mode using en_US locale.
+ $test_params = array(
+ array( 'd' => 'y' ,
+ 'c' => 'i' ,
+ 'a' => 'k' ),
+
+ array( 'a' => 'a' ,
+ 'b' => 'aaa',
+ 'c' => 'aa' ),
+
+ array( 'a' => 'a' ,
+ 'aaa'=> 'a' ,
+ 'aa' => 'a' ),
+
+ array( '1' => 'abc',
+ '5' => '!' ,
+ '2' => null ,
+ '7' => '' ),
+
+ array( '1' => '100',
+ '2' => '25' ,
+ '3' => '36' ),
+
+ array( '1' => 5 ,
+ '2' => '30' ,
+ '3' => 2 )
+ );
+
+ $res_str .= sort_arrays( 'en_US', $test_params );
+
+ // Sort an array in SORT_STRING mode using en_US locale.
+ $test_params = array(
+ array( '1' => '100',
+ '2' => '25' ,
+ '3' => '36' ),
+
+ array( '1' => 5 ,
+ '2' => '30' ,
+ '3' => 2 ),
+
+ array( '1' => 'd' ,
+ '2' => '' ,
+ '3' => ' a' ),
+
+ array( '1' => 'y' ,
+ '2' => 'k' ,
+ '3' => 'i' )
+ );
+
+ $res_str .= sort_arrays( 'en_US', $test_params, Collator::SORT_STRING );
+
+ // Sort a non-ASCII array using ru_RU locale.
+ $test_params = array(
+ array( 'п' => 'у',
+ 'б' => 'в',
+ 'е' => 'а' ),
+
+ array( '1' => 'п',
+ '4' => '',
+ '7' => 'd',
+ '2' => 'пп' )
+ );
+
+ $res_str .= sort_arrays( 'ru_RU', $test_params );
+
+
+ // Sort an array using Lithuanian locale.
+ $test_params = array(
+ array( 'd' => 'y',
+ 'c' => 'i',
+ 'a' => 'k' )
+ );
+
+ $res_str .= sort_arrays( 'lt_LT', $test_params );
+
+ return $res_str . "\n";
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+Test 1.162b81ac12878b817fc39063097e45b5:
+array (
+ 'c' => 'i',
+ 'a' => 'k',
+ 'd' => 'y',
+)
+ Result: true
+
+Test 2.93d96e22f692d8a281b0a389f01f8d1e:
+array (
+ 'a' => 'a',
+ 'c' => 'aa',
+ 'b' => 'aaa',
+)
+ Result: true
+
+Test 3.9f25de4482bc7b58de508e278113317c:
+array (
+ 'aa' => 'a',
+ 'aaa' => 'a',
+ 'a' => 'a',
+)
+ Result: true
+
+Test 4.a85a41ea78e45b651080cfd98c0b431d:
+array (
+ 7 => '',
+ 2 => NULL,
+ 5 => '!',
+ 1 => 'abc',
+)
+ Result: true
+
+Test 5.99dc71f405b286e03d489061b36e6900:
+array (
+ 2 => '25',
+ 3 => '36',
+ 1 => '100',
+)
+ Result: true
+
+Test 6.bf5bba243307c9d12934e756ad4be190:
+array (
+ 3 => 2,
+ 1 => 5,
+ 2 => '30',
+)
+ Result: true
+
+Test 7.e4ee7024c61476e9e7a6c28b5e47df6f:
+array (
+ 1 => '100',
+ 2 => '25',
+ 3 => '36',
+)
+ Result: true
+
+Test 8.5fa7033dd43784be0db1474eb48b83c8:
+array (
+ 3 => 2,
+ 2 => '30',
+ 1 => 5,
+)
+ Result: true
+
+Test 9.588cdf4692bc09aa92ffe7e48f9e4579:
+array (
+ 2 => '',
+ 3 => ' a',
+ 1 => 'd',
+)
+ Result: true
+
+Test 10.be02641a47ebcccd23e4183ca3a415f7:
+array (
+ 3 => 'i',
+ 2 => 'k',
+ 1 => 'y',
+)
+ Result: true
+
+Test 11.153d9b11d1e5936afc917a94a4e11f34:
+array (
+ 'е' => 'а',
+ 'б' => 'в',
+ 'п' => 'у',
+)
+ Result: true
+
+Test 12.6eaea3fa21b3b7d006ca7dfa27d4e282:
+array (
+ 4 => '',
+ 7 => 'd',
+ 1 => 'п',
+ 2 => 'пп',
+)
+ Result: true
+
+Test 13.8800d48abb960a59002eef77f1d73ae0:
+array (
+ 'c' => 'i',
+ 'd' => 'y',
+ 'a' => 'k',
+)
+ Result: true
diff --git a/ext/intl/tests/collator_compare.phpt b/ext/intl/tests/collator_compare.phpt
new file mode 100644
index 0000000..f10b570
--- /dev/null
+++ b/ext/intl/tests/collator_compare.phpt
@@ -0,0 +1,134 @@
+--TEST--
+compare()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Compare various string pairs using various locales.
+ */
+
+
+/*
+ * Converts comparison result to a character.
+ */
+function cmp_to_char( $comp_res )
+{
+ switch( $comp_res )
+ {
+ case 0: // UCOL_EQUAL
+ return '=';
+ case 1: // UCOL_GREATER
+ return '>';
+ case -1: // UCOL_LESS
+ return '<';
+ default:
+ return '?';
+ }
+}
+
+/*
+ * Compare string pairs in the given array
+ * using specified locale.
+ */
+function compare_pairs( $locale, $test_array )
+{
+ $res_str = '';
+
+ $coll = ut_coll_create( $locale );
+
+ foreach( $test_array as $test_strings )
+ {
+ list( $str1, $str2 ) = $test_strings;
+
+ // Compare strings.
+ $res_val = cmp_to_char( ut_coll_compare( $coll, $str1, $str2 ) );
+
+ // Concatenate result strings.
+ $res_str .= dump( $str1 ) .
+ ' ' . $res_val . ' ' .
+ dump( $str2 ) . "\n";
+ }
+
+ return $res_str;
+
+}
+
+function ut_main()
+{
+ $res_str = '';
+
+ // Compare strings using en_US locale.
+ $test_params = array(
+ array( 'abc', 'abc' ),
+ array( 'Abc', 'abc' ),
+ array( 'a' , 'abc' ),
+ array( 'a' , '' ),
+ array( '' , '' ),
+ array( 'a' , 'b' ),
+ array( 'ab' , 'b' ),
+ array( 'ab' , 'a' ),
+ array( 123 , 'abc' ),
+ array( 'ac' , null ),
+ array( '.' , '.' ),
+ // Try to compare long strings.
+ array( 'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde',
+ 'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdea'),
+ array( null , null )
+ );
+
+ $res_str .= compare_pairs( 'en_US', $test_params );
+
+
+ // Compare strings using ru_RU locale.
+ $test_params = array(
+ array( 'а', 'б' ),
+ array( 'а', 'аа' ),
+ array( 'аб', 'ба' ),
+ array( 'а', ',' ),
+ array( 'а', 'b' ),
+ array( 'а', 'bb' ),
+ array( 'а', 'ab' ),
+ array( 'а', null )
+ );
+
+ $res_str .= compare_pairs( 'ru_RU', $test_params );
+
+
+ // Compare strings using lt_LT locale.
+ $test_params = array(
+ array( 'y', 'k' )
+ );
+
+ $res_str .= compare_pairs( 'lt_LT', $test_params );
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+'abc' = 'abc'
+'Abc' > 'abc'
+'a' < 'abc'
+'a' > ''
+'' = ''
+'a' < 'b'
+'ab' < 'b'
+'ab' > 'a'
+123 < 'abc'
+'ac' > NULL
+'.' = '.'
+'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde' < 'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdea'
+NULL = NULL
+'а' < 'б'
+'а' < 'аа'
+'аб' < 'ба'
+'а' > ','
+'а' > 'b'
+'а' > 'bb'
+'а' > 'ab'
+'а' > NULL
+'y' < 'k'
diff --git a/ext/intl/tests/collator_create.phpt b/ext/intl/tests/collator_create.phpt
new file mode 100644
index 0000000..eed8cf1
--- /dev/null
+++ b/ext/intl/tests/collator_create.phpt
@@ -0,0 +1,82 @@
+--TEST--
+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
+
+/*
+ * 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 = 'en'
+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
diff --git a/ext/intl/tests/collator_create2.phpt b/ext/intl/tests/collator_create2.phpt
new file mode 100644
index 0000000..90d71b0
--- /dev/null
+++ b/ext/intl/tests/collator_create2.phpt
@@ -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
diff --git a/ext/intl/tests/collator_get_error_code.phpt b/ext/intl/tests/collator_get_error_code.phpt
new file mode 100644
index 0000000..45a8e71
--- /dev/null
+++ b/ext/intl/tests/collator_get_error_code.phpt
@@ -0,0 +1,47 @@
+--TEST--
+get_error_code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Retreive error code.
+ */
+
+
+/*
+ * Check if error code equals to expected one.
+ */
+function check_rc( $rc, $expected )
+{
+ return ( $rc === $expected ? "ok" : "failed" ) . "\n";
+}
+
+function ut_main()
+{
+ $res = '';
+ $coll = ut_coll_create( 'ru_RU' );
+
+ // Try specifying a correct attribute.
+ ut_coll_get_attribute( $coll, Collator::NORMALIZATION_MODE );
+ $status = ut_coll_get_error_code( $coll );
+ $res .= check_rc( $status, U_ZERO_ERROR );
+
+ // Try specifying an incorrect attribute.
+ ut_coll_get_attribute( $coll, 12345 );
+ $status = ut_coll_get_error_code( $coll );
+ $res .= check_rc( $status, U_ILLEGAL_ARGUMENT_ERROR );
+
+ return $res;
+}
+
+# Suppress warning messages.
+error_reporting( E_ERROR );
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+ok
+ok
diff --git a/ext/intl/tests/collator_get_error_message.phpt b/ext/intl/tests/collator_get_error_message.phpt
new file mode 100644
index 0000000..af4b9c3
--- /dev/null
+++ b/ext/intl/tests/collator_get_error_message.phpt
@@ -0,0 +1,36 @@
+--TEST--
+get_error_message()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Retreive error message.
+ */
+
+
+function ut_main()
+{
+ $res = '';
+ $coll = ut_coll_create( 'ru_RU' );
+
+ // Try specifying a correct attribute.
+ ut_coll_get_attribute( $coll, Collator::NORMALIZATION_MODE );
+ $status = ut_coll_get_error_message( $coll );
+ $res .= $status . "\n";
+
+ // Try specifying an incorrect attribute.
+ ut_coll_get_attribute( $coll, 12345 );
+ $status = ut_coll_get_error_message( $coll );
+ $res .= $status . "\n";
+
+ return $res;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+U_ZERO_ERROR
+Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR
diff --git a/ext/intl/tests/collator_get_locale.phpt b/ext/intl/tests/collator_get_locale.phpt
new file mode 100644
index 0000000..68440f3
--- /dev/null
+++ b/ext/intl/tests/collator_get_locale.phpt
@@ -0,0 +1,51 @@
+--TEST--
+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
+
+/*
+ * 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 'en'
+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'
diff --git a/ext/intl/tests/collator_get_locale2.phpt b/ext/intl/tests/collator_get_locale2.phpt
new file mode 100644
index 0000000..798c792
--- /dev/null
+++ b/ext/intl/tests/collator_get_locale2.phpt
@@ -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'
diff --git a/ext/intl/tests/collator_get_set_attribute.phpt b/ext/intl/tests/collator_get_set_attribute.phpt
new file mode 100644
index 0000000..b234790
--- /dev/null
+++ b/ext/intl/tests/collator_get_set_attribute.phpt
@@ -0,0 +1,41 @@
+--TEST--
+get/set_attribute()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try to set/get a collation attribute.
+ */
+
+
+/*
+ * Return current normalication mode.
+ */
+function check_val( $coll )
+{
+ $val = ut_coll_get_attribute( $coll, Collator::NORMALIZATION_MODE );
+ return sprintf( "%s\n", ( $val == Collator::OFF ? "off" : "on" ) );
+}
+
+function ut_main()
+{
+ $res = '';
+ $coll = ut_coll_create( 'en_US' );
+
+ ut_coll_set_attribute( $coll, Collator::NORMALIZATION_MODE, Collator::OFF );
+ $res .= check_val( $coll );
+
+ ut_coll_set_attribute( $coll, Collator::NORMALIZATION_MODE, Collator::ON );
+ $res .= check_val( $coll );
+
+ return $res;
+}
+
+include( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+off
+on
diff --git a/ext/intl/tests/collator_get_set_strength.phpt b/ext/intl/tests/collator_get_set_strength.phpt
new file mode 100644
index 0000000..1f77944
--- /dev/null
+++ b/ext/intl/tests/collator_get_set_strength.phpt
@@ -0,0 +1,41 @@
+--TEST--
+get/set_strength()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try to set/get collation strength.
+ */
+
+/*
+ * Set given collation strength, then get it back
+ * and check if it's the same.
+ */
+function check_set_strength( $coll, $val )
+{
+ ut_coll_set_strength( $coll, $val );
+ $new_val = ut_coll_get_strength( $coll );
+ return ( $new_val == $val ? "ok" : "failed" ) . "\n";
+}
+
+function ut_main()
+{
+ $res = '';
+ $coll = ut_coll_create( 'en_US' );
+
+ $res .= check_set_strength( $coll, Collator::PRIMARY );
+ $res .= check_set_strength( $coll, Collator::SECONDARY );
+ $res .= check_set_strength( $coll, Collator::TERTIARY );
+
+ return $res;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+ok
+ok
+ok
diff --git a/ext/intl/tests/collator_get_sort_key.phpt b/ext/intl/tests/collator_get_sort_key.phpt
new file mode 100644
index 0000000..a9c4d71
--- /dev/null
+++ b/ext/intl/tests/collator_get_sort_key.phpt
@@ -0,0 +1,98 @@
+--TEST--
+collator_get_sort_key()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip ICU >= 4.8 only'; ?>
+--FILE--
+<?php
+
+/*
+ * Get sort keys using various locales
+ */
+function sort_arrays( $locale, $data )
+{
+ $res_str = '';
+
+ $coll = ut_coll_create( $locale );
+
+ foreach($data as $value) {
+ $res_val = ut_coll_get_sort_key( $coll, $value );
+ $res_str .= "source: ".$value."\n".
+ "key: ".bin2hex($res_val)."\n";
+ }
+
+ return $res_str;
+}
+
+
+function ut_main()
+{
+ $res_str = '';
+
+ // Regular strings keys
+ $test_params = array(
+ 'abc', 'abd', 'aaa',
+ 'аа', 'а', 'z',
+ '', null , '3',
+ 'y' , 'i' , 'k'
+ );
+
+ $res_str .= sort_arrays( 'en_US', $test_params );
+
+ // Sort a non-ASCII array using ru_RU locale.
+ $test_params = array(
+ 'абг', 'абв', 'жжж', 'эюя'
+ );
+
+ $res_str .= sort_arrays( 'ru_RU', $test_params );
+
+ // Sort an array using Lithuanian locale.
+ $res_str .= sort_arrays( 'lt_LT', $test_params );
+
+ return $res_str . "\n";
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+source: abc
+key: 27292b01070107
+source: abd
+key: 27292d01070107
+source: aaa
+key: 27272701070107
+source: аа
+key: 5c0a0a01060106
+source: а
+key: 5c0a01050105
+source: z
+key: 5901050105
+source:
+key: 0101
+source:
+key: 0101
+source: 3
+key: 1801050105
+source: y
+key: 5701050105
+source: i
+key: 3701050105
+source: k
+key: 3b01050105
+source: абг
+key: 5c0a161a01070107
+source: абв
+key: 5c0a161801070107
+source: жжж
+key: 5c3a3a3a01070107
+source: эюя
+key: 5d3b3f4501070107
+source: абг
+key: 5c0a161a01070107
+source: абв
+key: 5c0a161801070107
+source: жжж
+key: 5c3a3a3a01070107
+source: эюя
+key: 5d3b3f4501070107 \ No newline at end of file
diff --git a/ext/intl/tests/collator_sort.phpt b/ext/intl/tests/collator_sort.phpt
new file mode 100644
index 0000000..5cefe2f
--- /dev/null
+++ b/ext/intl/tests/collator_sort.phpt
@@ -0,0 +1,247 @@
+--TEST--
+sort()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Sort arrays using various locales.
+ */
+
+
+$test_num = 1;
+
+/*
+ * Sort arrays in the given list using specified locale.
+ */
+function sort_arrays( $locale, $arrays, $sort_flag = Collator::SORT_REGULAR )
+{
+ $res_str = '';
+
+ $coll = ut_coll_create( $locale );
+
+ foreach( $arrays as $array )
+ {
+ // Sort array values
+ $res_val = ut_coll_sort( $coll, $array, $sort_flag );
+
+ // Concatenate the sorted array and function result
+ // with output string.
+ $res_dump = "\n" . dump( $array ) .
+ "\n Result: " . dump( $res_val );
+
+ // Preppend test signature to output string
+ $md5 = md5( $res_dump );
+
+ global $test_num;
+
+ $res_str .= "\n\n".
+ "Test $test_num.$md5:" .
+ $res_dump;
+ ++$test_num;
+ }
+
+ return $res_str;
+}
+
+function ut_main()
+{
+ global $test_num;
+ $test_num = 1;
+ $res_str = '';
+
+ // Sort an array in SORT_REGULAR mode using en_US locale.
+ $test_params = array(
+ array( 'abc', 'abd', 'aaa' ),
+ array( 'm' , '1' , '_' ),
+ array( 'a' , 'aaa', 'aa' ),
+ array( 'ba' , 'b' , 'ab' ),
+ array( 'e' , 'c' , 'a' ),
+ array( '100', '25' , '36' ),
+ array( 5 , '30' , 2 ),
+ array( 'd' , '' , ' a' ),
+ array( 'd ' , 'f ' , ' a' ),
+ array( 'a' , null , '3' ),
+ array( 'y' , 'k' , 'i' )
+ );
+
+ $res_str .= sort_arrays( 'en_US', $test_params );
+
+ $test_params = array(
+ array( '100', '25' , '36' ),
+ array( 5 , '30' , 2 ),
+ array( 'd' , '' , ' a' ),
+ array( 'y' , 'k' , 'i' )
+ );
+
+ // Sort in en_US locale with SORT_STRING flag
+ $res_str .= sort_arrays( 'en_US', $test_params, Collator::SORT_STRING );
+
+
+ // Sort a non-ASCII array using ru_RU locale.
+ $test_params = array(
+ array( 'абг', 'абв', 'ааа', 'abc' ),
+ array( 'аа', 'ааа' , 'а' )
+ );
+
+ $res_str .= sort_arrays( 'ru_RU', $test_params );
+
+ // Sort an array using Lithuanian locale.
+ $test_params = array(
+ array( 'y' , 'k' , 'i' )
+ );
+
+ $res_str .= sort_arrays( 'lt_LT', $test_params );
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+Test 1.e8f1cd28133d79ecd660002f1c660d0e:
+array (
+ 0 => 'aaa',
+ 1 => 'abc',
+ 2 => 'abd',
+)
+ Result: true
+
+Test 2.c2ded12173dd2996927378cae37eb275:
+array (
+ 0 => '_',
+ 1 => '1',
+ 2 => 'm',
+)
+ Result: true
+
+Test 3.54071c968d71cb98c5d379145f8d7d38:
+array (
+ 0 => 'a',
+ 1 => 'aa',
+ 2 => 'aaa',
+)
+ Result: true
+
+Test 4.19abe63d6f6dfef65b0e3c9ab4826b07:
+array (
+ 0 => 'ab',
+ 1 => 'b',
+ 2 => 'ba',
+)
+ Result: true
+
+Test 5.9a8dc0a9bc771368c2f1fc3d02754610:
+array (
+ 0 => 'a',
+ 1 => 'c',
+ 2 => 'e',
+)
+ Result: true
+
+Test 6.ab530b060e5e54a65bfb8b9f8fc61870:
+array (
+ 0 => '25',
+ 1 => '36',
+ 2 => '100',
+)
+ Result: true
+
+Test 7.0718dd838509017bded2ed307a6e785f:
+array (
+ 0 => 2,
+ 1 => 5,
+ 2 => '30',
+)
+ Result: true
+
+Test 8.923d65739c5219c634616ffd100a50e4:
+array (
+ 0 => '',
+ 1 => ' a',
+ 2 => 'd',
+)
+ Result: true
+
+Test 9.289bc2f28e87d3201ec9d7e8477ae1b0:
+array (
+ 0 => ' a',
+ 1 => 'd ',
+ 2 => 'f ',
+)
+ Result: true
+
+Test 10.de0fd958484f2377a645835d7fbcf124:
+array (
+ 0 => NULL,
+ 1 => '3',
+ 2 => 'a',
+)
+ Result: true
+
+Test 11.dd2b8f0adb37c45d528cad1a0cc0f361:
+array (
+ 0 => 'i',
+ 1 => 'k',
+ 2 => 'y',
+)
+ Result: true
+
+Test 12.1e6b4d6f7df9d4580317634ea46d8208:
+array (
+ 0 => '100',
+ 1 => '25',
+ 2 => '36',
+)
+ Result: true
+
+Test 13.cec115dc9850b98dfbdf102efa09e61b:
+array (
+ 0 => 2,
+ 1 => '30',
+ 2 => 5,
+)
+ Result: true
+
+Test 14.923d65739c5219c634616ffd100a50e4:
+array (
+ 0 => '',
+ 1 => ' a',
+ 2 => 'd',
+)
+ Result: true
+
+Test 15.dd2b8f0adb37c45d528cad1a0cc0f361:
+array (
+ 0 => 'i',
+ 1 => 'k',
+ 2 => 'y',
+)
+ Result: true
+
+Test 16.ca0e38a2e3147dd97070f2128f140934:
+array (
+ 0 => 'abc',
+ 1 => 'ааа',
+ 2 => 'абв',
+ 3 => 'абг',
+)
+ Result: true
+
+Test 17.91480b10473a0c96a4cd6d88c23c577a:
+array (
+ 0 => 'а',
+ 1 => 'аа',
+ 2 => 'ааа',
+)
+ Result: true
+
+Test 18.fdd3fe3981476039164aa000bf9177f2:
+array (
+ 0 => 'i',
+ 1 => 'y',
+ 2 => 'k',
+)
+ Result: true
diff --git a/ext/intl/tests/collator_sort_with_sort_keys.phpt b/ext/intl/tests/collator_sort_with_sort_keys.phpt
new file mode 100644
index 0000000..2f489d7
--- /dev/null
+++ b/ext/intl/tests/collator_sort_with_sort_keys.phpt
@@ -0,0 +1,189 @@
+--TEST--
+sort_with_sort_keys()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Sort arrays using various locales.
+ */
+
+
+$test_num = 1;
+
+/*
+ * Sort arrays in the given list using specified locale.
+ */
+function sort_arrays( $locale, $arrays )
+{
+ $res_str = '';
+
+ $coll = ut_coll_create( $locale );
+
+ foreach( $arrays as $array )
+ {
+ // Sort array values
+ $res_val = ut_coll_sort_with_sort_keys( $coll, $array );
+
+ // Concatenate the sorted array and function result
+ // with output string.
+ $res_dump = "\n" . dump( $array ) .
+ "\n Result: " . dump( $res_val );
+
+
+ // Preppend test signature to output string
+ $md5 = md5( $res_dump );
+
+ global $test_num;
+
+ $res_str .= "\n\n".
+ "Test $test_num.$md5:" .
+ $res_dump;
+ ++$test_num;
+ }
+
+ return $res_str;
+}
+
+
+function ut_main()
+{
+ global $test_num;
+ $test_num = 1;
+ $res_str = '';
+
+ // Sort an array in SORT_REGULAR mode using en_US locale.
+ $test_params = array(
+ array( 'abc', 'abd', 'aaa' ),
+ array( 'm' , '1' , '_' ),
+ array( 'a' , 'aaa', 'aa' ),
+ array( 'ba' , 'b' , 'ab' ),
+ array( 'e' , 'c' , 'a' ),
+ array( 'd' , '' , ' a' ),
+ array( 'd ' , 'f ' , ' a' ),
+ array( 'a' , null , '3' ),
+ array( 'y' , 'i' , 'k' )
+ );
+
+ $res_str .= sort_arrays( 'en_US', $test_params );
+
+ // Sort a non-ASCII array using ru_RU locale.
+ $test_params = array(
+ array( 'абг', 'абв', 'ааа', 'abc' ),
+ array( 'аа', 'ааа', 'а' )
+ );
+
+ $res_str .= sort_arrays( 'ru_RU', $test_params );
+
+ // Array with data for sorting.
+ $test_params = array(
+ array( 'y' , 'i' , 'k' )
+ );
+
+ // Sort an array using Lithuanian locale.
+ $res_str .= sort_arrays( 'lt_LT', $test_params );
+
+ return $res_str . "\n";
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+Test 1.e8f1cd28133d79ecd660002f1c660d0e:
+array (
+ 0 => 'aaa',
+ 1 => 'abc',
+ 2 => 'abd',
+)
+ Result: true
+
+Test 2.c2ded12173dd2996927378cae37eb275:
+array (
+ 0 => '_',
+ 1 => '1',
+ 2 => 'm',
+)
+ Result: true
+
+Test 3.54071c968d71cb98c5d379145f8d7d38:
+array (
+ 0 => 'a',
+ 1 => 'aa',
+ 2 => 'aaa',
+)
+ Result: true
+
+Test 4.19abe63d6f6dfef65b0e3c9ab4826b07:
+array (
+ 0 => 'ab',
+ 1 => 'b',
+ 2 => 'ba',
+)
+ Result: true
+
+Test 5.9a8dc0a9bc771368c2f1fc3d02754610:
+array (
+ 0 => 'a',
+ 1 => 'c',
+ 2 => 'e',
+)
+ Result: true
+
+Test 6.923d65739c5219c634616ffd100a50e4:
+array (
+ 0 => '',
+ 1 => ' a',
+ 2 => 'd',
+)
+ Result: true
+
+Test 7.289bc2f28e87d3201ec9d7e8477ae1b0:
+array (
+ 0 => ' a',
+ 1 => 'd ',
+ 2 => 'f ',
+)
+ Result: true
+
+Test 8.de0fd958484f2377a645835d7fbcf124:
+array (
+ 0 => NULL,
+ 1 => '3',
+ 2 => 'a',
+)
+ Result: true
+
+Test 9.dd2b8f0adb37c45d528cad1a0cc0f361:
+array (
+ 0 => 'i',
+ 1 => 'k',
+ 2 => 'y',
+)
+ Result: true
+
+Test 10.ca0e38a2e3147dd97070f2128f140934:
+array (
+ 0 => 'abc',
+ 1 => 'ааа',
+ 2 => 'абв',
+ 3 => 'абг',
+)
+ Result: true
+
+Test 11.91480b10473a0c96a4cd6d88c23c577a:
+array (
+ 0 => 'а',
+ 1 => 'аа',
+ 2 => 'ааа',
+)
+ Result: true
+
+Test 12.fdd3fe3981476039164aa000bf9177f2:
+array (
+ 0 => 'i',
+ 1 => 'y',
+ 2 => 'k',
+)
+ Result: true
diff --git a/ext/intl/tests/dateformat_calendars.phpt b/ext/intl/tests/dateformat_calendars.phpt
new file mode 100644
index 0000000..27f380c
--- /dev/null
+++ b/ext/intl/tests/dateformat_calendars.phpt
@@ -0,0 +1,45 @@
+--TEST--
+IntlDateFormatter, calendars and time zone
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$fmt1 = new IntlDateFormatter('en_US',
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::FULL,
+ 'GMT+05:12',
+ IntlDateFormatter::TRADITIONAL);
+$fmt2 = new IntlDateFormatter('en_US',
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::FULL,
+ 'GMT+05:12',
+ IntlDateFormatter::GREGORIAN);
+$fmt3 = new IntlDateFormatter('en_US@calendar=hebrew',
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::FULL,
+ 'GMT+05:12',
+ IntlDateFormatter::TRADITIONAL);
+var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000')));
+var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000')));
+var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000')));
+
+new IntlDateFormatter('en_US@calendar=hebrew',
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::FULL,
+ 'GMT+05:12',
+ -1);
+?>
+==DONE==
+--EXPECTF--
+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
+==DONE==
diff --git a/ext/intl/tests/dateformat_clone.phpt b/ext/intl/tests/dateformat_clone.phpt
new file mode 100644
index 0000000..f060444
--- /dev/null
+++ b/ext/intl/tests/dateformat_clone.phpt
@@ -0,0 +1,37 @@
+--TEST--
+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' );
+$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-69
+Result of formatting timestamp=0 is :
+1969-365.07:00:00 EST
+Result of clone formatting timestamp=0 is :
+31-12-69
diff --git a/ext/intl/tests/dateformat_clone2.phpt b/ext/intl/tests/dateformat_clone2.phpt
new file mode 100644
index 0000000..c91f4b8
--- /dev/null
+++ b/ext/intl/tests/dateformat_clone2.phpt
@@ -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
diff --git a/ext/intl/tests/dateformat_clone_bad_obj.phpt b/ext/intl/tests/dateformat_clone_bad_obj.phpt
new file mode 100644
index 0000000..5e12b96
--- /dev/null
+++ b/ext/intl/tests/dateformat_clone_bad_obj.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Cloning unconstructed IntlDateFormatter
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+class A extends IntlDateFormatter {
+ function __construct() {}
+}
+
+$a = new A;
+try {
+ $b = clone $a;
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+--EXPECTF--
+string(%s) "Cannot clone unconstructed IntlDateFormatter"
diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt
new file mode 100644
index 0000000..e554819
--- /dev/null
+++ b/ext/intl/tests/dateformat_format.phpt
@@ -0,0 +1,420 @@
+--TEST--
+datefmt_format_code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Test for the datefmt_format function
+ */
+
+
+function ut_main()
+{
+ $timezone = 'GMT-10';
+
+ $locale_arr = array (
+ 'en_US'
+ );
+
+ $datetype_arr = array (
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::MEDIUM,
+ IntlDateFormatter::SHORT,
+ IntlDateFormatter::NONE
+ );
+
+ $res_str = '';
+
+
+ $time_arr = array (
+ 0,
+ -1200000,
+ 1200000,
+ 2200000000.0,
+ -2200000000.0,
+ 90099999,
+ 3600,
+ -3600
+ );
+
+ $localtime_arr1 = array (
+ 'tm_sec' => 24 ,
+ 'tm_min' => 3,
+ 'tm_hour' => 19,
+ 'tm_mday' => 3,
+ 'tm_mon' => 3,
+ 'tm_year' => 105,
+ );
+ $localtime_arr2 = array (
+ 'tm_sec' => 21,
+ 'tm_min' => 5,
+ 'tm_hour' => 7,
+ 'tm_mday' => 13,
+ 'tm_mon' => 4,
+ 'tm_year' => 205,
+ );
+ $localtime_arr3 = array (
+ 'tm_sec' => 11,
+ 'tm_min' => 13,
+ 'tm_hour' => 0,
+ 'tm_mday' => 17,
+ 'tm_mon' => 11,
+ 'tm_year' => -5
+ );
+
+ $localtime_arr = array (
+ $localtime_arr1,
+ $localtime_arr2,
+ $localtime_arr3
+ );
+
+ $d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC"));
+ $d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC"));
+ $d2->setTimezone(new DateTimeZone("PDT"));
+ $dates = array(
+ $d1,
+ $d2,
+ new StdClass(),
+ );
+
+ //Test format with input as a timestamp : integer
+ foreach( $time_arr as $timestamp_entry){
+ $res_str .= "\n------------\n";
+ $res_str .= "\nInput timestamp is : $timestamp_entry";
+ $res_str .= "\n------------\n";
+ foreach( $locale_arr as $locale_entry ){
+ foreach( $datetype_arr as $datetype_entry )
+ {
+ $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry ";
+ $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN);
+ $formatted = ut_datefmt_format( $fmt , $timestamp_entry);
+ $res_str .= "\nFormatted timestamp is : $formatted";
+ }
+ }
+ }
+
+ //Test format with input as a localtime :array
+ foreach( $localtime_arr as $localtime_entry){
+ $res_str .= "\n------------\n";
+ $res_str .= "\nInput localtime is : ";
+ foreach( $localtime_entry as $key => $value){
+ $res_str .= "$key : '$value' , ";
+ }
+
+ $res_str .= "\n------------\n";
+ foreach( $locale_arr as $locale_entry ){
+ foreach( $datetype_arr as $datetype_entry )
+ {
+ $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry ";
+ $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN );
+ $formatted1 = ut_datefmt_format( $fmt , $localtime_entry);
+ if( intl_get_error_code() == U_ZERO_ERROR){
+ $res_str .= "\nFormatted localtime_array is : $formatted1";
+ }else{
+ $res_str .= "\nError while formatting as: '".intl_get_error_message()."'";
+ }
+ }
+ }
+ }
+
+ foreach($dates as $date_entry) {
+ foreach( $locale_arr as $locale_entry ){
+ foreach( $datetype_arr as $datetype_entry ) {
+ $res_str .= "\n------------";
+ $res_str .= "\nDate is: ".var_export($date_entry, true);
+ $res_str .= "\n------------";
+
+ $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN );
+ $formatted1 = ut_datefmt_format( $fmt , $date_entry);
+ if( intl_get_error_code() == U_ZERO_ERROR){
+ $res_str .= "\nFormatted DateTime is : $formatted1";
+ }else{
+ $res_str .= "\nError while formatting as: '".intl_get_error_message()."'";
+ }
+ }
+ }
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+------------
+
+Input timestamp is : 0
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Wednesday, December 31, 1969 2:00:00 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : December 31, 1969 2:00:00 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Dec 31, 1969 2:00:00 PM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted timestamp is : 12/31/69 2:00 PM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted timestamp is : 19691231 02:00 PM
+------------
+
+Input timestamp is : -1200000
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Wednesday, December 17, 1969 4:40:00 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : December 17, 1969 4:40:00 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Dec 17, 1969 4:40:00 PM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted timestamp is : 12/17/69 4:40 PM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted timestamp is : 19691217 04:40 PM
+------------
+
+Input timestamp is : 1200000
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Wednesday, January 14, 1970 11:20:00 AM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : January 14, 1970 11:20:00 AM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Jan 14, 1970 11:20:00 AM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted timestamp is : 1/14/70 11:20 AM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted timestamp is : 19700114 11:20 AM
+------------
+
+Input timestamp is : 2200000000
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Sunday, September 18, 2039 1:06:40 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : September 18, 2039 1:06:40 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Sep 18, 2039 1:06:40 PM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted timestamp is : 9/18/39 1:06 PM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted timestamp is : 20390918 01:06 PM
+------------
+
+Input timestamp is : -2200000000
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Saturday, April 14, 1900 2:53:20 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : April 14, 1900 2:53:20 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Apr 14, 1900 2:53:20 PM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted timestamp is : 4/14/00 2:53 PM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted timestamp is : 19000414 02:53 PM
+------------
+
+Input timestamp is : 90099999
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Wednesday, November 8, 1972 9:46:39 AM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : November 8, 1972 9:46:39 AM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Nov 8, 1972 9:46:39 AM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted timestamp is : 11/8/72 9:46 AM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted timestamp is : 19721108 09:46 AM
+------------
+
+Input timestamp is : 3600
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Wednesday, December 31, 1969 3:00:00 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : December 31, 1969 3:00:00 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Dec 31, 1969 3:00:00 PM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted timestamp is : 12/31/69 3:00 PM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted timestamp is : 19691231 03:00 PM
+------------
+
+Input timestamp is : -3600
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Wednesday, December 31, 1969 1:00:00 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : December 31, 1969 1:00:00 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Dec 31, 1969 1:00:00 PM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted timestamp is : 12/31/69 1:00 PM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted timestamp is : 19691231 01:00 PM
+------------
+
+Input localtime is : tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_mday : '3' , tm_mon : '3' , tm_year : '105' ,
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted localtime_array is : Sunday, April 3, 2005 7:03:24 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted localtime_array is : April 3, 2005 7:03:24 PM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted localtime_array is : Apr 3, 2005 7:03:24 PM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted localtime_array is : 4/3/05 7:03 PM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted localtime_array is : 20050403 07:03 PM
+------------
+
+Input localtime is : tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_mday : '13' , tm_mon : '4' , tm_year : '205' ,
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted localtime_array is : Wednesday, May 13, 2105 7:05:21 AM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted localtime_array is : May 13, 2105 7:05:21 AM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted localtime_array is : May 13, 2105 7:05:21 AM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted localtime_array is : 5/13/05 7:05 AM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted localtime_array is : 21050513 07:05 AM
+------------
+
+Input localtime is : tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_mday : '17' , tm_mon : '11' , tm_year : '-5' ,
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted localtime_array is : Tuesday, December 17, 1895 12:13:11 AM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted localtime_array is : December 17, 1895 12:13:11 AM GMT-10:00
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted localtime_array is : Dec 17, 1895 12:13:11 AM
+IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
+Formatted localtime_array is : 12/17/95 12:13 AM
+IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
+Formatted localtime_array is : 18951217 12:13 AM
+------------
+Date is: DateTime::__set_state(array(
+ 'date' => '2010-01-01 01:02:03',
+ 'timezone_type' => 3,
+ 'timezone' => 'UTC',
+))
+------------
+Formatted DateTime is : Thursday, December 31, 2009 3:02:03 PM GMT-10:00
+------------
+Date is: DateTime::__set_state(array(
+ 'date' => '2010-01-01 01:02:03',
+ 'timezone_type' => 3,
+ 'timezone' => 'UTC',
+))
+------------
+Formatted DateTime is : December 31, 2009 3:02:03 PM GMT-10:00
+------------
+Date is: DateTime::__set_state(array(
+ 'date' => '2010-01-01 01:02:03',
+ 'timezone_type' => 3,
+ 'timezone' => 'UTC',
+))
+------------
+Formatted DateTime is : Dec 31, 2009 3:02:03 PM
+------------
+Date is: DateTime::__set_state(array(
+ 'date' => '2010-01-01 01:02:03',
+ 'timezone_type' => 3,
+ 'timezone' => 'UTC',
+))
+------------
+Formatted DateTime is : 12/31/09 3:02 PM
+------------
+Date is: DateTime::__set_state(array(
+ 'date' => '2010-01-01 01:02:03',
+ 'timezone_type' => 3,
+ 'timezone' => 'UTC',
+))
+------------
+Formatted DateTime is : 20091231 03:02 PM
+------------
+Date is: DateTime::__set_state(array(
+ 'date' => '2000-12-30 19:04:05',
+ 'timezone_type' => 3,
+ 'timezone' => 'America/Los_Angeles',
+))
+------------
+Formatted DateTime is : Saturday, December 30, 2000 5:04:05 PM GMT-10:00
+------------
+Date is: DateTime::__set_state(array(
+ 'date' => '2000-12-30 19:04:05',
+ 'timezone_type' => 3,
+ 'timezone' => 'America/Los_Angeles',
+))
+------------
+Formatted DateTime is : December 30, 2000 5:04:05 PM GMT-10:00
+------------
+Date is: DateTime::__set_state(array(
+ 'date' => '2000-12-30 19:04:05',
+ 'timezone_type' => 3,
+ 'timezone' => 'America/Los_Angeles',
+))
+------------
+Formatted DateTime is : Dec 30, 2000 5:04:05 PM
+------------
+Date is: DateTime::__set_state(array(
+ 'date' => '2000-12-30 19:04:05',
+ 'timezone_type' => 3,
+ 'timezone' => 'America/Los_Angeles',
+))
+------------
+Formatted DateTime is : 12/30/00 5:04 PM
+------------
+Date is: DateTime::__set_state(array(
+ 'date' => '2000-12-30 19:04:05',
+ 'timezone_type' => 3,
+ 'timezone' => 'America/Los_Angeles',
+))
+------------
+Formatted DateTime is : 20001230 05:04 PM
+------------
+Date is: stdClass::__set_state(array(
+))
+------------
+Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR'
+------------
+Date is: stdClass::__set_state(array(
+))
+------------
+Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR'
+------------
+Date is: stdClass::__set_state(array(
+))
+------------
+Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR'
+------------
+Date is: stdClass::__set_state(array(
+))
+------------
+Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR'
+------------
+Date is: stdClass::__set_state(array(
+))
+------------
+Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR'
diff --git a/ext/intl/tests/dateformat_format_parse.phpt b/ext/intl/tests/dateformat_format_parse.phpt
new file mode 100644
index 0000000..bd41d71
--- /dev/null
+++ b/ext/intl/tests/dateformat_format_parse.phpt
@@ -0,0 +1,294 @@
+--TEST--
+datefmt_format_code() and datefmt_parse_code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Test for the datefmt_format function
+ */
+
+
+function ut_main()
+{
+ $timezone = 'GMT+5';
+
+ $locale_arr = array (
+ 'en_US'
+ );
+
+ $datetype_arr = array (
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::MEDIUM
+ );
+
+ $res_str = '';
+
+
+ $time_arr = array (
+ 0,
+ -1200000,
+ 1200000,
+ 2200000000,
+ -2200000000,
+ 90099999,
+ 3600,
+ -3600
+ );
+
+ $localtime_arr1 = array (
+ 'tm_sec' => 24 ,
+ 'tm_min' => 3,
+ 'tm_hour' => 19,
+ 'tm_mday' => 3,
+ 'tm_mon' => 3,
+ 'tm_year' => 105,
+ );
+ $localtime_arr2 = array (
+ 'tm_sec' => 21,
+ 'tm_min' => 5,
+ 'tm_hour' => 7,
+ 'tm_mday' => 13,
+ 'tm_mon' => 7,
+ 'tm_year' => 205,
+ );
+ $localtime_arr3 = array (
+ 'tm_sec' => 11,
+ 'tm_min' => 13,
+ 'tm_hour' => 0,
+ 'tm_mday' => 17,
+ 'tm_mon' => 11,
+ 'tm_year' => -5
+ );
+
+ $localtime_arr = array (
+ $localtime_arr1,
+ $localtime_arr2,
+ $localtime_arr3
+ );
+
+ //Test format and parse with a timestamp : long
+ foreach( $time_arr as $timestamp_entry){
+ $res_str .= "\n------------\n";
+ $res_str .= "\nInput timestamp is : $timestamp_entry";
+ $res_str .= "\n------------\n";
+ foreach( $locale_arr as $locale_entry ){
+ foreach( $datetype_arr as $datetype_entry ) {
+ $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry ";
+ $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone);
+ $formatted = ut_datefmt_format( $fmt , $timestamp_entry);
+ $res_str .= "\nFormatted timestamp is : $formatted";
+ $parsed = ut_datefmt_parse( $fmt , $formatted);
+ if( intl_get_error_code() == U_ZERO_ERROR){
+ $res_str .= "\nParsed timestamp is : $parsed";
+ }else{
+ $res_str .= "\nError while parsing as: '".intl_get_error_message()."'";
+ }
+ }
+ }
+ }
+
+ //Test format and parse with a localtime :array
+ foreach( $localtime_arr as $localtime_entry){
+ $res_str .= "\n------------\n";
+ $res_str .= "\nInput localtime is : ";
+ foreach( $localtime_entry as $key => $value){
+ $res_str .= "$key : '$value' , ";
+ }
+
+ $res_str .= "\n------------\n";
+ foreach( $locale_arr as $locale_entry ){
+ foreach( $datetype_arr as $datetype_entry ) {
+ $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry ";
+ $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone);
+ $formatted1 = ut_datefmt_format( $fmt , $localtime_entry);
+ if( intl_get_error_code() == U_ZERO_ERROR){
+ $res_str .= "\nFormatted localtime_array is : $formatted1";
+ }else{
+ $res_str .= "\nError while formatting as: '".intl_get_error_message()."'";
+ }
+ //Parsing
+ $parsed_arr = ut_datefmt_localtime( $fmt, $formatted1 );
+
+ if( $parsed_arr){
+ $res_str .= "\nParsed array is: ";
+ foreach( $parsed_arr as $key => $value){
+ $res_str .= "$key : '$value' , ";
+ }
+ }
+/*
+ else{
+ //$res_str .= "No values found from LocaleTime parsing.";
+ $res_str .= "\tError : '".intl_get_error_message()."'";
+ }
+*/
+ }
+ }
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+------------
+
+Input timestamp is : 0
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Thursday, January 1, 1970 5:00:00 AM GMT+05:00
+Parsed timestamp is : 0
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : January 1, 1970 5:00:00 AM GMT+05:00
+Parsed timestamp is : 0
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Jan 1, 1970 5:00:00 AM
+Parsed timestamp is : 0
+------------
+
+Input timestamp is : -1200000
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Thursday, December 18, 1969 7:40:00 AM GMT+05:00
+Parsed timestamp is : -1200000
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : December 18, 1969 7:40:00 AM GMT+05:00
+Parsed timestamp is : -1200000
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Dec 18, 1969 7:40:00 AM
+Parsed timestamp is : -1200000
+------------
+
+Input timestamp is : 1200000
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Thursday, January 15, 1970 2:20:00 AM GMT+05:00
+Parsed timestamp is : 1200000
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : January 15, 1970 2:20:00 AM GMT+05:00
+Parsed timestamp is : 1200000
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Jan 15, 1970 2:20:00 AM
+Parsed timestamp is : 1200000
+------------
+
+Input timestamp is : 2200000000
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Monday, September 19, 2039 4:06:40 AM GMT+05:00
+Parsed timestamp is : 2200000000
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : September 19, 2039 4:06:40 AM GMT+05:00
+Parsed timestamp is : 2200000000
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Sep 19, 2039 4:06:40 AM
+Parsed timestamp is : 2200000000
+------------
+
+Input timestamp is : -2200000000
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Sunday, April 15, 1900 5:53:20 AM GMT+05:00
+Parsed timestamp is : -2200000000
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : April 15, 1900 5:53:20 AM GMT+05:00
+Parsed timestamp is : -2200000000
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Apr 15, 1900 5:53:20 AM
+Parsed timestamp is : -2200000000
+------------
+
+Input timestamp is : 90099999
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Thursday, November 9, 1972 12:46:39 AM GMT+05:00
+Parsed timestamp is : 90099999
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : November 9, 1972 12:46:39 AM GMT+05:00
+Parsed timestamp is : 90099999
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Nov 9, 1972 12:46:39 AM
+Parsed timestamp is : 90099999
+------------
+
+Input timestamp is : 3600
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Thursday, January 1, 1970 6:00:00 AM GMT+05:00
+Parsed timestamp is : 3600
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : January 1, 1970 6:00:00 AM GMT+05:00
+Parsed timestamp is : 3600
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Jan 1, 1970 6:00:00 AM
+Parsed timestamp is : 3600
+------------
+
+Input timestamp is : -3600
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted timestamp is : Thursday, January 1, 1970 4:00:00 AM GMT+05:00
+Parsed timestamp is : -3600
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted timestamp is : January 1, 1970 4:00:00 AM GMT+05:00
+Parsed timestamp is : -3600
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted timestamp is : Jan 1, 1970 4:00:00 AM
+Parsed timestamp is : -3600
+------------
+
+Input localtime is : tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_mday : '3' , tm_mon : '3' , tm_year : '105' ,
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted localtime_array is : Sunday, April 3, 2005 7:03:24 PM GMT+05:00
+Parsed array is: tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_year : '105' , tm_mday : '3' , tm_wday : '0' , tm_yday : '93' , tm_mon : '3' , tm_isdst : '0' ,
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted localtime_array is : April 3, 2005 7:03:24 PM GMT+05:00
+Parsed array is: tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_year : '105' , tm_mday : '3' , tm_wday : '0' , tm_yday : '93' , tm_mon : '3' , tm_isdst : '0' ,
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted localtime_array is : Apr 3, 2005 7:03:24 PM
+Parsed array is: tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_year : '105' , tm_mday : '3' , tm_wday : '0' , tm_yday : '93' , tm_mon : '3' , tm_isdst : '0' ,
+------------
+
+Input localtime is : tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_mday : '13' , tm_mon : '7' , tm_year : '205' ,
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted localtime_array is : Thursday, August 13, 2105 7:05:21 AM GMT+05:00
+Parsed array is: tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_year : '205' , tm_mday : '13' , tm_wday : '4' , tm_yday : '225' , tm_mon : '7' , tm_isdst : '0' ,
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted localtime_array is : August 13, 2105 7:05:21 AM GMT+05:00
+Parsed array is: tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_year : '205' , tm_mday : '13' , tm_wday : '4' , tm_yday : '225' , tm_mon : '7' , tm_isdst : '0' ,
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted localtime_array is : Aug 13, 2105 7:05:21 AM
+Parsed array is: tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_year : '205' , tm_mday : '13' , tm_wday : '4' , tm_yday : '225' , tm_mon : '7' , tm_isdst : '0' ,
+------------
+
+Input localtime is : tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_mday : '17' , tm_mon : '11' , tm_year : '-5' ,
+------------
+
+IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
+Formatted localtime_array is : Tuesday, December 17, 1895 12:13:11 AM GMT+05:00
+Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' ,
+IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
+Formatted localtime_array is : December 17, 1895 12:13:11 AM GMT+05:00
+Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' ,
+IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
+Formatted localtime_array is : Dec 17, 1895 12:13:11 AM
+Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' ,
diff --git a/ext/intl/tests/dateformat_get_datetype.phpt b/ext/intl/tests/dateformat_get_datetype.phpt
new file mode 100644
index 0000000..24d0389
--- /dev/null
+++ b/ext/intl/tests/dateformat_get_datetype.phpt
@@ -0,0 +1,57 @@
+--TEST--
+datefmt_get_datetype_code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Test for the datefmt_get_datetype function
+ */
+
+
+function ut_main()
+{
+ $datetype_arr = array (
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::MEDIUM,
+ IntlDateFormatter::SHORT,
+ IntlDateFormatter::NONE
+ );
+
+ $res_str = '';
+
+ foreach( $datetype_arr as $datetype_entry )
+ {
+ $res_str .= "\nCreating IntlDateFormatter with date_type = $datetype_entry";
+ $fmt = ut_datefmt_create( "de-DE", $datetype_entry , IntlDateFormatter::SHORT,'America/Los_Angeles', IntlDateFormatter::GREGORIAN );
+ $date_type = ut_datefmt_get_datetype( $fmt);
+ $res_str .= "\nAfter call to get_datetype : datetype= $date_type";
+ $res_str .= "\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+Creating IntlDateFormatter with date_type = 0
+After call to get_datetype : datetype= 0
+
+Creating IntlDateFormatter with date_type = 1
+After call to get_datetype : datetype= 1
+
+Creating IntlDateFormatter with date_type = 2
+After call to get_datetype : datetype= 2
+
+Creating IntlDateFormatter with date_type = 3
+After call to get_datetype : datetype= 3
+
+Creating IntlDateFormatter with date_type = -1
+After call to get_datetype : datetype= -1
diff --git a/ext/intl/tests/dateformat_get_locale.phpt b/ext/intl/tests/dateformat_get_locale.phpt
new file mode 100644
index 0000000..17fcca3
--- /dev/null
+++ b/ext/intl/tests/dateformat_get_locale.phpt
@@ -0,0 +1,59 @@
+--TEST--
+datefmt_get_locale_code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Test for the datefmt_get_locale function
+ */
+
+
+function ut_main()
+{
+ $locale_arr = array (
+ 'de-DE',
+ 'sl-IT-nedis',
+ 'en_UK',
+ 'hi'
+ );
+
+ $res_str = '';
+
+ foreach( $locale_arr as $locale_entry )
+ {
+ $res_str .= "\nCreating IntlDateFormatter with locale = $locale_entry";
+ $fmt = ut_datefmt_create( $locale_entry , IntlDateFormatter::SHORT,IntlDateFormatter::SHORT,'America/Los_Angeles', IntlDateFormatter::GREGORIAN );
+ $locale = ut_datefmt_get_locale( $fmt , 1);
+ $res_str .= "\nAfter call to get_locale : locale= $locale";
+ $res_str .= "\n";
+ }
+ $badvals = array(100, -1, 4294901761);
+ foreach($badvals as $badval) {
+ if(ut_datefmt_get_locale($fmt, $badval)) {
+ $res_str .= "datefmt_get_locale should return false for bad argument $badval\n";
+ }
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+Creating IntlDateFormatter with locale = de-DE
+After call to get_locale : locale= de_DE
+
+Creating IntlDateFormatter with locale = sl-IT-nedis
+After call to get_locale : locale= sl
+
+Creating IntlDateFormatter with locale = en_UK
+After call to get_locale : locale= en
+
+Creating IntlDateFormatter with locale = hi
+After call to get_locale : locale= hi
diff --git a/ext/intl/tests/dateformat_get_set_calendar.phpt b/ext/intl/tests/dateformat_get_set_calendar.phpt
new file mode 100644
index 0000000..bfd4e57
--- /dev/null
+++ b/ext/intl/tests/dateformat_get_set_calendar.phpt
@@ -0,0 +1,60 @@
+--TEST--
+datefmt_get_calendar_code() datefmt_set_calendar_code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * 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;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--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
diff --git a/ext/intl/tests/dateformat_get_set_pattern.phpt b/ext/intl/tests/dateformat_get_set_pattern.phpt
new file mode 100644
index 0000000..bd541c1
--- /dev/null
+++ b/ext/intl/tests/dateformat_get_set_pattern.phpt
@@ -0,0 +1,85 @@
+--TEST--
+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
+
+/*
+ * 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-69
+-------------------
+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-1969 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
diff --git a/ext/intl/tests/dateformat_get_set_pattern2.phpt b/ext/intl/tests/dateformat_get_set_pattern2.phpt
new file mode 100644
index 0000000..de41f10
--- /dev/null
+++ b/ext/intl/tests/dateformat_get_set_pattern2.phpt
@@ -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
diff --git a/ext/intl/tests/dateformat_get_timetype.phpt b/ext/intl/tests/dateformat_get_timetype.phpt
new file mode 100644
index 0000000..2ddc117
--- /dev/null
+++ b/ext/intl/tests/dateformat_get_timetype.phpt
@@ -0,0 +1,57 @@
+--TEST--
+datefmt_get_timetype_code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Test for the datefmt_get_timetype function
+ */
+
+
+function ut_main()
+{
+ $timetype_arr = array (
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::MEDIUM,
+ IntlDateFormatter::SHORT,
+ IntlDateFormatter::NONE
+ );
+
+ $res_str = '';
+
+ foreach( $timetype_arr as $timetype_entry )
+ {
+ $res_str .= "\nCreating IntlDateFormatter with time_type = $timetype_entry";
+ $fmt = ut_datefmt_create( "de-DE", IntlDateFormatter::SHORT, $timetype_entry ,'America/Los_Angeles', IntlDateFormatter::GREGORIAN );
+ $time_type = ut_datefmt_get_timetype( $fmt);
+ $res_str .= "\nAfter call to get_timetype : timetype= $time_type";
+ $res_str .= "\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+Creating IntlDateFormatter with time_type = 0
+After call to get_timetype : timetype= 0
+
+Creating IntlDateFormatter with time_type = 1
+After call to get_timetype : timetype= 1
+
+Creating IntlDateFormatter with time_type = 2
+After call to get_timetype : timetype= 2
+
+Creating IntlDateFormatter with time_type = 3
+After call to get_timetype : timetype= 3
+
+Creating IntlDateFormatter with time_type = -1
+After call to get_timetype : timetype= -1
diff --git a/ext/intl/tests/dateformat_get_timezone_id.phpt b/ext/intl/tests/dateformat_get_timezone_id.phpt
new file mode 100644
index 0000000..80cbdbb
--- /dev/null
+++ b/ext/intl/tests/dateformat_get_timezone_id.phpt
@@ -0,0 +1,49 @@
+--TEST--
+datefmt_get_timezone_id_code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Test for the datefmt_get_timezone_id function
+ */
+
+
+function ut_main()
+{
+ $timezone_id_arr = array (
+ 'America/New_York',
+ 'America/Los_Angeles',
+ 'America/Dallas'
+ );
+
+ $res_str = '';
+
+ foreach( $timezone_id_arr as $timezone_id_entry )
+ {
+ $res_str .= "\nCreating IntlDateFormatter with timezone_id = $timezone_id_entry";
+ $fmt = ut_datefmt_create( "de-DE", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, $timezone_id_entry , IntlDateFormatter::GREGORIAN );
+ $timezone_id = ut_datefmt_get_timezone_id( $fmt);
+ $res_str .= "\nAfter call to get_timezone_id : timezone_id= $timezone_id";
+ $res_str .= "\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+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 = America/Dallas
+After call to get_timezone_id : timezone_id= America/Dallas
diff --git a/ext/intl/tests/dateformat_is_set_lenient.phpt b/ext/intl/tests/dateformat_is_set_lenient.phpt
new file mode 100644
index 0000000..8492a2e
--- /dev/null
+++ b/ext/intl/tests/dateformat_is_set_lenient.phpt
@@ -0,0 +1,88 @@
+--TEST--
+datefmt_set_lenient and datefmt_set_lenient()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+
+<?php
+
+/*
+ * Test for the datefmt_get_lenient & datefmt_set_lenient function
+ */
+
+
+function ut_main()
+{
+
+ $res_str = '';
+
+ //Create
+ $fmt = ut_datefmt_create( "en-US", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT , 'America/New_York', IntlDateFormatter::GREGORIAN );
+ $res_str .= "\nIntlDateFormatter Created.\n";
+
+ $resLenient1 = ut_datefmt_is_lenient( $fmt);
+ $res_str .= "After call to get_lenient : lenient= ";
+ if( $resLenient1){
+ $res_str .= "TRUE\n";
+ }else{
+ $res_str .= "FALSE\n";
+ }
+
+ //Set and test
+ $res_str .= "--------------------\n";
+ $isLenient = TRUE;
+ $res_str .= "Setting IntlDateFormatter with lenient = ";
+ if( $isLenient){
+ $res_str .= "TRUE\n";
+ }else{
+ $res_str .= "FALSE\n";
+ }
+ ut_datefmt_set_lenient( $fmt , $isLenient );
+ $resLenient = ut_datefmt_is_lenient( $fmt);
+ $res_str .= "After call to is_lenient : lenient= ";
+ if( $resLenient){
+ $res_str .= "TRUE\n";
+ }else{
+ $res_str .= "FALSE\n";
+ }
+
+
+ //Set and test
+ $res_str .= "--------------------\n";
+ $isLenient = FALSE;
+ $res_str .= "Setting IntlDateFormatter with lenient =";
+ if( $isLenient){
+ $res_str .= "TRUE\n";
+ }else{
+ $res_str .= "FALSE\n";
+ }
+ ut_datefmt_set_lenient( $fmt , $isLenient);
+ $resLenient = ut_datefmt_is_lenient( $fmt);
+ $res_str .= "After call to is_lenient : lenient= ";
+ if( $resLenient){
+ $res_str .= "TRUE\n";
+ }else{
+ $res_str .= "FALSE\n";
+ }
+
+ $res_str .= "--------------------\n";
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+IntlDateFormatter Created.
+After call to get_lenient : lenient= TRUE
+--------------------
+Setting IntlDateFormatter with lenient = TRUE
+After call to is_lenient : lenient= TRUE
+--------------------
+Setting IntlDateFormatter with lenient =FALSE
+After call to is_lenient : lenient= FALSE
+--------------------
diff --git a/ext/intl/tests/dateformat_localtime.phpt b/ext/intl/tests/dateformat_localtime.phpt
new file mode 100644
index 0000000..79f297d
--- /dev/null
+++ b/ext/intl/tests/dateformat_localtime.phpt
@@ -0,0 +1,134 @@
+--TEST--
+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
+
+/*
+ * Test for the datefmt_localtime function
+ */
+
+
+function ut_main()
+{
+ $locale_arr = array (
+ 'en_US_CA'
+ );
+
+ $datetype_arr = array (
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::MEDIUM,
+ IntlDateFormatter::SHORT,
+ IntlDateFormatter::NONE
+ );
+
+ $res_str = '';
+
+ $datetype_arr = array (
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::MEDIUM,
+ );
+
+ $res_str = '';
+
+
+ $text_arr = array (
+ "Thursday, December 18, 1969 8:49:59 AM PST",
+ "June 18, 1969 8:49:59 AM ",
+ "12/18/69 8:49 AM",
+ "19691218 08:49 AM"
+ );
+
+ $fmt1 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::LONG, IntlDateFormatter::LONG);
+ $fmt2 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM);
+ $fmt3 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::FULL, IntlDateFormatter::FULL);
+ $fmt_array = array(
+ $fmt1 , $fmt2 ,$fmt3
+ );
+ $fmt_desc_array = array(
+ "DateType::LONG, TimeType::LONG",
+ "DateType::MEDIUM, TimeType::MEDIUM",
+ "DateType::FULL, TimeType::FULL"
+ );
+
+ foreach( $text_arr as $text_entry){
+ $res_str .= "\n-------------------------------\n";
+ $res_str .= "\nInput text is : $text_entry";
+ $cnt =0;
+
+
+ foreach( $fmt_array as $fmt_entry ){
+ $res_str .= "\n------------";
+ $res_str .= "\nIntlDateFormatter : ".$fmt_desc_array[$cnt];
+ $parse_pos = 0;
+ $cnt++;
+ $parsed_arr = ut_datefmt_localtime( $fmt_entry , $text_entry , $parse_pos );
+
+ if( $parsed_arr){
+ $res_str .= "\n";
+ foreach( $parsed_arr as $key => $value){
+ $res_str .= "$key : '$value' , ";
+ }
+ }
+/*
+ else{
+ //$res_str .= "No values found from LocaleTime parsing.";
+ $res_str .= "\tError : '".intl_get_error_message()."'";
+ }
+*/
+ }//end of for $fmt_array
+ }
+
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECTF--
+-------------------------------
+
+Input text is : Thursday, December 18, 1969 8:49:59 AM PST
+------------
+IntlDateFormatter : DateType::LONG, TimeType::LONG
+------------
+IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
+------------
+IntlDateFormatter : DateType::FULL, TimeType::FULL
+tm_sec : '59' , tm_min : '49' , tm_hour : '8' , tm_year : '69' , tm_mday : '18' , tm_wday : '4' , tm_yday : '352' , tm_mon : '11' , tm_isdst : '0' ,
+-------------------------------
+
+Input text is : June 18, 1969 8:49:59 AM
+------------
+IntlDateFormatter : DateType::LONG, TimeType::LONG
+------------
+IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
+tm_sec : '59' , tm_min : '49' , tm_hour : '8' , tm_year : '69' , tm_mday : '18' , tm_wday : '3' , tm_yday : '169' , tm_mon : '5' , tm_isdst : '%d' ,
+------------
+IntlDateFormatter : DateType::FULL, TimeType::FULL
+-------------------------------
+
+Input text is : 12/18/69 8:49 AM
+------------
+IntlDateFormatter : DateType::LONG, TimeType::LONG
+------------
+IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
+------------
+IntlDateFormatter : DateType::FULL, TimeType::FULL
+-------------------------------
+
+Input text is : 19691218 08:49 AM
+------------
+IntlDateFormatter : DateType::LONG, TimeType::LONG
+------------
+IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
+------------
+IntlDateFormatter : DateType::FULL, TimeType::FULL
diff --git a/ext/intl/tests/dateformat_parse.phpt b/ext/intl/tests/dateformat_parse.phpt
new file mode 100644
index 0000000..ff59773
--- /dev/null
+++ b/ext/intl/tests/dateformat_parse.phpt
@@ -0,0 +1,113 @@
+--TEST--
+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--
+<?php
+
+/*
+ * Test for the datefmt_parse function
+ */
+
+putenv('TZ=America/Los_Angeles');
+
+function ut_main()
+{
+ $locale_arr = array (
+ 'en_US_CA'
+ );
+
+ $datetype_arr = array (
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::MEDIUM,
+ IntlDateFormatter::SHORT,
+ IntlDateFormatter::NONE
+ );
+
+ $res_str = '';
+
+
+ $text_arr = array (
+ // Full parsing
+ array("Sunday, September 18, 2039 4:06:40 PM PT", IntlDateFormatter::FULL, IntlDateFormatter::FULL),
+ array("Wednesday, December 17, 1969 6:40:00 PM PT", IntlDateFormatter::FULL, IntlDateFormatter::FULL),
+ array("Thursday, December 18, 1969 8:49:59 PM PST", IntlDateFormatter::FULL, IntlDateFormatter::FULL),
+ array("December 18, 1969 8:49:59 AM PST", IntlDateFormatter::LONG, IntlDateFormatter::FULL),
+ array("12/18/69 8:49 AM", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT),
+ array("19691218 08:49 AM", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT),
+ // Partial parsing
+ array("Sunday, September 18, 2039 4:06:40 PM PT", IntlDateFormatter::FULL, IntlDateFormatter::NONE),
+ array("Sunday, September 18, 2039 4:06:40 PM PT", IntlDateFormatter::FULL, IntlDateFormatter::SHORT),
+ array("December 18, 1969 8:49:59 AM PST", IntlDateFormatter::LONG, IntlDateFormatter::NONE),
+ array("December 18, 1969 8:49:59 AM PST", IntlDateFormatter::LONG, IntlDateFormatter::SHORT),
+ array("12/18/69 8:49 AM", IntlDateFormatter::SHORT, IntlDateFormatter::LONG),
+ array("19691218 08:49 AM", IntlDateFormatter::SHORT, IntlDateFormatter::LONG),
+ );
+
+ foreach( $text_arr as $text_entry){
+ $fmt = ut_datefmt_create( 'en_US_CA', $text_entry[1], $text_entry[2]);
+ $parse_pos = 0;
+ $parsed = ut_datefmt_parse( $fmt , $text_entry[0] , $parse_pos );
+
+ $res_str .= "\nInput text : {$text_entry[0]} ; DF = {$text_entry[1]}; TF = {$text_entry[2]}";
+ if( intl_get_error_code() != U_ZERO_ERROR) {
+ $res_str .= "\nError : ".intl_get_error_message();
+ }
+ $res_str .= "\nParsed: $parsed; parse_pos : $parse_pos\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+
+Input text : Sunday, September 18, 2039 4:06:40 PM PT ; DF = 0; TF = 0
+Parsed: 2200000000; parse_pos : 40
+
+Input text : Wednesday, December 17, 1969 6:40:00 PM PT ; DF = 0; TF = 0
+Parsed: -1200000; parse_pos : 42
+
+Input text : Thursday, December 18, 1969 8:49:59 PM PST ; DF = 0; TF = 0
+Parsed: -1105801; parse_pos : 42
+
+Input text : December 18, 1969 8:49:59 AM PST ; DF = 1; TF = 0
+Parsed: -1149001; parse_pos : 32
+
+Input text : 12/18/69 8:49 AM ; DF = 3; TF = 3
+Parsed: -1149060; parse_pos : 16
+
+Input text : 19691218 08:49 AM ; DF = 3; TF = 3
+Error : Date parsing failed: U_PARSE_ERROR
+Parsed: ; parse_pos : 8
+
+Input text : Sunday, September 18, 2039 4:06:40 PM PT ; DF = 0; TF = -1
+Parsed: 2199942000; parse_pos : 26
+
+Input text : Sunday, September 18, 2039 4:06:40 PM PT ; DF = 0; TF = 3
+Error : Date parsing failed: U_PARSE_ERROR
+Parsed: ; parse_pos : 31
+
+Input text : December 18, 1969 8:49:59 AM PST ; DF = 1; TF = -1
+Parsed: -1180800; parse_pos : 17
+
+Input text : December 18, 1969 8:49:59 AM PST ; DF = 1; TF = 3
+Error : Date parsing failed: U_PARSE_ERROR
+Parsed: ; parse_pos : 22
+
+Input text : 12/18/69 8:49 AM ; DF = 3; TF = 1
+Error : Date parsing failed: U_PARSE_ERROR
+Parsed: ; parse_pos : 13
+
+Input text : 19691218 08:49 AM ; DF = 3; TF = 1
+Error : Date parsing failed: U_PARSE_ERROR
+Parsed: ; parse_pos : 8
diff --git a/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt b/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt
new file mode 100644
index 0000000..03f99f1
--- /dev/null
+++ b/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt
@@ -0,0 +1,120 @@
+--TEST--
+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
+
+/*
+ * Test for the datefmt_parse_localtime function with parse pos
+ */
+
+
+function ut_main()
+{
+ $locale_arr = array (
+ 'en_US_CA'
+ );
+
+ $datetype_arr = array (
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::MEDIUM,
+ );
+
+ $res_str = '';
+
+
+ $text_arr = array (
+ "Thursday, December 18, 1969 8:49:59 AM PST",
+ "June 18, 1969 8:49:59 AM ",
+ "12/18/69 8:49 AM",
+ "19691218 08:49 AM"
+ );
+
+ $fmt1 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::LONG, IntlDateFormatter::LONG);
+ $fmt2 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM);
+ $fmt3 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::FULL, IntlDateFormatter::FULL);
+ $fmt_array = array(
+ $fmt1 , $fmt2 ,$fmt3
+ );
+ $fmt_desc_array = array(
+ "DateType::LONG, TimeType::LONG",
+ "DateType::MEDIUM, TimeType::MEDIUM",
+ "DateType::FULL, TimeType::FULL"
+ );
+
+ foreach( $text_arr as $text_entry){
+ $res_str .= "\n-------------------------------\n";
+ $res_str .= "\nInput text is : $text_entry";
+ $cnt =0;
+ foreach( $fmt_array as $fmt_entry ){
+ $res_str .= "\n------------";
+ $res_str .= "\nIntlDateFormatter : ".$fmt_desc_array[$cnt];
+ $cnt++;
+ $parsed_arr = ut_datefmt_localtime( $fmt_entry , $text_entry);
+
+ if( $parsed_arr){
+ $res_str .= "\n";
+ foreach( $parsed_arr as $key => $value){
+ $res_str .= "$key : '$value' , ";
+ }
+ }
+ else{
+ //$res_str .= "No values found from LocaleTime parsing.";
+ $res_str .= "\tError : '".intl_get_error_message()."'";
+ }
+
+ }
+ }
+
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECTF--
+-------------------------------
+
+Input text is : Thursday, December 18, 1969 8:49:59 AM PST
+------------
+IntlDateFormatter : DateType::LONG, TimeType::LONG Error : 'Date parsing failed: U_PARSE_ERROR'
+------------
+IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM Error : 'Date parsing failed: U_PARSE_ERROR'
+------------
+IntlDateFormatter : DateType::FULL, TimeType::FULL
+tm_sec : '59' , tm_min : '49' , tm_hour : '8' , tm_year : '69' , tm_mday : '18' , tm_wday : '4' , tm_yday : '352' , tm_mon : '11' , tm_isdst : '0' ,
+-------------------------------
+
+Input text is : June 18, 1969 8:49:59 AM
+------------
+IntlDateFormatter : DateType::LONG, TimeType::LONG Error : 'Date parsing failed: U_PARSE_ERROR'
+------------
+IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
+tm_sec : '59' , tm_min : '49' , tm_hour : '8' , tm_year : '69' , tm_mday : '18' , tm_wday : '3' , tm_yday : '169' , tm_mon : '5' , tm_isdst : '%d' ,
+------------
+IntlDateFormatter : DateType::FULL, TimeType::FULL Error : 'Date parsing failed: U_PARSE_ERROR'
+-------------------------------
+
+Input text is : 12/18/69 8:49 AM
+------------
+IntlDateFormatter : DateType::LONG, TimeType::LONG Error : 'Date parsing failed: U_PARSE_ERROR'
+------------
+IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM Error : 'Date parsing failed: U_PARSE_ERROR'
+------------
+IntlDateFormatter : DateType::FULL, TimeType::FULL Error : 'Date parsing failed: U_PARSE_ERROR'
+-------------------------------
+
+Input text is : 19691218 08:49 AM
+------------
+IntlDateFormatter : DateType::LONG, TimeType::LONG Error : 'Date parsing failed: U_PARSE_ERROR'
+------------
+IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM Error : 'Date parsing failed: U_PARSE_ERROR'
+------------
+IntlDateFormatter : DateType::FULL, TimeType::FULL Error : 'Date parsing failed: U_PARSE_ERROR'
diff --git a/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt b/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt
new file mode 100644
index 0000000..0f26643
--- /dev/null
+++ b/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt
@@ -0,0 +1,157 @@
+--TEST--
+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--
+TZ=America/Los_Angeles
+--FILE--
+<?php
+
+/*
+ * Test for the datefmt_parse_timestamp function with parse_pos
+ */
+
+
+function ut_main()
+{
+ $locale_arr = array (
+ 'en_US_CA'
+ );
+
+ $datetype_arr = array (
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::MEDIUM,
+ IntlDateFormatter::SHORT,
+ IntlDateFormatter::NONE
+ );
+
+ $res_str = '';
+
+
+ $text_arr = array (
+ "Sunday, September 18, 3039 4:06:40 PM PT",
+ "Thursday, December 18, 1969 8:49:59 AM PST",
+ //"December 18, 1969 8:49:59 AM PST",
+ "12/18/69 8:49 AM",
+ "20111218 08:49 AM",
+ "19691218 08:49 AM"
+ );
+
+ foreach( $text_arr as $text_entry){
+ $res_str .= "\n------------\n";
+ $res_str .= "\nInput text is : $text_entry";
+ $res_str .= "\n------------";
+
+ foreach( $locale_arr as $locale_entry ){
+ $res_str .= "\nLocale is : $locale_entry";
+ $res_str .= "\n------------";
+ foreach( $datetype_arr as $datetype_entry )
+ {
+ $res_str .= "\ndatetype = $datetype_entry ,timetype =$datetype_entry";
+ $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry);
+ $pos = 0;
+ $parsed = ut_datefmt_parse( $fmt , $text_entry, $pos);
+ if( intl_get_error_code() == U_ZERO_ERROR){
+ $res_str .= "\nParsed text is : $parsed; Position = $pos";
+ }else{
+ $res_str .= "\nError while parsing as: '".intl_get_error_message()."'; Position = $pos";
+ }
+ }
+ }
+ }
+ $res_str .= "\n";
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+------------
+
+Input text is : Sunday, September 18, 3039 4:06:40 PM PT
+------------
+Locale is : en_US_CA
+------------
+datetype = 0 ,timetype =0
+Parsed text is : 33756908800; Position = 40
+datetype = 1 ,timetype =1
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 2 ,timetype =2
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 3 ,timetype =3
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = -1 ,timetype =-1
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+------------
+
+Input text is : Thursday, December 18, 1969 8:49:59 AM PST
+------------
+Locale is : en_US_CA
+------------
+datetype = 0 ,timetype =0
+Parsed text is : -1149001; Position = 42
+datetype = 1 ,timetype =1
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 2 ,timetype =2
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 3 ,timetype =3
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = -1 ,timetype =-1
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+------------
+
+Input text is : 12/18/69 8:49 AM
+------------
+Locale is : en_US_CA
+------------
+datetype = 0 ,timetype =0
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 1 ,timetype =1
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 2 ,timetype =2
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 3 ,timetype =3
+Parsed text is : -1149060; Position = 16
+datetype = -1 ,timetype =-1
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+------------
+
+Input text is : 20111218 08:49 AM
+------------
+Locale is : en_US_CA
+------------
+datetype = 0 ,timetype =0
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 1 ,timetype =1
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 2 ,timetype =2
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 3 ,timetype =3
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 8
+datetype = -1 ,timetype =-1
+Parsed text is : 1324226940; Position = 17
+------------
+
+Input text is : 19691218 08:49 AM
+------------
+Locale is : en_US_CA
+------------
+datetype = 0 ,timetype =0
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 1 ,timetype =1
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 2 ,timetype =2
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
+datetype = 3 ,timetype =3
+Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 8
+datetype = -1 ,timetype =-1
+Parsed text is : -1149060; Position = 17
diff --git a/ext/intl/tests/dateformat_set_timezone_id.phpt b/ext/intl/tests/dateformat_set_timezone_id.phpt
new file mode 100644
index 0000000..72a9230
--- /dev/null
+++ b/ext/intl/tests/dateformat_set_timezone_id.phpt
@@ -0,0 +1,76 @@
+--TEST--
+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
+
+/*
+ * Test for the datefmt_set_timezone_id function
+ */
+
+
+function ut_main()
+{
+ $timezone_id_arr = array (
+ 'America/New_York',
+ 'America/Los_Angeles',
+ 'America/Chicago',
+ 'CN'
+ );
+ $timestamp_entry = 0;
+
+ $res_str = '';
+
+ $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/San_Francisco' , IntlDateFormatter::GREGORIAN );
+ $timezone_id = ut_datefmt_get_timezone_id( $fmt );
+ $res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n";
+
+ foreach( $timezone_id_arr as $timezone_id_entry )
+ {
+
+ $res_str .= "-----------";
+ $res_str .= "\nTrying to set timezone_id= $timezone_id_entry";
+ ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry );
+ $timezone_id = ut_datefmt_get_timezone_id( $fmt );
+ $res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id";
+ $formatted = ut_datefmt_format( $fmt, 0);
+ $res_str .= "\nFormatting timestamp=0 resulted in $formatted";
+ $formatted = ut_datefmt_format( $fmt, 3600);
+ $res_str .= "\nFormatting timestamp=3600 resulted in $formatted";
+ $res_str .= "\n";
+
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+After creation of the dateformatter : timezone_id= America/San_Francisco
+-----------
+Trying to set timezone_id= America/New_York
+After call to set_timezone_id : timezone_id= America/New_York
+Formatting timestamp=0 resulted in Wednesday, December 31, 1969 7:00:00 PM Eastern Standard Time
+Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 8:00:00 PM Eastern Standard Time
+-----------
+Trying to set timezone_id= America/Los_Angeles
+After call to set_timezone_id : timezone_id= America/Los_Angeles
+Formatting timestamp=0 resulted in Wednesday, December 31, 1969 4:00:00 PM Pacific Standard Time
+Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 5:00:00 PM Pacific Standard Time
+-----------
+Trying to set timezone_id= America/Chicago
+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
+-----------
+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
diff --git a/ext/intl/tests/dateformat_set_timezone_id2.phpt b/ext/intl/tests/dateformat_set_timezone_id2.phpt
new file mode 100644
index 0000000..23aacda
--- /dev/null
+++ b/ext/intl/tests/dateformat_set_timezone_id2.phpt
@@ -0,0 +1,76 @@
+--TEST--
+datefmt_set_timezone_id_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_set_timezone_id function
+ */
+
+
+function ut_main()
+{
+ $timezone_id_arr = array (
+ 'America/New_York',
+ 'America/Los_Angeles',
+ 'America/Chicago',
+ 'CN'
+ );
+ $timestamp_entry = 0;
+
+ $res_str = '';
+
+ $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/San_Francisco' , IntlDateFormatter::GREGORIAN );
+ $timezone_id = ut_datefmt_get_timezone_id( $fmt );
+ $res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n";
+
+ foreach( $timezone_id_arr as $timezone_id_entry )
+ {
+
+ $res_str .= "-----------";
+ $res_str .= "\nTrying to set timezone_id= $timezone_id_entry";
+ ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry );
+ $timezone_id = ut_datefmt_get_timezone_id( $fmt );
+ $res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id";
+ $formatted = ut_datefmt_format( $fmt, 0);
+ $res_str .= "\nFormatting timestamp=0 resulted in $formatted";
+ $formatted = ut_datefmt_format( $fmt, 3600);
+ $res_str .= "\nFormatting timestamp=3600 resulted in $formatted";
+ $res_str .= "\n";
+
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+After creation of the dateformatter : timezone_id= America/San_Francisco
+-----------
+Trying to set timezone_id= America/New_York
+After call to set_timezone_id : timezone_id= America/New_York
+Formatting timestamp=0 resulted in Wednesday, December 31, 1969 7:00:00 PM Eastern Standard Time
+Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 8:00:00 PM Eastern Standard Time
+-----------
+Trying to set timezone_id= America/Los_Angeles
+After call to set_timezone_id : timezone_id= America/Los_Angeles
+Formatting timestamp=0 resulted in Wednesday, December 31, 1969 4:00:00 PM Pacific Standard Time
+Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 5:00:00 PM Pacific Standard Time
+-----------
+Trying to set timezone_id= America/Chicago
+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
+-----------
+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
diff --git a/ext/intl/tests/formatter_clone.phpt b/ext/intl/tests/formatter_clone.phpt
new file mode 100644
index 0000000..4e8d096
--- /dev/null
+++ b/ext/intl/tests/formatter_clone.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Cloning numfmt
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+include_once( 'ut_common.inc' );
+$GLOBALS['oo-mode'] = true;
+$res_str = '';
+/*
+ * Clone
+ */
+$test_value = 12345.123456;
+$fmt = new NumberFormatter( "en_US", NumberFormatter::PATTERN_DECIMAL );
+$res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
+$fmt_clone = clone $fmt;
+
+$res = $fmt->setPattern("0.0" );
+if( $res === false )
+ $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n";
+
+$res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
+$res_str .= "Formatted(clone) number: " . ut_nfmt_format( $fmt_clone, $test_value ) . "\n";
+echo $res_str;
+
+?>
+--EXPECTF--
+Formatted number: 12345.123456
+Formatted number: 12345.1
+Formatted(clone) number: 12345.123456
diff --git a/ext/intl/tests/formatter_clone_bad_obj.phpt b/ext/intl/tests/formatter_clone_bad_obj.phpt
new file mode 100644
index 0000000..ef7b28a
--- /dev/null
+++ b/ext/intl/tests/formatter_clone_bad_obj.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Cloning unconstructed numfmt
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+class A extends NumberFormatter {
+ function __construct() {}
+}
+
+$a = new A;
+try {
+ $b = clone $a;
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+--EXPECTF--
+string(42) "Cannot clone unconstructed NumberFormatter"
diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt
new file mode 100644
index 0000000..295f011
--- /dev/null
+++ b/ext/intl/tests/formatter_fail.phpt
@@ -0,0 +1,79 @@
+--TEST--
+numfmt creation failures
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+function err($fmt) {
+ if(!$fmt) {
+ echo var_export(intl_get_error_message(), true)."\n";
+ }
+}
+
+function crt($t, $l, $s) {
+ switch(true) {
+ case $t == "O":
+ return new NumberFormatter($l, $s);
+ break;
+ case $t == "C":
+ return NumberFormatter::create($l, $s);
+ break;
+ case $t == "P":
+ return numfmt_create($l, $s);
+ break;
+ }
+}
+
+$args = array(
+ array(null, null),
+ array("whatever", 1234567),
+ array(array(), array()),
+ array("en", -1),
+ array("en_US", NumberFormatter::PATTERN_RULEBASED),
+);
+
+$fmt = new NumberFormatter();
+err($fmt);
+$fmt = numfmt_create();
+err($fmt);
+$fmt = NumberFormatter::create();
+err($fmt);
+
+foreach($args as $arg) {
+ $fmt = crt("O", $arg[0], $arg[1]);
+ err($fmt);
+ $fmt = crt("C", $arg[0], $arg[1]);
+ err($fmt);
+ $fmt = crt("P", $arg[0], $arg[1]);
+ err($fmt);
+}
+
+?>
+--EXPECTF--
+Warning: NumberFormatter::__construct() expects at least 2 parameters, 0 given in %s on line %d
+'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: numfmt_create() expects at least 2 parameters, 0 given in %s on line %d
+'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: NumberFormatter::create() expects at least 2 parameters, 0 given in %s on line %d
+'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
+'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
+'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
+
+Warning: NumberFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: NumberFormatter::create() expects parameter 1 to be string, array given in %s on line %d
+'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: numfmt_create() expects parameter 1 to be string, array given in %s on line %d
+'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
+'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
+'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
+'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
+'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
+'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
diff --git a/ext/intl/tests/formatter_format.phpt b/ext/intl/tests/formatter_format.phpt
new file mode 100644
index 0000000..334ef49
--- /dev/null
+++ b/ext/intl/tests/formatter_format.phpt
@@ -0,0 +1,130 @@
+--TEST--
+numfmt_format() 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
+
+/*
+ * 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 zwei­hundert­vier­und­dreißig­tausend­fünf­hundert­sieben­und­sechzig 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 567ᵉ?'
+'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!
diff --git a/ext/intl/tests/formatter_format2.phpt b/ext/intl/tests/formatter_format2.phpt
new file mode 100644
index 0000000..0732e41
--- /dev/null
+++ b/ext/intl/tests/formatter_format2.phpt
@@ -0,0 +1,130 @@
+--TEST--
+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'; ?>
+--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 zwei­hundert­vier­und­dreißig­tausend­fünf­hundert­sieben­und­sechzig 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!
diff --git a/ext/intl/tests/formatter_format_conv.phpt b/ext/intl/tests/formatter_format_conv.phpt
new file mode 100644
index 0000000..e1d25ef
--- /dev/null
+++ b/ext/intl/tests/formatter_format_conv.phpt
@@ -0,0 +1,24 @@
+--TEST--
+numfmt_format() with type conversion
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+function ut_main()
+{
+ $fmt = ut_nfmt_create( 'en_US', NumberFormatter::DECIMAL );
+ $number = 1234567.891234567890000;
+
+ $str_res = ut_nfmt_format ($fmt, $number, NumberFormatter::TYPE_INT32)."\n";
+ return $str_res;
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+
+?>
+--EXPECT--
+1,234,567
diff --git a/ext/intl/tests/formatter_format_currency.phpt b/ext/intl/tests/formatter_format_currency.phpt
new file mode 100644
index 0000000..be219a5
--- /dev/null
+++ b/ext/intl/tests/formatter_format_currency.phpt
@@ -0,0 +1,50 @@
+--TEST--
+numfmt_format_currency() 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
+
+/*
+ * 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();
+
+?>
+--EXPECT--
+en_UK: '£1,234,567.89'
+en_US: '$1,234,567.89'
+ru: '1 234 567,89 р.'
+uk: '1 234 567,89 ₴'
+en: '₴1,234,567.89'
diff --git a/ext/intl/tests/formatter_format_currency2.phpt b/ext/intl/tests/formatter_format_currency2.phpt
new file mode 100644
index 0000000..d9277f3
--- /dev/null
+++ b/ext/intl/tests/formatter_format_currency2.phpt
@@ -0,0 +1,50 @@
+--TEST--
+numfmt_format_currency() 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
+
+/*
+ * 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();
+
+?>
+--EXPECT--
+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'
diff --git a/ext/intl/tests/formatter_get_error.phpt b/ext/intl/tests/formatter_get_error.phpt
new file mode 100644
index 0000000..acb683e
--- /dev/null
+++ b/ext/intl/tests/formatter_get_error.phpt
@@ -0,0 +1,31 @@
+--TEST--
+numfmt_get_error_message/code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Error handling.
+ */
+
+
+function ut_main()
+{
+ $fmt = ut_nfmt_create( "en_US", NumberFormatter::CURRENCY );
+ $currency = '';
+ $pos = 0;
+ $num = ut_nfmt_parse_currency( $fmt, '123.45', $currency, $pos );
+ if( $num === false )
+ return $fmt->getErrorMessage() . " (" . $fmt->getErrorCode() . ")\n";
+ else
+ return "Ooops, an error should have occurred.";
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+Number parsing failed: U_PARSE_ERROR (9)
diff --git a/ext/intl/tests/formatter_get_locale.phpt b/ext/intl/tests/formatter_get_locale.phpt
new file mode 100644
index 0000000..3d4fb2a
--- /dev/null
+++ b/ext/intl/tests/formatter_get_locale.phpt
@@ -0,0 +1,49 @@
+--TEST--
+numfmt_get_locale()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Get locale.
+ */
+
+function ut_main()
+{
+ $locales = array(
+ 'en_UK',
+ 'en_US@California',
+ 'fr_CA',
+ );
+
+ $loc_types = array(
+ Locale::ACTUAL_LOCALE => 'actual',
+ Locale::VALID_LOCALE => 'valid',
+ );
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $fmt = ut_nfmt_create( $locale, NumberFormatter::DECIMAL );
+ $res_str .= "$locale: ";
+ foreach( $loc_types as $loc_type => $loc_type_name )
+ $res_str .= sprintf( " %s=%s",
+ $loc_type_name,
+ dump( ut_nfmt_get_locale( $fmt, $loc_type ) ) );
+ $res_str .= "\n";
+ }
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+en_UK: actual='en' valid='en'
+en_US@California: actual='en' valid='en'
+fr_CA: actual='fr_CA' valid='fr_CA'
diff --git a/ext/intl/tests/formatter_get_set_attribute.phpt b/ext/intl/tests/formatter_get_set_attribute.phpt
new file mode 100644
index 0000000..51c7d36
--- /dev/null
+++ b/ext/intl/tests/formatter_get_set_attribute.phpt
@@ -0,0 +1,194 @@
+--TEST--
+numfmt_get/set_attribute()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.2', '<') != 1) print 'skip for ICU 4.4+'; ?>
+--FILE--
+<?php
+
+/*
+ * Get/set various number formatting attributes.
+ */
+
+
+function ut_main()
+{
+ // attr_name => array( attr, value )
+ $attributes = array(
+ 'PARSE_INT_ONLY' => array( NumberFormatter::PARSE_INT_ONLY, 1, 12345.123456 ),
+ 'GROUPING_USED' => array( NumberFormatter::GROUPING_USED, 0, 12345.123456 ),
+ 'DECIMAL_ALWAYS_SHOWN' => array( NumberFormatter::DECIMAL_ALWAYS_SHOWN, 1, 12345 ),
+ 'MAX_INTEGER_DIGITS' => array( NumberFormatter::MAX_INTEGER_DIGITS, 2, 12345.123456 ),
+ 'MIN_INTEGER_DIGITS' => array( NumberFormatter::MIN_INTEGER_DIGITS, 20, 12345.123456 ),
+ 'INTEGER_DIGITS' => array( NumberFormatter::INTEGER_DIGITS, 7, 12345.123456 ),
+ 'MAX_FRACTION_DIGITS' => array( NumberFormatter::MAX_FRACTION_DIGITS, 2, 12345.123456 ),
+ 'MIN_FRACTION_DIGITS' => array( NumberFormatter::MIN_FRACTION_DIGITS, 20, 12345.123456 ),
+ 'FRACTION_DIGITS' => array( NumberFormatter::FRACTION_DIGITS, 5, 12345.123456 ),
+ 'MULTIPLIER' => array( NumberFormatter::MULTIPLIER, 2, 12345.123456 ),
+ 'GROUPING_SIZE' => array( NumberFormatter::GROUPING_SIZE, 2, 12345.123456 ),
+ 'ROUNDING_MODE' => array( NumberFormatter::ROUNDING_MODE, 1, 12345.123456 ),
+ 'ROUNDING_INCREMENT' => array( NumberFormatter::ROUNDING_INCREMENT, (float)2, 12345.123456 ),
+ 'FORMAT_WIDTH' => array( NumberFormatter::FORMAT_WIDTH, 27, 12345.123456 ),
+ 'PADDING_POSITION' => array( NumberFormatter::PADDING_POSITION, 2, 12345.123456 ),
+ 'SECONDARY_GROUPING_SIZE' => array( NumberFormatter::SECONDARY_GROUPING_SIZE, 2, 12345.123456 ),
+ 'SIGNIFICANT_DIGITS_USED' => array( NumberFormatter::SIGNIFICANT_DIGITS_USED, 1, 12345.123456 ),
+ 'MIN_SIGNIFICANT_DIGITS' => array( NumberFormatter::MIN_SIGNIFICANT_DIGITS, 3, 1 ),
+ 'MAX_SIGNIFICANT_DIGITS' => array( NumberFormatter::MAX_SIGNIFICANT_DIGITS, 4, 12345.123456 ),
+ // 'LENIENT_PARSE' => array( NumberFormatter::LENIENT_PARSE, 2, 12345.123456 )
+ );
+
+ $res_str = '';
+
+ $fmt = ut_nfmt_create( "en_US", NumberFormatter::DECIMAL );
+
+ foreach( $attributes as $attr_name => $args )
+ {
+ list( $attr, $new_val, $number ) = $args;
+ $res_str .= "\nAttribute $attr_name\n";
+
+ // Get original value of the attribute.
+ $orig_val = ut_nfmt_get_attribute( $fmt, $attr );
+
+ // Format the number using the original attribute value.
+ $rc = ut_nfmt_format( $fmt, $number );
+
+ $ps = ut_nfmt_parse( $fmt, $rc );
+
+ $res_str .= sprintf( "Old attribute value: %s ; Format result: %s ; Parse result: %s\n",
+ dump( $orig_val ),
+ dump( $rc ),
+ dump( $ps ) );
+
+ // Set new attribute value.
+ $rc = ut_nfmt_set_attribute( $fmt, $attr, $new_val );
+ if( $rc )
+ $res_str .= "Setting attribute: ok\n";
+ else
+ $res_str .= sprintf( "Setting attribute failed: %s\n", ut_nfmt_get_error_message( $fmt ) );
+
+ // Format the number using the new value.
+ $rc = ut_nfmt_format( $fmt, $number );
+
+ // Get current value of the attribute and check if it equals $new_val.
+ $attr_val_check = ut_nfmt_get_attribute( $fmt, $attr );
+ if( $attr_val_check !== $new_val )
+ $res_str .= "ERROR: New $attr_name attribute value has not been set correctly.\n";
+
+ $ps = ut_nfmt_parse( $fmt, $rc );
+
+ $res_str .= sprintf( "New attribute value: %s ; Format result: %s ; Parse result: %s\n",
+ dump( $new_val ),
+ dump( $rc ),
+ dump( $ps ) );
+
+
+ // Restore original attribute of the value
+ if( $attr != NumberFormatter::INTEGER_DIGITS && $attr != NumberFormatter::FRACTION_DIGITS
+ && $attr != NumberFormatter::FORMAT_WIDTH && $attr != NumberFormatter::SIGNIFICANT_DIGITS_USED )
+ ut_nfmt_set_attribute( $fmt, $attr, $orig_val );
+ }
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+
+?>
+--EXPECT--
+Attribute PARSE_INT_ONLY
+Old attribute value: 0 ; Format result: '12,345.123' ; Parse result: 12345.123
+Setting attribute: ok
+New attribute value: 1 ; Format result: '12,345.123' ; Parse result: 12345
+
+Attribute GROUPING_USED
+Old attribute value: 1 ; Format result: '12,345.123' ; Parse result: 12345.123
+Setting attribute: ok
+New attribute value: 0 ; Format result: '12345.123' ; Parse result: 12345.123
+
+Attribute DECIMAL_ALWAYS_SHOWN
+Old attribute value: 0 ; Format result: '12,345' ; Parse result: 12345
+Setting attribute: ok
+New attribute value: 1 ; Format result: '12,345.' ; Parse result: 12345
+
+Attribute MAX_INTEGER_DIGITS
+Old attribute value: 309 ; Format result: '12,345.123' ; Parse result: 12345.123
+Setting attribute: ok
+New attribute value: 2 ; Format result: '45.123' ; Parse result: 45.123
+
+Attribute MIN_INTEGER_DIGITS
+Old attribute value: 1 ; Format result: '12,345.123' ; Parse result: 12345.123
+Setting attribute: ok
+New attribute value: 20 ; Format result: '00,000,000,000,000,012,345.123' ; Parse result: 12345.123
+
+Attribute INTEGER_DIGITS
+Old attribute value: 1 ; Format result: '12,345.123' ; Parse result: 12345.123
+Setting attribute: ok
+New attribute value: 7 ; Format result: '0,012,345.123' ; Parse result: 12345.123
+
+Attribute MAX_FRACTION_DIGITS
+Old attribute value: 3 ; Format result: '0,012,345.123' ; Parse result: 12345.123
+Setting attribute: ok
+New attribute value: 2 ; Format result: '0,012,345.12' ; Parse result: 12345.12
+
+Attribute MIN_FRACTION_DIGITS
+Old attribute value: 0 ; Format result: '0,012,345.123' ; Parse result: 12345.123
+Setting attribute: ok
+New attribute value: 20 ; Format result: '0,012,345.12345600000000000000' ; Parse result: 12345.123456
+
+Attribute FRACTION_DIGITS
+Old attribute value: 0 ; Format result: '0,012,345.123456' ; Parse result: 12345.123456
+Setting attribute: ok
+New attribute value: 5 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
+
+Attribute MULTIPLIER
+Old attribute value: 1 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
+Setting attribute: ok
+New attribute value: 2 ; Format result: '0,024,690.24691' ; Parse result: 12345.123455
+
+Attribute GROUPING_SIZE
+Old attribute value: 3 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
+Setting attribute: ok
+New attribute value: 2 ; Format result: '0,01,23,45.12346' ; Parse result: 12345.12346
+
+Attribute ROUNDING_MODE
+Old attribute value: 4 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
+Setting attribute: ok
+New attribute value: 1 ; Format result: '0,012,345.12345' ; Parse result: 12345.12345
+
+Attribute ROUNDING_INCREMENT
+Old attribute value: 0 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
+Setting attribute: ok
+New attribute value: 2 ; Format result: '0,012,346.00000' ; Parse result: 12346
+
+Attribute FORMAT_WIDTH
+Old attribute value: 0 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
+Setting attribute: ok
+New attribute value: 27 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
+
+Attribute PADDING_POSITION
+Old attribute value: 0 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
+Setting attribute: ok
+New attribute value: 2 ; Format result: '0,012,345.12346************' ; Parse result: 12345.12346
+
+Attribute SECONDARY_GROUPING_SIZE
+Old attribute value: 0 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
+Setting attribute: ok
+New attribute value: 2 ; Format result: '************00,12,345.12346' ; Parse result: 12345.12346
+
+Attribute SIGNIFICANT_DIGITS_USED
+Old attribute value: 0 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
+Setting attribute: ok
+New attribute value: 1 ; Format result: '*******************12,345.1' ; Parse result: 12345.1
+
+Attribute MIN_SIGNIFICANT_DIGITS
+Old attribute value: 1 ; Format result: '**************************1' ; Parse result: 1
+Setting attribute: ok
+New attribute value: 3 ; Format result: '***********************1.00' ; Parse result: 1
+
+Attribute MAX_SIGNIFICANT_DIGITS
+Old attribute value: 6 ; Format result: '*******************12,345.1' ; Parse result: 12345.1
+Setting attribute: ok
+New attribute value: 4 ; Format result: '*********************12,350' ; Parse result: 12350
diff --git a/ext/intl/tests/formatter_get_set_pattern.phpt b/ext/intl/tests/formatter_get_set_pattern.phpt
new file mode 100644
index 0000000..0ae5b30
--- /dev/null
+++ b/ext/intl/tests/formatter_get_set_pattern.phpt
@@ -0,0 +1,52 @@
+--TEST--
+numfmt_get/set_pattern()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Get/set pattern.
+ */
+
+
+function ut_main()
+{
+ $res_str = '';
+ $test_value = 12345.123456;
+ $fmt = ut_nfmt_create( "en_US", NumberFormatter::PATTERN_DECIMAL );
+
+ // Get default patten.
+ $res_str .= "Default pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n";
+ $res_str .= "Formatting result: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
+
+ // Set a new pattern.
+ $res = ut_nfmt_set_pattern( $fmt, "0.0" );
+ if( $res === false )
+ $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n";
+
+ // Check if the pattern has been changed.
+ $res = ut_nfmt_get_pattern( $fmt );
+ if( $res === false )
+ $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n";
+ $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n";
+ $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
+
+ ut_nfmt_set_pattern($fmt, str_repeat('@', 200));
+ $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n";
+ $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTF--
+Default pattern: '#.####################################################################################################################################################################################################################################################################################################################%s'
+Formatting result: 12345.123456
+New pattern: '#0.0'
+Formatted number: 12345.1
+New pattern: '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
+Formatted number: 12345.123456000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
diff --git a/ext/intl/tests/formatter_get_set_symbol.phpt b/ext/intl/tests/formatter_get_set_symbol.phpt
new file mode 100644
index 0000000..050e8cf
--- /dev/null
+++ b/ext/intl/tests/formatter_get_set_symbol.phpt
@@ -0,0 +1,190 @@
+--TEST--
+numfmt_get/set_symbol() 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
+
+/*
+ * Get/set symbol.
+ */
+
+
+function ut_main()
+{
+ $longstr = str_repeat("blah", 10);
+ $symbols = array(
+ 'DECIMAL_SEPARATOR_SYMBOL' => array( NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, '_._', 12345.123456, NumberFormatter::DECIMAL ),
+ 'GROUPING_SEPARATOR_SYMBOL' => array( NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '_,_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'PATTERN_SEPARATOR_SYMBOL' => array( NumberFormatter::PATTERN_SEPARATOR_SYMBOL, '_;_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'PERCENT_SYMBOL' => array( NumberFormatter::PERCENT_SYMBOL, '_%_', 12345.123456, NumberFormatter::PERCENT ),
+ 'ZERO_DIGIT_SYMBOL' => array( NumberFormatter::ZERO_DIGIT_SYMBOL, '_ZD_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'DIGIT_SYMBOL' => array( NumberFormatter::DIGIT_SYMBOL, '_DS_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'MINUS_SIGN_SYMBOL' => array( NumberFormatter::MINUS_SIGN_SYMBOL, '_-_', -12345.123456, NumberFormatter::DECIMAL ),
+ 'PLUS_SIGN_SYMBOL' => array( NumberFormatter::PLUS_SIGN_SYMBOL, '_+_', 12345.123456, NumberFormatter::SCIENTIFIC ),
+ 'CURRENCY_SYMBOL' => array( NumberFormatter::CURRENCY_SYMBOL, '_$_', 12345.123456, NumberFormatter::CURRENCY ),
+ 'INTL_CURRENCY_SYMBOL' => array( NumberFormatter::INTL_CURRENCY_SYMBOL, '_$_', 12345.123456, NumberFormatter::CURRENCY ),
+ 'MONETARY_SEPARATOR_SYMBOL' => array( NumberFormatter::MONETARY_SEPARATOR_SYMBOL, '_MS_', 12345.123456, NumberFormatter::CURRENCY ),
+ 'EXPONENTIAL_SYMBOL' => array( NumberFormatter::EXPONENTIAL_SYMBOL, '_E_', 12345.123456, NumberFormatter::SCIENTIFIC ),
+ 'PERMILL_SYMBOL' => array( NumberFormatter::PERMILL_SYMBOL, '_PS_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'PAD_ESCAPE_SYMBOL' => array( NumberFormatter::PAD_ESCAPE_SYMBOL, '_PE_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'INFINITY_SYMBOL' => array( NumberFormatter::INFINITY_SYMBOL, '_IS_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'NAN_SYMBOL' => array( NumberFormatter::NAN_SYMBOL, '_N_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'SIGNIFICANT_DIGIT_SYMBOL' => array( NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL, '_SD_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'MONETARY_GROUPING_SEPARATOR_SYMBOL' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, '_MG_', 12345.123456, NumberFormatter::CURRENCY ),
+ 'MONETARY_GROUPING_SEPARATOR_SYMBOL-2' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, "&nbsp;", 12345.123456, NumberFormatter::CURRENCY ),
+ 'MONETARY_GROUPING_SEPARATOR_SYMBOL-3' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, $longstr, 12345.123456, NumberFormatter::CURRENCY ),
+ );
+
+ $res_str = '';
+
+ foreach( $symbols as $symb_name => $data )
+ {
+ list( $symb, $new_val, $number, $attr ) = $data;
+
+ $fmt = ut_nfmt_create( 'en_US', $attr);
+
+ $res_str .= "\nSymbol '$symb_name'\n";
+
+ // Get original symbol value.
+ $orig_val = ut_nfmt_get_symbol( $fmt, $symb );
+ $res_str .= "Default symbol: [$orig_val]\n";
+
+ // Set a new symbol value.
+ $res_val = ut_nfmt_set_symbol( $fmt, $symb, $new_val );
+ if( !$res_val )
+ $res_str .= "set_symbol() error: " . ut_nfmt_get_error_message( $fmt ) . "\n";
+
+ // Get the symbol value back.
+ $new_val_check = ut_nfmt_get_symbol( $fmt, $symb );
+ if( !$new_val_check )
+ $res_str .= "get_symbol() error: " . ut_nfmt_get_error_message( $fmt ) . "\n";
+
+ $res_str .= "New symbol: [$new_val_check]\n";
+
+ // Check if the new value has been set.
+ if( $new_val_check !== $new_val )
+ $res_str .= "ERROR: New $symb_name symbol value has not been set correctly.\n";
+
+ // Format the number using the new value.
+ $s = ut_nfmt_format( $fmt, $number );
+ $res_str .= "A number formatted with the new symbol: $s\n";
+
+ // Restore attribute's symbol.
+ ut_nfmt_set_symbol( $fmt, $symb, $orig_val );
+ }
+ $badvals = array(2147483648, -2147483648, -1, 4294901761);
+ foreach($badvals as $badval) {
+ if(ut_nfmt_get_symbol( $fmt, 2147483648 )) {
+ $res_str .= "Bad value $badval should return false!\n";
+ }
+ }
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+Symbol 'DECIMAL_SEPARATOR_SYMBOL'
+Default symbol: [.]
+New symbol: [_._]
+A number formatted with the new symbol: 12,345_._123
+
+Symbol 'GROUPING_SEPARATOR_SYMBOL'
+Default symbol: [,]
+New symbol: [_,_]
+A number formatted with the new symbol: 12_,_345.123
+
+Symbol 'PATTERN_SEPARATOR_SYMBOL'
+Default symbol: [;]
+New symbol: [_;_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'PERCENT_SYMBOL'
+Default symbol: [%]
+New symbol: [_%_]
+A number formatted with the new symbol: 1,234,512_%_
+
+Symbol 'ZERO_DIGIT_SYMBOL'
+Default symbol: [0]
+New symbol: [_ZD_]
+A number formatted with the new symbol: `a,bcd.`ab
+
+Symbol 'DIGIT_SYMBOL'
+Default symbol: [#]
+New symbol: [_DS_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'MINUS_SIGN_SYMBOL'
+Default symbol: [-]
+New symbol: [_-_]
+A number formatted with the new symbol: _-_12,345.123
+
+Symbol 'PLUS_SIGN_SYMBOL'
+Default symbol: [+]
+New symbol: [_+_]
+A number formatted with the new symbol: 1.2345123456E4
+
+Symbol 'CURRENCY_SYMBOL'
+Default symbol: [$]
+New symbol: [_$_]
+A number formatted with the new symbol: _$_12,345.12
+
+Symbol 'INTL_CURRENCY_SYMBOL'
+Default symbol: [USD]
+New symbol: [_$_]
+A number formatted with the new symbol: $12,345.12
+
+Symbol 'MONETARY_SEPARATOR_SYMBOL'
+Default symbol: [.]
+New symbol: [_MS_]
+A number formatted with the new symbol: $12,345_MS_12
+
+Symbol 'EXPONENTIAL_SYMBOL'
+Default symbol: [E]
+New symbol: [_E_]
+A number formatted with the new symbol: 1.2345123456_E_4
+
+Symbol 'PERMILL_SYMBOL'
+Default symbol: [‰]
+New symbol: [_PS_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'PAD_ESCAPE_SYMBOL'
+Default symbol: [*]
+New symbol: [_PE_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'INFINITY_SYMBOL'
+Default symbol: [∞]
+New symbol: [_IS_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'NAN_SYMBOL'
+Default symbol: [NaN]
+New symbol: [_N_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'SIGNIFICANT_DIGIT_SYMBOL'
+Default symbol: [@]
+New symbol: [_SD_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'MONETARY_GROUPING_SEPARATOR_SYMBOL'
+Default symbol: [,]
+New symbol: [_MG_]
+A number formatted with the new symbol: $12_MG_345.12
+
+Symbol 'MONETARY_GROUPING_SEPARATOR_SYMBOL-2'
+Default symbol: [,]
+New symbol: [&nbsp;]
+A number formatted with the new symbol: $12&nbsp;345.12
+
+Symbol 'MONETARY_GROUPING_SEPARATOR_SYMBOL-3'
+Default symbol: [,]
+New symbol: [blahblahblahblahblahblahblahblahblahblah]
+A number formatted with the new symbol: $12blahblahblahblahblahblahblahblahblahblah345.12
+
diff --git a/ext/intl/tests/formatter_get_set_symbol2.phpt b/ext/intl/tests/formatter_get_set_symbol2.phpt
new file mode 100644
index 0000000..769713b
--- /dev/null
+++ b/ext/intl/tests/formatter_get_set_symbol2.phpt
@@ -0,0 +1,190 @@
+--TEST--
+numfmt_get/set_symbol() 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
+
+/*
+ * Get/set symbol.
+ */
+
+
+function ut_main()
+{
+ $longstr = str_repeat("blah", 10);
+ $symbols = array(
+ 'DECIMAL_SEPARATOR_SYMBOL' => array( NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, '_._', 12345.123456, NumberFormatter::DECIMAL ),
+ 'GROUPING_SEPARATOR_SYMBOL' => array( NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '_,_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'PATTERN_SEPARATOR_SYMBOL' => array( NumberFormatter::PATTERN_SEPARATOR_SYMBOL, '_;_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'PERCENT_SYMBOL' => array( NumberFormatter::PERCENT_SYMBOL, '_%_', 12345.123456, NumberFormatter::PERCENT ),
+ 'ZERO_DIGIT_SYMBOL' => array( NumberFormatter::ZERO_DIGIT_SYMBOL, '_ZD_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'DIGIT_SYMBOL' => array( NumberFormatter::DIGIT_SYMBOL, '_DS_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'MINUS_SIGN_SYMBOL' => array( NumberFormatter::MINUS_SIGN_SYMBOL, '_-_', -12345.123456, NumberFormatter::DECIMAL ),
+ 'PLUS_SIGN_SYMBOL' => array( NumberFormatter::PLUS_SIGN_SYMBOL, '_+_', 12345.123456, NumberFormatter::SCIENTIFIC ),
+ 'CURRENCY_SYMBOL' => array( NumberFormatter::CURRENCY_SYMBOL, '_$_', 12345.123456, NumberFormatter::CURRENCY ),
+ 'INTL_CURRENCY_SYMBOL' => array( NumberFormatter::INTL_CURRENCY_SYMBOL, '_$_', 12345.123456, NumberFormatter::CURRENCY ),
+ 'MONETARY_SEPARATOR_SYMBOL' => array( NumberFormatter::MONETARY_SEPARATOR_SYMBOL, '_MS_', 12345.123456, NumberFormatter::CURRENCY ),
+ 'EXPONENTIAL_SYMBOL' => array( NumberFormatter::EXPONENTIAL_SYMBOL, '_E_', 12345.123456, NumberFormatter::SCIENTIFIC ),
+ 'PERMILL_SYMBOL' => array( NumberFormatter::PERMILL_SYMBOL, '_PS_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'PAD_ESCAPE_SYMBOL' => array( NumberFormatter::PAD_ESCAPE_SYMBOL, '_PE_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'INFINITY_SYMBOL' => array( NumberFormatter::INFINITY_SYMBOL, '_IS_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'NAN_SYMBOL' => array( NumberFormatter::NAN_SYMBOL, '_N_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'SIGNIFICANT_DIGIT_SYMBOL' => array( NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL, '_SD_', 12345.123456, NumberFormatter::DECIMAL ),
+ 'MONETARY_GROUPING_SEPARATOR_SYMBOL' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, '_MG_', 12345.123456, NumberFormatter::CURRENCY ),
+ 'MONETARY_GROUPING_SEPARATOR_SYMBOL-2' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, "&nbsp;", 12345.123456, NumberFormatter::CURRENCY ),
+ 'MONETARY_GROUPING_SEPARATOR_SYMBOL-3' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, $longstr, 12345.123456, NumberFormatter::CURRENCY ),
+ );
+
+ $res_str = '';
+
+ foreach( $symbols as $symb_name => $data )
+ {
+ list( $symb, $new_val, $number, $attr ) = $data;
+
+ $fmt = ut_nfmt_create( 'en_US', $attr);
+
+ $res_str .= "\nSymbol '$symb_name'\n";
+
+ // Get original symbol value.
+ $orig_val = ut_nfmt_get_symbol( $fmt, $symb );
+ $res_str .= "Default symbol: [$orig_val]\n";
+
+ // Set a new symbol value.
+ $res_val = ut_nfmt_set_symbol( $fmt, $symb, $new_val );
+ if( !$res_val )
+ $res_str .= "set_symbol() error: " . ut_nfmt_get_error_message( $fmt ) . "\n";
+
+ // Get the symbol value back.
+ $new_val_check = ut_nfmt_get_symbol( $fmt, $symb );
+ if( !$new_val_check )
+ $res_str .= "get_symbol() error: " . ut_nfmt_get_error_message( $fmt ) . "\n";
+
+ $res_str .= "New symbol: [$new_val_check]\n";
+
+ // Check if the new value has been set.
+ if( $new_val_check !== $new_val )
+ $res_str .= "ERROR: New $symb_name symbol value has not been set correctly.\n";
+
+ // Format the number using the new value.
+ $s = ut_nfmt_format( $fmt, $number );
+ $res_str .= "A number formatted with the new symbol: $s\n";
+
+ // Restore attribute's symbol.
+ ut_nfmt_set_symbol( $fmt, $symb, $orig_val );
+ }
+ $badvals = array(2147483648, -2147483648, -1, 4294901761);
+ foreach($badvals as $badval) {
+ if(ut_nfmt_get_symbol( $fmt, 2147483648 )) {
+ $res_str .= "Bad value $badval should return false!\n";
+ }
+ }
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+Symbol 'DECIMAL_SEPARATOR_SYMBOL'
+Default symbol: [.]
+New symbol: [_._]
+A number formatted with the new symbol: 12,345_._123
+
+Symbol 'GROUPING_SEPARATOR_SYMBOL'
+Default symbol: [,]
+New symbol: [_,_]
+A number formatted with the new symbol: 12_,_345.123
+
+Symbol 'PATTERN_SEPARATOR_SYMBOL'
+Default symbol: [;]
+New symbol: [_;_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'PERCENT_SYMBOL'
+Default symbol: [%]
+New symbol: [_%_]
+A number formatted with the new symbol: 1,234,512_%_
+
+Symbol 'ZERO_DIGIT_SYMBOL'
+Default symbol: [0]
+New symbol: [_ZD_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'DIGIT_SYMBOL'
+Default symbol: [#]
+New symbol: [_DS_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'MINUS_SIGN_SYMBOL'
+Default symbol: [-]
+New symbol: [_-_]
+A number formatted with the new symbol: _-_12,345.123
+
+Symbol 'PLUS_SIGN_SYMBOL'
+Default symbol: [+]
+New symbol: [_+_]
+A number formatted with the new symbol: 1.2345123456E4
+
+Symbol 'CURRENCY_SYMBOL'
+Default symbol: [$]
+New symbol: [_$_]
+A number formatted with the new symbol: _$_12,345.12
+
+Symbol 'INTL_CURRENCY_SYMBOL'
+Default symbol: [USD]
+New symbol: [_$_]
+A number formatted with the new symbol: $12,345.12
+
+Symbol 'MONETARY_SEPARATOR_SYMBOL'
+Default symbol: [.]
+New symbol: [_MS_]
+A number formatted with the new symbol: $12,345_MS_12
+
+Symbol 'EXPONENTIAL_SYMBOL'
+Default symbol: [E]
+New symbol: [_E_]
+A number formatted with the new symbol: 1.2345123456_E_4
+
+Symbol 'PERMILL_SYMBOL'
+Default symbol: [‰]
+New symbol: [_PS_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'PAD_ESCAPE_SYMBOL'
+Default symbol: [*]
+New symbol: [_PE_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'INFINITY_SYMBOL'
+Default symbol: [∞]
+New symbol: [_IS_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'NAN_SYMBOL'
+Default symbol: [NaN]
+New symbol: [_N_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'SIGNIFICANT_DIGIT_SYMBOL'
+Default symbol: [@]
+New symbol: [_SD_]
+A number formatted with the new symbol: 12,345.123
+
+Symbol 'MONETARY_GROUPING_SEPARATOR_SYMBOL'
+Default symbol: [,]
+New symbol: [_MG_]
+A number formatted with the new symbol: $12_MG_345.12
+
+Symbol 'MONETARY_GROUPING_SEPARATOR_SYMBOL-2'
+Default symbol: [,]
+New symbol: [&nbsp;]
+A number formatted with the new symbol: $12&nbsp;345.12
+
+Symbol 'MONETARY_GROUPING_SEPARATOR_SYMBOL-3'
+Default symbol: [,]
+New symbol: [blahblahblahblahblahblahblahblahblahblah]
+A number formatted with the new symbol: $12blahblahblahblahblahblahblahblahblahblah345.12
+
diff --git a/ext/intl/tests/formatter_get_set_text_attribute.phpt b/ext/intl/tests/formatter_get_set_text_attribute.phpt
new file mode 100644
index 0000000..539ff52
--- /dev/null
+++ b/ext/intl/tests/formatter_get_set_text_attribute.phpt
@@ -0,0 +1,121 @@
+--TEST--
+numfmt_get/set_text_attribute()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Get/set text attribute.
+ */
+
+
+function ut_main()
+{
+ // Array with data for testing
+ $long_str = str_repeat('blah', 100);
+ $attributes = array(
+ 'POSITIVE_PREFIX' => array( NumberFormatter::POSITIVE_PREFIX, '_+_', 12345.1234 ),
+ 'POSITIVE_SUFFIX' => array( NumberFormatter::POSITIVE_SUFFIX, '_+_', 12345.1234 ),
+ 'NEGATIVE_PREFIX' => array( NumberFormatter::NEGATIVE_PREFIX, '_-_', -12345.1234 ),
+ 'NEGATIVE_SUFFIX' => array( NumberFormatter::NEGATIVE_SUFFIX, '_-_', -12345.1234 ),
+ 'PADDING_CHARACTER' => array( NumberFormatter::PADDING_CHARACTER, '^', 12345.1234 ),
+ 'POSITIVE_PREFIX-2' => array( NumberFormatter::POSITIVE_PREFIX, $long_str, 12345.1234 ),
+// 'CURRENCY_CODE' => array( NumberFormatter::CURRENCY_CODE, '_C_', 12345.1234 )
+// 'DEFAULT_RULESET' => array( NumberFormatter::DEFAULT_RULESET, '_DR_', 12345.1234 ),
+// 'PUBLIC_RULESETS' => array( NumberFormatter::PUBLIC_RULESETS, '_PR_', 12345.1234 )
+ );
+
+ $res_str = '';
+
+ $fmt = ut_nfmt_create( "en_US", NumberFormatter::DECIMAL );
+
+ foreach( $attributes as $attr_name => $data )
+ {
+ list( $attr, $new_val, $test_number ) = $data;
+ $res_str .= "\nAttribute $attr_name\n";
+
+ if( $attr == NumberFormatter::PADDING_CHARACTER )
+ ut_nfmt_set_attribute( $fmt, NumberFormatter::FORMAT_WIDTH, 21 );
+
+ // Get default attribute's value
+ $def_val = ut_nfmt_get_text_attribute( $fmt, $attr );
+ if( $def_val === false )
+ $res_str .= "get_text_attribute() error: " . ut_nfmt_get_error_message( $fmt ) . "\n";
+
+ $res_str .= "Default value: [$def_val]\n";
+ $res_str .= "Formatting number with default value: " . ut_nfmt_format( $fmt, $test_number ) . "\n";
+
+ // Set new attribute's value and see if it works out.
+ $res_val = ut_nfmt_set_text_attribute( $fmt, $attr, $new_val );
+ if( !$res_val )
+ $res_str .= "set_text_attribute() error: " . ut_nfmt_get_error_message( $fmt ) . "\n";
+
+ // Get attribute value back.
+ $new_val_check = ut_nfmt_get_text_attribute( $fmt, $attr );
+ $res_str .= "New value: [$new_val_check]\n";
+ $res_str .= "Formatting number with new value: " . ut_nfmt_format( $fmt, $test_number ) . "\n";
+
+ // Check if the new value has been set.
+ if( $new_val !== $new_val_check )
+ $res_str .= "ERROR: New $attr_name symbol value has not been set correctly.\n";
+
+ // Restore attribute's value to default
+ ut_nfmt_set_text_attribute( $fmt, $attr, $def_val );
+
+ if( $attr == NumberFormatter::PADDING_CHARACTER )
+ ut_nfmt_set_attribute( $fmt, NumberFormatter::FORMAT_WIDTH, 0 );
+ }
+
+ //
+ $fmt = ut_nfmt_create( "uk_UA", NumberFormatter::CURRENCY );
+ $res_str .= sprintf( "\nCurrency ISO-code for locale 'uk_UA' is: %s\n",
+ ut_nfmt_get_text_attribute( $fmt, NumberFormatter::CURRENCY_CODE ) );
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+Attribute POSITIVE_PREFIX
+Default value: []
+Formatting number with default value: 12,345.123
+New value: [_+_]
+Formatting number with new value: _+_12,345.123
+
+Attribute POSITIVE_SUFFIX
+Default value: []
+Formatting number with default value: 12,345.123
+New value: [_+_]
+Formatting number with new value: 12,345.123_+_
+
+Attribute NEGATIVE_PREFIX
+Default value: [-]
+Formatting number with default value: -12,345.123
+New value: [_-_]
+Formatting number with new value: _-_12,345.123
+
+Attribute NEGATIVE_SUFFIX
+Default value: []
+Formatting number with default value: -12,345.123
+New value: [_-_]
+Formatting number with new value: -12,345.123_-_
+
+Attribute PADDING_CHARACTER
+Default value: [*]
+Formatting number with default value: ***********12,345.123
+New value: [^]
+Formatting number with new value: ^^^^^^^^^^^12,345.123
+
+Attribute POSITIVE_PREFIX-2
+Default value: []
+Formatting number with default value: 12,345.123
+New value: [blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah]
+Formatting number with new value: blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah12,345.123
+
+Currency ISO-code for locale 'uk_UA' is: UAH
+
+
diff --git a/ext/intl/tests/formatter_parse.phpt b/ext/intl/tests/formatter_parse.phpt
new file mode 100644
index 0000000..2ab9cce
--- /dev/null
+++ b/ext/intl/tests/formatter_parse.phpt
@@ -0,0 +1,42 @@
+--TEST--
+numfmt_parse()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Number parsing.
+ */
+
+
+function ut_main()
+{
+ $res_str = '';
+
+ // Test parsing float number.
+ $fmt = ut_nfmt_create( "en_US", NumberFormatter::DECIMAL );
+ $res_str .= ut_nfmt_parse( $fmt, "123E-3" ) . "\n";
+
+ // Test parsing float number as integer.
+ $fmt = ut_nfmt_create( "en_US", NumberFormatter::DECIMAL );
+ $res_str .= ut_nfmt_parse( $fmt, "1.23", NumberFormatter::TYPE_INT32 ) . "\n";
+
+ // Test specifying non-zero parsing start position.
+ $fmt = ut_nfmt_create( "en_US", NumberFormatter::DECIMAL );
+ $pos = 2;
+ $res_str .= ut_nfmt_parse( $fmt, "0.123 here", NumberFormatter::TYPE_DOUBLE, $pos ) . "\n";
+ $res_str .= "$pos\n";
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+0.123
+1
+123
+5
diff --git a/ext/intl/tests/formatter_parse_currency.phpt b/ext/intl/tests/formatter_parse_currency.phpt
new file mode 100644
index 0000000..4ebd1a4
--- /dev/null
+++ b/ext/intl/tests/formatter_parse_currency.phpt
@@ -0,0 +1,37 @@
+--TEST--
+numfmt_parse_currency()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Currency parsing.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $fmt = ut_nfmt_create( "en_US", NumberFormatter::CURRENCY );
+ $pos = 0;
+ $currency = '';
+ $num = ut_nfmt_parse_currency( $fmt, '$9,988,776.65', $currency, $pos );
+ $res_str .= "$num $currency\n";
+
+ $fmt = ut_nfmt_create( "en_US", NumberFormatter::CURRENCY );
+ $pos = 1;
+ $currency = '';
+ $num = ut_nfmt_parse_currency( $fmt, ' $123.45', $currency, $pos );
+ $res_str .= "$num $currency\n";
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+9988776.65 USD
+123.45 USD
diff --git a/ext/intl/tests/grapheme.phpt b/ext/intl/tests/grapheme.phpt
new file mode 100644
index 0000000..def9110
--- /dev/null
+++ b/ext/intl/tests/grapheme.phpt
@@ -0,0 +1,1192 @@
+--TEST--
+grapheme()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Test grapheme functions (procedural only)
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4)
+ $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5)
+ $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6)
+ $char_O_diaeresis = "\xC3\x96"; // 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6)
+
+ $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B)
+ $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
+
+ $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126)
+ $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9)
+
+ $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A)
+
+ $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01)
+
+ $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B)
+
+ // the word 'hindi' using Devanagari characters:
+ $hindi = "\xe0\xa4\xb9\xe0\xa4\xbf\xe0\xa4\xa8\xe0\xa5\x8d\xe0\xa4\xa6\xe0\xa5\x80";
+
+ $char_a_ring_nfd = "a\xCC\x8A";
+ $char_A_ring_nfd = "A\xCC\x8A";
+ $char_o_diaeresis_nfd = "o\xCC\x88";
+ $char_O_diaeresis_nfd = "O\xCC\x88";
+ $char_diaeresis = "\xCC\x88";
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_strlen($string) {}' . "\n\n";
+
+
+ $res_str .= "\"hindi\" in devanagari strlen " . grapheme_strlen($hindi) . "\n";
+ $res_str .= "\"ab\" + \"hindi\" + \"cde\" strlen " . grapheme_strlen('ab' . $hindi . 'cde') . "\n";
+ $res_str .= "\"\" strlen " . grapheme_strlen("") . "\n";
+ $res_str .= "char_a_ring_nfd strlen " . grapheme_strlen($char_a_ring_nfd) . "\n";
+ $res_str .= "char_a_ring_nfd + \"bc\" strlen " . grapheme_strlen($char_a_ring_nfd . 'bc') . "\n";
+ $res_str .= "\"abc\" strlen " . grapheme_strlen('abc') . "\n";
+
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_strpos($haystack, $needle, $offset = 0) {}' . "\n\n";
+
+ $tests = array(
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ),
+ array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ),
+ array( "abc", $char_a_ring_nfd, "false" ),
+ array( $char_a_ring_nfd . "bc", "a", "false" ),
+ array( "abc", "d", "false" ),
+ array( "abc", "c", 2 ),
+ array( "abc", "b", 1 ),
+ array( "abc", "a", 0 ),
+ array( "abc", "a", 0, 0 ),
+ array( "abc", "a", 1, "false" ),
+ array( "ababc", "a", 1, 2 ),
+ array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ),
+ array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ),
+
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ),
+ array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ),
+ array( "abc", $char_a_ring_nfd . "bc", "false" ),
+ array( $char_a_ring_nfd . "bc", "abcdefg", "false" ),
+ array( "abc", "defghijklmnopq", "false" ),
+ array( "abc", "ab", 0 ),
+ array( "abc", "bc", 1 ),
+ array( "abc", "abc", 0 ),
+ array( "abc", "abcd", "false" ),
+ array( "abc", "ab", 0, 0 ),
+ array( "abc", "abc", 0, 0 ),
+ array( "abc", "abc", 1, "false" ),
+ array( "ababc", "ab", 1, 2 ),
+ array( "ababc", "abc", 1, 2 ),
+ array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ),
+ array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ),
+ );
+
+ foreach( $tests as $test ) {
+ $arg1 = urlencode($test[1]);
+ $arg0 = urlencode($test[0]);
+ $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strpos";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_strpos($test[0], $test[1]);
+ }
+ else {
+ $res_str .= " from $test[2]";
+ $result = grapheme_strpos($test[0], $test[1], $test[2]);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= $result;
+ }
+ $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n";
+ }
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_stripos($haystack, $needle, $offset = 0) {}' . "\n\n";
+
+ $tests = array(
+ array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ),
+ array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ),
+ array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ),
+ array( "Abc", $char_a_ring_nfd, "false" ),
+ array( $char_a_ring_nfd . "bc", "A", "false" ),
+ array( "abc", "D", "false" ),
+ array( "abC", "c", 2 ),
+ array( "abc", "B", 1 ),
+ array( "Abc", "a", 0 ),
+ array( "abc", "A", 0, 0 ),
+ array( "Abc", "a", 1, "false" ),
+ array( "ababc", "A", 1, 2 ),
+
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ),
+ array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ),
+ array( "abc", $char_a_ring_nfd . "BC", "false" ),
+ array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ),
+ array( "aBC", "Defghijklmnopq", "false" ),
+ array( "abC", "Ab", 0 ),
+ array( "aBC", "bc", 1 ),
+ array( "abC", "Abc", 0 ),
+ array( "abC", "aBcd", "false" ),
+ array( "ABc", "ab", 0, 0 ),
+ array( "aBc", "abC", 0, 0 ),
+ array( "abc", "aBc", 1, "false" ),
+ array( "ABabc", "AB", 1, 2 ),
+ array( "abaBc", "aBc", 1, 2 ),
+ array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ),
+ array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ),
+ );
+
+ foreach( $tests as $test ) {
+ $arg1 = urlencode($test[1]);
+ $arg0 = urlencode($test[0]);
+ $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stripos";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_stripos($test[0], $test[1]);
+ }
+ else {
+ $res_str .= " from $test[2]";
+ $result = grapheme_stripos($test[0], $test[1], $test[2]);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= $result;
+ }
+ $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n";
+ }
+
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_strrpos($haystack, $needle, $offset = 0) {}' . "\n\n";
+
+
+ $tests = array(
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ),
+ array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ),
+ array( "abc", $char_a_ring_nfd, "false" ),
+ array( $char_a_ring_nfd . "bc", "a", "false" ),
+ array( "abc", "d", "false" ),
+ array( "abc", "c", 2 ),
+ array( "abc", "b", 1 ),
+ array( "abc", "a", 0 ),
+ array( "abc", "a", 0, 0 ),
+ array( "abc", "a", 1, "false" ),
+ array( "ababc", "a", 1, 2 ),
+ array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ),
+ array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ),
+
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ),
+ array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ),
+ array( "abc", $char_a_ring_nfd . "bc", "false" ),
+ array( $char_a_ring_nfd . "bc", "abcdefg", "false" ),
+ array( "abc", "defghijklmnopq", "false" ),
+ array( "abc", "ab", 0 ),
+ array( "abc", "bc", 1 ),
+ array( "abc", "abc", 0 ),
+ array( "abc", "abcd", "false" ),
+ array( "abc", "ab", 0, 0 ),
+ array( "abc", "abc", 0, 0 ),
+ array( "abc", "abc", 1, "false" ),
+ array( "ababc", "ab", 1, 2 ),
+ array( "ababc", "abc", 1, 2 ),
+ array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ),
+ array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ),
+ );
+
+ foreach( $tests as $test ) {
+ $arg1 = urlencode($test[1]);
+ $arg0 = urlencode($test[0]);
+ $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strrpos";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_strrpos($test[0], $test[1]);
+ }
+ else {
+ $res_str .= " from $test[2]";
+ $result = grapheme_strrpos($test[0], $test[1], $test[2]);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= $result;
+ }
+ $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n";
+ }
+
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_strripos($haystack, $needle, $offset = 0) {}' . "\n\n";
+
+ $tests = array(
+ array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ),
+ array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ),
+ array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ),
+ array( "Abc", $char_a_ring_nfd, "false" ),
+ array( $char_a_ring_nfd . "bc", "A", "false" ),
+ array( "abc", "D", "false" ),
+ array( "abC", "c", 2 ),
+ array( "abc", "B", 1 ),
+ array( "Abc", "a", 0 ),
+ array( "abc", "A", 0, 0 ),
+ array( "Abc", "a", 1, "false" ),
+ array( "ababc", "A", 1, 2 ),
+
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ),
+ array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ),
+ array( "abc", $char_a_ring_nfd . "BC", "false" ),
+ array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ),
+ array( "aBC", "Defghijklmnopq", "false" ),
+ array( "abC", "Ab", 0 ),
+ array( "aBC", "bc", 1 ),
+ array( "abC", "Abc", 0 ),
+ array( "abC", "aBcd", "false" ),
+ array( "ABc", "ab", 0, 0 ),
+ array( "aBc", "abC", 0, 0 ),
+ array( "abc", "aBc", 1, "false" ),
+ array( "ABabc", "AB", 1, 2 ),
+ array( "abaBc", "aBc", 1, 2 ),
+ array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ),
+ array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ),
+ );
+
+ foreach( $tests as $test ) {
+ $arg1 = urlencode($test[1]);
+ $arg0 = urlencode($test[0]);
+ $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strripos";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_strripos($test[0], $test[1]);
+ }
+ else {
+ $res_str .= " from $test[2]";
+ $result = grapheme_strripos($test[0], $test[1], $test[2]);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= $result;
+ }
+ $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n";
+ }
+
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_substr($string, $start, $length = -1) {}' . "\n\n";
+
+ $tests = array(
+
+ array( "abc", 3, "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ),
+ array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 2, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ),
+ array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", 2, "a" . $char_A_ring_nfd . "bc" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 5, "O" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, 4, $char_O_diaeresis_nfd ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "bc" ),
+ array( "a" . $char_A_ring_nfd . "bc", 1, $char_A_ring_nfd . "bc" ),
+ array( "Abc", -5, "false" ),
+ array( $char_a_ring_nfd . "bc", 3, "false" ),
+ array( "abc", 4, "false" ),
+ array( "abC", 2, "C" ),
+ array( "abc", 1, "bc" ),
+ array( "Abc", 1, 1, "b" ),
+ array( "abc", 0, 2, "ab" ),
+ array( "Abc", -4, 1, "false" ),
+ array( "ababc", 1, 2, "ba" ),
+ array( "ababc", 0, 10, "ababc" ),
+
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, 10 , "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, "Opq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -1, "Op" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -2, "O" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -3, "" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -4, "false" ),
+
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -4, "a" . $char_a_ring_nfd . "bc" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -5, "a" . $char_a_ring_nfd . "b" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -6, "a" . $char_a_ring_nfd ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -7, "a" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -8, "" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -9, "false" ),
+
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -7, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -6, "bc" . $char_o_diaeresis_nfd . "Opq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -5, "c" . $char_o_diaeresis_nfd . "Opq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -4, $char_o_diaeresis_nfd . "Opq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -3, "Opq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -2, "pq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -1, "q" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -999, "false" ),
+
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 7, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 6, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 5, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 4, "a" . $char_a_ring_nfd . "bc" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 3, "a" . $char_a_ring_nfd . "b" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 2, "a" . $char_a_ring_nfd ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 1, "a" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 0, "" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -999, "false" ),
+
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -4, "a" . $char_a_ring_nfd . "bc" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -5, "a" . $char_a_ring_nfd . "b" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -6, "a" . $char_a_ring_nfd ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -7, "a" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -8, "" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -9, "false" ),
+
+ );
+
+ foreach( $tests as $test ) {
+ $arg0 = urlencode($test[0]);
+ $res_str .= "substring of \"$arg0\" from \"$test[1]\" - grapheme_substr";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_substr($test[0], $test[1]);
+ }
+ else {
+ $res_str .= " with length $test[2]";
+ $result = grapheme_substr($test[0], $test[1], $test[2]);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= urlencode($result);
+ }
+ $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
+ }
+
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n";
+
+ $tests = array(
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", "o" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, $char_o_diaeresis_nfd ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"),
+ array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"),
+ array( "abc", $char_a_ring_nfd, "false" ),
+ array( $char_a_ring_nfd . "bc", "a", "false" ),
+ array( "abc", "d", "false" ),
+ array( "abc", "c", "c" ),
+ array( "abc", "b", "bc" ),
+ array( "abc", "a", "abc" ),
+ array( "abc", "ab", "abc" ),
+ array( "abc", "abc", "abc" ),
+ array( "abc", "bc", "bc" ),
+ array( "abc", "a", FALSE, "abc" ),
+ array( "abc", "a", TRUE, "" ),
+ array( "abc", "b", TRUE, "a" ),
+ array( "abc", "c", TRUE, "ab" ),
+ array( "ababc", "bab", TRUE, "a" ),
+ array( "ababc", "abc", TRUE, "ab" ),
+ array( "ababc", "abc", FALSE, "abc" ),
+
+ array( "ab" . $char_a_ring_nfd . "c", "d", "false" ),
+ array( "bc" . $char_a_ring_nfd . "a", "a", "a" ),
+ array( "a" . $char_a_ring_nfd . "bc", "b", "bc" ),
+ array( $char_a_ring_nfd . "bc", "a", "false" ),
+ array( $char_a_ring_nfd . "abc", "ab", "abc" ),
+ array( "abc" . $char_a_ring_nfd, "abc", "abc" . $char_a_ring_nfd),
+ array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc" ),
+ array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_a_ring_nfd . "bc"),
+ array( "a" . $char_a_ring_nfd . "bc", "a", TRUE, "" ),
+ array( $char_a_ring_nfd . "abc", "b", TRUE, $char_a_ring_nfd . "a" ),
+ array( "ab" . $char_a_ring_nfd . "c", "c", TRUE, "ab" . $char_a_ring_nfd ),
+ array( "aba" . $char_a_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ),
+ array( "ababc" . $char_a_ring_nfd, "abc" . $char_a_ring_nfd, TRUE, "ab" ),
+ array( "abab" . $char_a_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "ab" . $char_a_ring_nfd . "c" ),
+
+ );
+
+ foreach( $tests as $test ) {
+ $arg1 = urlencode($test[1]);
+ $arg0 = urlencode($test[0]);
+ $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strstr";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_strstr($test[0], $test[1]);
+ }
+ else {
+ $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" );
+ $result = grapheme_strstr($test[0], $test[1], $test[2]);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= urlencode($result);
+ }
+ $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
+ }
+
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_stristr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n";
+
+ $tests = array(
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd, $char_o_diaeresis_nfd ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", "O" ),
+ array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ),
+ array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"),
+ array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, $char_a_ring_nfd . "bc"),
+ array( "abc", $char_a_ring_nfd, "false" ),
+ array( $char_a_ring_nfd . "bc", "A", "false" ),
+ array( "abc", "d", "false" ),
+ array( "abc", "C", "c" ),
+ array( "aBc", "b", "Bc" ),
+ array( "abc", "A", "abc" ),
+ array( "abC", "ab", "abC" ),
+ array( "abc", "aBc", "abc" ),
+ array( "abC", "bc", "bC" ),
+ array( "abc", "A", FALSE, "abc" ),
+ array( "abc", "a", TRUE, "" ),
+ array( "aBc", "b", TRUE, "a" ),
+ array( "abc", "C", TRUE, "ab" ),
+ array( "aBabc", "bab", TRUE, "a" ),
+ array( "ababc", "aBc", TRUE, "ab" ),
+ array( "ababc", "abC", FALSE, "abc" ),
+
+ array( "ab" . $char_a_ring_nfd . "c", "d", "false" ),
+ array( "bc" . $char_a_ring_nfd . "A", "a", "A" ),
+ array( "a" . $char_a_ring_nfd . "bc", "B", "bc" ),
+ array( $char_A_ring_nfd . "bc", "a", "false" ),
+ array( $char_a_ring_nfd . "abc", "Ab", "abc" ),
+ array( "abc" . $char_A_ring_nfd, "abc", "abc" . $char_A_ring_nfd),
+ array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd . "bc", $char_a_ring_nfd . "bc" ),
+ array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_A_ring_nfd . "bc" ),
+ array( "a" . $char_a_ring_nfd . "bc", "A", TRUE, "" ),
+ array( $char_a_ring_nfd . "aBc", "b", TRUE, $char_a_ring_nfd . "a" ),
+ array( "ab" . $char_a_ring_nfd . "c", "C", TRUE, "ab" . $char_a_ring_nfd ),
+ array( "aba" . $char_A_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ),
+ array( "ababc" . $char_a_ring_nfd, "aBc" . $char_A_ring_nfd, TRUE, "ab" ),
+ array( "abAB" . $char_A_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "AB" . $char_A_ring_nfd . "c" ),
+
+ );
+
+ foreach( $tests as $test ) {
+ $arg1 = urlencode($test[1]);
+ $arg0 = urlencode($test[0]);
+ $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stristr";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_stristr($test[0], $test[1]);
+ }
+ else {
+ $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" );
+ $result = grapheme_stristr($test[0], $test[1], $test[2]);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= urlencode($result);
+ }
+ $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
+ }
+
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_COUNT, $start = 0[, $next])' . "\n\n";
+
+ $tests = array(
+ // haystack, count, [[offset], [next]], result
+ array( "abc", 3, "abc" ),
+ array( "abc", 2, "ab" ),
+ array( "abc", 1, "a" ),
+ array( "abc", 0, "" ),
+ array( "abc", 1, 0, "a" ),
+ array( "abc", 1, 1, "b" ),
+ array( "abc", 1, 2, "c" ),
+ array( "abc", 0, 2, "" ),
+
+ array( "abc", 3, 0, 3, "abc" ),
+ array( "abc", 2, 0, 2, "ab" ),
+ array( "abc", 1, 0, 1, "a" ),
+ array( "abc", 0, 0, 0, "" ),
+ array( "abc", 1, 0, 1, "a" ),
+ array( "abc", 1, 1, 2, "b" ),
+ array( "abc", 1, 2, 3, "c" ),
+ array( "abc", 0, 2, 2, "" ),
+ array( "http://news.bbc.co.uk/2/hi/middle_east/7831588.stm", 48, 48 , 50 , "tm" ),
+
+ array( $char_a_ring_nfd . "bc", 3, $char_a_ring_nfd . "bc" ),
+ array( $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "b" ),
+ array( $char_a_ring_nfd . "bc", 1, $char_a_ring_nfd . "" ),
+ array( $char_a_ring_nfd . "bc", 3, 0, 5, $char_a_ring_nfd . "bc" ),
+ array( $char_a_ring_nfd . "bc", 2, 0, 4, $char_a_ring_nfd . "b" ),
+ array( $char_a_ring_nfd . "bc", 1, 0, 3, $char_a_ring_nfd . "" ),
+ array( $char_a_ring_nfd . "bcde", 2, 3, 5, "bc" ),
+ array( $char_a_ring_nfd . "bcde", 2, 4, 6, "cd" ),
+ array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, 5, 11, "de" . $char_a_ring_nfd . "f" ),
+
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, $char_a_ring_nfd . $char_o_diaeresis_nfd ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 1, $char_a_ring_nfd . "" ),
+
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 0, $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 2, $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 3, $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 4, $char_diaeresis),
+
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 4, $char_diaeresis . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 7, $char_diaeresis . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 8, $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"),
+
+ );
+
+ $next = -1;
+ foreach( $tests as $test ) {
+ $arg0 = urlencode($test[0]);
+ $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_extract($test[0], $test[1]);
+ }
+ elseif ( 4 == count ( $test ) ) {
+ $res_str .= " starting at byte position $test[2]";
+ $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2]);
+ }
+ else {
+ $res_str .= " starting at byte position $test[2] with \$next";
+ $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2], $next);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= urlencode($result);
+ }
+ $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]);
+ if ( 5 == count ( $test ) ) {
+ $res_str .= " \$next=$next == $test[3] ";
+ if ( $next != $test[3] ) {
+ $res_str .= "***FAILED***";
+ }
+ }
+ $res_str .= "\n";
+ }
+
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXBYTES, $start = 0)' . "\n\n";
+
+ $tests = array(
+ array( "abc", 3, "abc" ),
+ array( "abc", 2, "ab" ),
+ array( "abc", 1, "a" ),
+ array( "abc", 0, "" ),
+ array( $char_a_ring_nfd . "bc", 5, $char_a_ring_nfd . "bc" ),
+ array( $char_a_ring_nfd . "bc", 4, $char_a_ring_nfd . "b" ),
+ array( $char_a_ring_nfd . "bc", 1, "" ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 9, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 10, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 11, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 3, $char_a_ring_nfd . "" ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 4, $char_a_ring_nfd . "" ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 5, $char_a_ring_nfd . "" ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ),
+ array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 7, $char_a_ring_nfd . $char_o_diaeresis_nfd . "c" ),
+
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 0, $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 2, $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 3, $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 4, $char_diaeresis),
+
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 4, $char_diaeresis . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 7, $char_diaeresis . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 8, $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis),
+ array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"),
+
+ );
+
+ foreach( $tests as $test ) {
+ $arg0 = urlencode($test[0]);
+ $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES);
+ }
+ else {
+ $res_str .= " starting at byte position $test[2]";
+ $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES, $test[2]);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= urlencode($result);
+ }
+ $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
+ }
+
+
+ //=====================================================================================
+ $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXCHARS, $start = 0)' . "\n\n";
+
+ $tests = array(
+ array( "abc", 3, "abc" ),
+ array( "abc", 2, "ab" ),
+ array( "abc", 1, "a" ),
+ array( "abc", 0, "" ),
+ array( "abc" . $char_o_diaeresis_nfd, 0, "" ),
+ array( "abc" . $char_o_diaeresis_nfd, 1, "a" ),
+ array( "abc" . $char_o_diaeresis_nfd, 2, "ab" ),
+ array( "abc" . $char_o_diaeresis_nfd, 3, "abc" ),
+ array( "abc" . $char_o_diaeresis_nfd, 4, "abc" ),
+ array( "abc" . $char_o_diaeresis_nfd, 5, "abc" . $char_o_diaeresis_nfd),
+ array( "abc" . $char_o_diaeresis_nfd, 6, "abc" . $char_o_diaeresis_nfd),
+ array( $char_o_diaeresis_nfd . "abc", 0, "" ),
+ array( $char_o_diaeresis_nfd . "abc", 1, "" ),
+ array( $char_o_diaeresis_nfd . "abc", 2, $char_o_diaeresis_nfd ),
+ array( $char_o_diaeresis_nfd . "abc", 3, $char_o_diaeresis_nfd . "a" ),
+ array( $char_o_diaeresis_nfd . "abc", 4, $char_o_diaeresis_nfd . "ab" ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 5, $char_o_diaeresis_nfd . "abc" ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 6, $char_o_diaeresis_nfd . "abc" ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 7, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ),
+
+ array( "abc", 3, 0, "abc" ),
+ array( "abc", 2, 1, "bc" ),
+ array( "abc", 1, 2, "c" ),
+ array( "abc", 0, 3, "false" ),
+ array( "abc", 1, 3, "false" ),
+ array( "abc", 1, 999, "false" ),
+ array( $char_o_diaeresis_nfd . "abc", 1, 6, "false" ),
+ array( $char_o_diaeresis_nfd . "abc", 1, 999, "false" ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 0, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 1, $char_diaeresis . "abc" . $char_a_ring_nfd . "xy" ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 2, "abc" . $char_a_ring_nfd . "xyz" ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 3, "abc" . $char_a_ring_nfd . "xyz" ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 4, "bc" . $char_a_ring_nfd . "xyz" ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 5, "c" . $char_a_ring_nfd . "xyz" ),
+ array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 6, $char_a_ring_nfd . "xyz" ),
+
+ );
+
+ foreach( $tests as $test ) {
+ $arg0 = urlencode($test[0]);
+ $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS);
+ }
+ else {
+ $res_str .= " starting at byte position $test[2]";
+ $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS, $test[2]);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= urlencode($result);
+ }
+ $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
+ }
+
+
+ //=====================================================================================
+
+ return $res_str;
+}
+
+echo ut_main();
+
+function check_result($result, $expected) {
+
+ if ( $result === false ) {
+ $result = 'false';
+ }
+
+ if ( strcmp($result, $expected) != 0 ) {
+ return " **FAILED** ";
+ }
+
+ return "";
+}
+
+?>
+--EXPECT--
+
+function grapheme_strlen($string) {}
+
+"hindi" in devanagari strlen 3
+"ab" + "hindi" + "cde" strlen 8
+"" strlen 0
+char_a_ring_nfd strlen 1
+char_a_ring_nfd + "bc" strlen 3
+"abc" strlen 3
+
+function grapheme_strpos($haystack, $needle, $offset = 0) {}
+
+find "o" in "aa%CC%8Abco%CC%88o" - grapheme_strpos = 5 == 5
+find "o" in "aa%CC%8Abco%CC%88" - grapheme_strpos = false == false
+find "o%CC%88" in "aa%CC%8Abco%CC%88" - grapheme_strpos = 4 == 4
+find "a%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_strpos = 2 == 2
+find "a%CC%8A" in "aa%CC%8Abc" - grapheme_strpos = 1 == 1
+find "a%CC%8A" in "abc" - grapheme_strpos = false == false
+find "a" in "a%CC%8Abc" - grapheme_strpos = false == false
+find "d" in "abc" - grapheme_strpos = false == false
+find "c" in "abc" - grapheme_strpos = 2 == 2
+find "b" in "abc" - grapheme_strpos = 1 == 1
+find "a" in "abc" - grapheme_strpos = 0 == 0
+find "a" in "abc" - grapheme_strpos from 0 = 0 == 0
+find "a" in "abc" - grapheme_strpos from 1 = false == false
+find "a" in "ababc" - grapheme_strpos from 1 = 2 == 2
+find "o" in "aoa%CC%8Abco%CC%88o" - grapheme_strpos from 2 = 6 == 6
+find "a%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abc" - grapheme_strpos from 2 = 3 == 3
+find "op" in "aa%CC%8Abco%CC%88opq" - grapheme_strpos = 5 == 5
+find "opq" in "aa%CC%8Abco%CC%88opq" - grapheme_strpos = 5 == 5
+find "abc" in "aa%CC%8Abco%CC%88" - grapheme_strpos = false == false
+find "o%CC%88bco%CC%88" in "aa%CC%8Abco%CC%88bco%CC%88" - grapheme_strpos = 4 == 4
+find "a%CC%8Abc" in "o%CC%88aa%CC%8Abc" - grapheme_strpos = 2 == 2
+find "a%CC%8Abc" in "aa%CC%8Abc" - grapheme_strpos = 1 == 1
+find "a%CC%8Abc" in "abc" - grapheme_strpos = false == false
+find "abcdefg" in "a%CC%8Abc" - grapheme_strpos = false == false
+find "defghijklmnopq" in "abc" - grapheme_strpos = false == false
+find "ab" in "abc" - grapheme_strpos = 0 == 0
+find "bc" in "abc" - grapheme_strpos = 1 == 1
+find "abc" in "abc" - grapheme_strpos = 0 == 0
+find "abcd" in "abc" - grapheme_strpos = false == false
+find "ab" in "abc" - grapheme_strpos from 0 = 0 == 0
+find "abc" in "abc" - grapheme_strpos from 0 = 0 == 0
+find "abc" in "abc" - grapheme_strpos from 1 = false == false
+find "ab" in "ababc" - grapheme_strpos from 1 = 2 == 2
+find "abc" in "ababc" - grapheme_strpos from 1 = 2 == 2
+find "oa%CC%8Abc" in "aoa%CC%8Abco%CC%88oa%CC%8Abc" - grapheme_strpos from 2 = 6 == 6
+find "a%CC%8Abca%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abca%CC%8Adef" - grapheme_strpos from 2 = 3 == 3
+
+function grapheme_stripos($haystack, $needle, $offset = 0) {}
+
+find "o" in "aoa%CC%8Abco%CC%88O" - grapheme_stripos from 2 = 6 == 6
+find "a%CC%8A" in "o%CC%88a%CC%8AaA%CC%8Abc" - grapheme_stripos from 2 = 3 == 3
+find "o" in "aa%CC%8Abco%CC%88O" - grapheme_stripos = 5 == 5
+find "O" in "aa%CC%8Abco%CC%88" - grapheme_stripos = false == false
+find "o%CC%88" in "aa%CC%8AbcO%CC%88" - grapheme_stripos = 4 == 4
+find "A%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_stripos = 2 == 2
+find "a%CC%8A" in "aA%CC%8Abc" - grapheme_stripos = 1 == 1
+find "a%CC%8A" in "Abc" - grapheme_stripos = false == false
+find "A" in "a%CC%8Abc" - grapheme_stripos = false == false
+find "D" in "abc" - grapheme_stripos = false == false
+find "c" in "abC" - grapheme_stripos = 2 == 2
+find "B" in "abc" - grapheme_stripos = 1 == 1
+find "a" in "Abc" - grapheme_stripos = 0 == 0
+find "A" in "abc" - grapheme_stripos from 0 = 0 == 0
+find "a" in "Abc" - grapheme_stripos from 1 = false == false
+find "A" in "ababc" - grapheme_stripos from 1 = 2 == 2
+find "oP" in "aa%CC%8Abco%CC%88Opq" - grapheme_stripos = 5 == 5
+find "opQ" in "aa%CC%8Abco%CC%88Opq" - grapheme_stripos = 5 == 5
+find "abc" in "aa%CC%8Abco%CC%88" - grapheme_stripos = false == false
+find "O%CC%88bco%CC%88" in "aa%CC%8Abco%CC%88bCo%CC%88" - grapheme_stripos = 4 == 4
+find "A%CC%8Abc" in "o%CC%88aa%CC%8ABc" - grapheme_stripos = 2 == 2
+find "a%CC%8Abc" in "aa%CC%8ABC" - grapheme_stripos = 1 == 1
+find "a%CC%8ABC" in "abc" - grapheme_stripos = false == false
+find "aBCdefg" in "a%CC%8ABC" - grapheme_stripos = false == false
+find "Defghijklmnopq" in "aBC" - grapheme_stripos = false == false
+find "Ab" in "abC" - grapheme_stripos = 0 == 0
+find "bc" in "aBC" - grapheme_stripos = 1 == 1
+find "Abc" in "abC" - grapheme_stripos = 0 == 0
+find "aBcd" in "abC" - grapheme_stripos = false == false
+find "ab" in "ABc" - grapheme_stripos from 0 = 0 == 0
+find "abC" in "aBc" - grapheme_stripos from 0 = 0 == 0
+find "aBc" in "abc" - grapheme_stripos from 1 = false == false
+find "AB" in "ABabc" - grapheme_stripos from 1 = 2 == 2
+find "aBc" in "abaBc" - grapheme_stripos from 1 = 2 == 2
+find "Oa%CC%8AbC" in "aoa%CC%8Abco%CC%88oA%CC%8AbC" - grapheme_stripos from 2 = 6 == 6
+find "a%CC%8ABca%CC%8A" in "o%CC%88a%CC%8AaA%CC%8AbCa%CC%8Adef" - grapheme_stripos from 2 = 3 == 3
+
+function grapheme_strrpos($haystack, $needle, $offset = 0) {}
+
+find "o" in "aa%CC%8Abco%CC%88o" - grapheme_strrpos = 5 == 5
+find "o" in "aa%CC%8Abco%CC%88" - grapheme_strrpos = false == false
+find "o%CC%88" in "aa%CC%8Abco%CC%88" - grapheme_strrpos = 4 == 4
+find "a%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_strrpos = 2 == 2
+find "a%CC%8A" in "aa%CC%8Abc" - grapheme_strrpos = 1 == 1
+find "a%CC%8A" in "abc" - grapheme_strrpos = false == false
+find "a" in "a%CC%8Abc" - grapheme_strrpos = false == false
+find "d" in "abc" - grapheme_strrpos = false == false
+find "c" in "abc" - grapheme_strrpos = 2 == 2
+find "b" in "abc" - grapheme_strrpos = 1 == 1
+find "a" in "abc" - grapheme_strrpos = 0 == 0
+find "a" in "abc" - grapheme_strrpos from 0 = 0 == 0
+find "a" in "abc" - grapheme_strrpos from 1 = false == false
+find "a" in "ababc" - grapheme_strrpos from 1 = 2 == 2
+find "o" in "aoa%CC%8Abco%CC%88o" - grapheme_strrpos from 2 = 6 == 6
+find "a%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abc" - grapheme_strrpos from 2 = 3 == 3
+find "op" in "aa%CC%8Abco%CC%88opq" - grapheme_strrpos = 5 == 5
+find "opq" in "aa%CC%8Abco%CC%88opq" - grapheme_strrpos = 5 == 5
+find "abc" in "aa%CC%8Abco%CC%88" - grapheme_strrpos = false == false
+find "o%CC%88bco%CC%88" in "aa%CC%8Abco%CC%88bco%CC%88" - grapheme_strrpos = 4 == 4
+find "a%CC%8Abc" in "o%CC%88aa%CC%8Abc" - grapheme_strrpos = 2 == 2
+find "a%CC%8Abc" in "aa%CC%8Abc" - grapheme_strrpos = 1 == 1
+find "a%CC%8Abc" in "abc" - grapheme_strrpos = false == false
+find "abcdefg" in "a%CC%8Abc" - grapheme_strrpos = false == false
+find "defghijklmnopq" in "abc" - grapheme_strrpos = false == false
+find "ab" in "abc" - grapheme_strrpos = 0 == 0
+find "bc" in "abc" - grapheme_strrpos = 1 == 1
+find "abc" in "abc" - grapheme_strrpos = 0 == 0
+find "abcd" in "abc" - grapheme_strrpos = false == false
+find "ab" in "abc" - grapheme_strrpos from 0 = 0 == 0
+find "abc" in "abc" - grapheme_strrpos from 0 = 0 == 0
+find "abc" in "abc" - grapheme_strrpos from 1 = false == false
+find "ab" in "ababc" - grapheme_strrpos from 1 = 2 == 2
+find "abc" in "ababc" - grapheme_strrpos from 1 = 2 == 2
+find "oa%CC%8Abc" in "aoa%CC%8Abco%CC%88oa%CC%8Abc" - grapheme_strrpos from 2 = 6 == 6
+find "a%CC%8Abca%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abca%CC%8Adef" - grapheme_strrpos from 2 = 3 == 3
+
+function grapheme_strripos($haystack, $needle, $offset = 0) {}
+
+find "o" in "aoa%CC%8Abco%CC%88O" - grapheme_strripos from 2 = 6 == 6
+find "a%CC%8A" in "o%CC%88a%CC%8AaA%CC%8Abc" - grapheme_strripos from 2 = 3 == 3
+find "o" in "aa%CC%8Abco%CC%88O" - grapheme_strripos = 5 == 5
+find "O" in "aa%CC%8Abco%CC%88" - grapheme_strripos = false == false
+find "o%CC%88" in "aa%CC%8AbcO%CC%88" - grapheme_strripos = 4 == 4
+find "A%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_strripos = 2 == 2
+find "a%CC%8A" in "aA%CC%8Abc" - grapheme_strripos = 1 == 1
+find "a%CC%8A" in "Abc" - grapheme_strripos = false == false
+find "A" in "a%CC%8Abc" - grapheme_strripos = false == false
+find "D" in "abc" - grapheme_strripos = false == false
+find "c" in "abC" - grapheme_strripos = 2 == 2
+find "B" in "abc" - grapheme_strripos = 1 == 1
+find "a" in "Abc" - grapheme_strripos = 0 == 0
+find "A" in "abc" - grapheme_strripos from 0 = 0 == 0
+find "a" in "Abc" - grapheme_strripos from 1 = false == false
+find "A" in "ababc" - grapheme_strripos from 1 = 2 == 2
+find "oP" in "aa%CC%8Abco%CC%88Opq" - grapheme_strripos = 5 == 5
+find "opQ" in "aa%CC%8Abco%CC%88Opq" - grapheme_strripos = 5 == 5
+find "abc" in "aa%CC%8Abco%CC%88" - grapheme_strripos = false == false
+find "O%CC%88bco%CC%88" in "aa%CC%8Abco%CC%88bCo%CC%88" - grapheme_strripos = 4 == 4
+find "A%CC%8Abc" in "o%CC%88aa%CC%8ABc" - grapheme_strripos = 2 == 2
+find "a%CC%8Abc" in "aa%CC%8ABC" - grapheme_strripos = 1 == 1
+find "a%CC%8ABC" in "abc" - grapheme_strripos = false == false
+find "aBCdefg" in "a%CC%8ABC" - grapheme_strripos = false == false
+find "Defghijklmnopq" in "aBC" - grapheme_strripos = false == false
+find "Ab" in "abC" - grapheme_strripos = 0 == 0
+find "bc" in "aBC" - grapheme_strripos = 1 == 1
+find "Abc" in "abC" - grapheme_strripos = 0 == 0
+find "aBcd" in "abC" - grapheme_strripos = false == false
+find "ab" in "ABc" - grapheme_strripos from 0 = 0 == 0
+find "abC" in "aBc" - grapheme_strripos from 0 = 0 == 0
+find "aBc" in "abc" - grapheme_strripos from 1 = false == false
+find "AB" in "ABabc" - grapheme_strripos from 1 = 2 == 2
+find "aBc" in "abaBc" - grapheme_strripos from 1 = 2 == 2
+find "Oa%CC%8AbC" in "aoa%CC%8Abco%CC%88oA%CC%8AbC" - grapheme_strripos from 2 = 6 == 6
+find "a%CC%8ABca%CC%8A" in "o%CC%88a%CC%8AaA%CC%8AbCa%CC%8Adef" - grapheme_strripos from 2 = 3 == 3
+
+function grapheme_substr($string, $start, $length = -1) {}
+
+substring of "abc" from "3" - grapheme_substr = false == false
+substring of "aa%CC%8Abco%CC%88" from "5" - grapheme_substr = false == false
+substring of "aoa%CC%8Abco%CC%88O" from "2" - grapheme_substr = a%CC%8Abco%CC%88O == a%CC%8Abco%CC%88O
+substring of "o%CC%88a%CC%8AaA%CC%8Abc" from "2" - grapheme_substr = aA%CC%8Abc == aA%CC%8Abc
+substring of "aa%CC%8Abco%CC%88O" from "5" - grapheme_substr = O == O
+substring of "aa%CC%8Abco%CC%88" from "5" - grapheme_substr = false == false
+substring of "aa%CC%8AbcO%CC%88" from "4" - grapheme_substr = O%CC%88 == O%CC%88
+substring of "o%CC%88aa%CC%8Abc" from "2" - grapheme_substr = a%CC%8Abc == a%CC%8Abc
+substring of "aA%CC%8Abc" from "1" - grapheme_substr = A%CC%8Abc == A%CC%8Abc
+substring of "Abc" from "-5" - grapheme_substr = false == false
+substring of "a%CC%8Abc" from "3" - grapheme_substr = false == false
+substring of "abc" from "4" - grapheme_substr = false == false
+substring of "abC" from "2" - grapheme_substr = C == C
+substring of "abc" from "1" - grapheme_substr = bc == bc
+substring of "Abc" from "1" - grapheme_substr with length 1 = b == b
+substring of "abc" from "0" - grapheme_substr with length 2 = ab == ab
+substring of "Abc" from "-4" - grapheme_substr with length 1 = false == false
+substring of "ababc" from "1" - grapheme_substr with length 2 = ba == ba
+substring of "ababc" from "0" - grapheme_substr with length 10 = ababc == ababc
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length 10 = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
+substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr = Opq == Opq
+substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr with length -1 = Op == Op
+substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr with length -2 = O == O
+substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr with length -3 = ==
+substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr with length -4 = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -1 = aa%CC%8Abco%CC%88Op == aa%CC%8Abco%CC%88Op
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -2 = aa%CC%8Abco%CC%88O == aa%CC%8Abco%CC%88O
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -3 = aa%CC%8Abco%CC%88 == aa%CC%8Abco%CC%88
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -4 = aa%CC%8Abc == aa%CC%8Abc
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -5 = aa%CC%8Ab == aa%CC%8Ab
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -6 = aa%CC%8A == aa%CC%8A
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -7 = a == a
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -8 = ==
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -9 = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
+substring of "aa%CC%8Abco%CC%88Opq" from "-7" - grapheme_substr = a%CC%8Abco%CC%88Opq == a%CC%8Abco%CC%88Opq
+substring of "aa%CC%8Abco%CC%88Opq" from "-6" - grapheme_substr = bco%CC%88Opq == bco%CC%88Opq
+substring of "aa%CC%8Abco%CC%88Opq" from "-5" - grapheme_substr = co%CC%88Opq == co%CC%88Opq
+substring of "aa%CC%8Abco%CC%88Opq" from "-4" - grapheme_substr = o%CC%88Opq == o%CC%88Opq
+substring of "aa%CC%8Abco%CC%88Opq" from "-3" - grapheme_substr = Opq == Opq
+substring of "aa%CC%8Abco%CC%88Opq" from "-2" - grapheme_substr = pq == pq
+substring of "aa%CC%8Abco%CC%88Opq" from "-1" - grapheme_substr = q == q
+substring of "aa%CC%8Abco%CC%88Opq" from "-999" - grapheme_substr = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 8 = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 7 = aa%CC%8Abco%CC%88Op == aa%CC%8Abco%CC%88Op
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 6 = aa%CC%8Abco%CC%88O == aa%CC%8Abco%CC%88O
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 5 = aa%CC%8Abco%CC%88 == aa%CC%8Abco%CC%88
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 4 = aa%CC%8Abc == aa%CC%8Abc
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 3 = aa%CC%8Ab == aa%CC%8Ab
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 2 = aa%CC%8A == aa%CC%8A
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 1 = a == a
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 0 = ==
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -999 = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -1 = aa%CC%8Abco%CC%88Op == aa%CC%8Abco%CC%88Op
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -2 = aa%CC%8Abco%CC%88O == aa%CC%8Abco%CC%88O
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -3 = aa%CC%8Abco%CC%88 == aa%CC%8Abco%CC%88
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -4 = aa%CC%8Abc == aa%CC%8Abc
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -5 = aa%CC%8Ab == aa%CC%8Ab
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -6 = aa%CC%8A == aa%CC%8A
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -7 = a == a
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -8 = ==
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -9 = false == false
+
+function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {}
+
+find "o" in "aa%CC%8Abco%CC%88o" - grapheme_strstr = o == o
+find "o" in "aa%CC%8Abco%CC%88" - grapheme_strstr = false == false
+find "o%CC%88" in "aa%CC%8Abco%CC%88" - grapheme_strstr = o%CC%88 == o%CC%88
+find "a%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_strstr = a%CC%8Abc == a%CC%8Abc
+find "a%CC%8A" in "aa%CC%8Abc" - grapheme_strstr = a%CC%8Abc == a%CC%8Abc
+find "a%CC%8A" in "abc" - grapheme_strstr = false == false
+find "a" in "a%CC%8Abc" - grapheme_strstr = false == false
+find "d" in "abc" - grapheme_strstr = false == false
+find "c" in "abc" - grapheme_strstr = c == c
+find "b" in "abc" - grapheme_strstr = bc == bc
+find "a" in "abc" - grapheme_strstr = abc == abc
+find "ab" in "abc" - grapheme_strstr = abc == abc
+find "abc" in "abc" - grapheme_strstr = abc == abc
+find "bc" in "abc" - grapheme_strstr = bc == bc
+find "a" in "abc" - grapheme_strstr before flag is FALSE = abc == abc
+find "a" in "abc" - grapheme_strstr before flag is TRUE = ==
+find "b" in "abc" - grapheme_strstr before flag is TRUE = a == a
+find "c" in "abc" - grapheme_strstr before flag is TRUE = ab == ab
+find "bab" in "ababc" - grapheme_strstr before flag is TRUE = a == a
+find "abc" in "ababc" - grapheme_strstr before flag is TRUE = ab == ab
+find "abc" in "ababc" - grapheme_strstr before flag is FALSE = abc == abc
+find "d" in "aba%CC%8Ac" - grapheme_strstr = false == false
+find "a" in "bca%CC%8Aa" - grapheme_strstr = a == a
+find "b" in "aa%CC%8Abc" - grapheme_strstr = bc == bc
+find "a" in "a%CC%8Abc" - grapheme_strstr = false == false
+find "ab" in "a%CC%8Aabc" - grapheme_strstr = abc == abc
+find "abc" in "abca%CC%8A" - grapheme_strstr = abca%CC%8A == abca%CC%8A
+find "a%CC%8Abc" in "aa%CC%8Abc" - grapheme_strstr = a%CC%8Abc == a%CC%8Abc
+find "a%CC%8A" in "aa%CC%8Abc" - grapheme_strstr before flag is FALSE = a%CC%8Abc == a%CC%8Abc
+find "a" in "aa%CC%8Abc" - grapheme_strstr before flag is TRUE = ==
+find "b" in "a%CC%8Aabc" - grapheme_strstr before flag is TRUE = a%CC%8Aa == a%CC%8Aa
+find "c" in "aba%CC%8Ac" - grapheme_strstr before flag is TRUE = aba%CC%8A == aba%CC%8A
+find "baa%CC%8Ab" in "abaa%CC%8Abc" - grapheme_strstr before flag is TRUE = a == a
+find "abca%CC%8A" in "ababca%CC%8A" - grapheme_strstr before flag is TRUE = ab == ab
+find "aba%CC%8Ac" in "ababa%CC%8Ac" - grapheme_strstr before flag is FALSE = aba%CC%8Ac == aba%CC%8Ac
+
+function grapheme_stristr($haystack, $needle, $before_needle = FALSE) {}
+
+find "O%CC%88" in "aa%CC%8Abco%CC%88" - grapheme_stristr = o%CC%88 == o%CC%88
+find "o" in "aa%CC%8Abco%CC%88O" - grapheme_stristr = O == O
+find "o" in "aa%CC%8Abco%CC%88" - grapheme_stristr = false == false
+find "a%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_stristr = a%CC%8Abc == a%CC%8Abc
+find "A%CC%8A" in "aa%CC%8Abc" - grapheme_stristr = a%CC%8Abc == a%CC%8Abc
+find "a%CC%8A" in "abc" - grapheme_stristr = false == false
+find "A" in "a%CC%8Abc" - grapheme_stristr = false == false
+find "d" in "abc" - grapheme_stristr = false == false
+find "C" in "abc" - grapheme_stristr = c == c
+find "b" in "aBc" - grapheme_stristr = Bc == Bc
+find "A" in "abc" - grapheme_stristr = abc == abc
+find "ab" in "abC" - grapheme_stristr = abC == abC
+find "aBc" in "abc" - grapheme_stristr = abc == abc
+find "bc" in "abC" - grapheme_stristr = bC == bC
+find "A" in "abc" - grapheme_stristr before flag is FALSE = abc == abc
+find "a" in "abc" - grapheme_stristr before flag is TRUE = ==
+find "b" in "aBc" - grapheme_stristr before flag is TRUE = a == a
+find "C" in "abc" - grapheme_stristr before flag is TRUE = ab == ab
+find "bab" in "aBabc" - grapheme_stristr before flag is TRUE = a == a
+find "aBc" in "ababc" - grapheme_stristr before flag is TRUE = ab == ab
+find "abC" in "ababc" - grapheme_stristr before flag is FALSE = abc == abc
+find "d" in "aba%CC%8Ac" - grapheme_stristr = false == false
+find "a" in "bca%CC%8AA" - grapheme_stristr = A == A
+find "B" in "aa%CC%8Abc" - grapheme_stristr = bc == bc
+find "a" in "A%CC%8Abc" - grapheme_stristr = false == false
+find "Ab" in "a%CC%8Aabc" - grapheme_stristr = abc == abc
+find "abc" in "abcA%CC%8A" - grapheme_stristr = abcA%CC%8A == abcA%CC%8A
+find "A%CC%8Abc" in "aa%CC%8Abc" - grapheme_stristr = a%CC%8Abc == a%CC%8Abc
+find "a%CC%8A" in "aA%CC%8Abc" - grapheme_stristr before flag is FALSE = A%CC%8Abc == A%CC%8Abc
+find "A" in "aa%CC%8Abc" - grapheme_stristr before flag is TRUE = ==
+find "b" in "a%CC%8AaBc" - grapheme_stristr before flag is TRUE = a%CC%8Aa == a%CC%8Aa
+find "C" in "aba%CC%8Ac" - grapheme_stristr before flag is TRUE = aba%CC%8A == aba%CC%8A
+find "baa%CC%8Ab" in "abaA%CC%8Abc" - grapheme_stristr before flag is TRUE = a == a
+find "aBcA%CC%8A" in "ababca%CC%8A" - grapheme_stristr before flag is TRUE = ab == ab
+find "aba%CC%8Ac" in "abABA%CC%8Ac" - grapheme_stristr before flag is FALSE = ABA%CC%8Ac == ABA%CC%8Ac
+
+function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_COUNT, $start = 0[, $next])
+
+extract from "abc" "3" graphemes - grapheme_extract = abc == abc
+extract from "abc" "2" graphemes - grapheme_extract = ab == ab
+extract from "abc" "1" graphemes - grapheme_extract = a == a
+extract from "abc" "0" graphemes - grapheme_extract = ==
+extract from "abc" "1" graphemes - grapheme_extract starting at byte position 0 = a == a
+extract from "abc" "1" graphemes - grapheme_extract starting at byte position 1 = b == b
+extract from "abc" "1" graphemes - grapheme_extract starting at byte position 2 = c == c
+extract from "abc" "0" graphemes - grapheme_extract starting at byte position 2 = ==
+extract from "abc" "3" graphemes - grapheme_extract starting at byte position 0 with $next = abc == abc $next=3 == 3
+extract from "abc" "2" graphemes - grapheme_extract starting at byte position 0 with $next = ab == ab $next=2 == 2
+extract from "abc" "1" graphemes - grapheme_extract starting at byte position 0 with $next = a == a $next=1 == 1
+extract from "abc" "0" graphemes - grapheme_extract starting at byte position 0 with $next = == $next=0 == 0
+extract from "abc" "1" graphemes - grapheme_extract starting at byte position 0 with $next = a == a $next=1 == 1
+extract from "abc" "1" graphemes - grapheme_extract starting at byte position 1 with $next = b == b $next=2 == 2
+extract from "abc" "1" graphemes - grapheme_extract starting at byte position 2 with $next = c == c $next=3 == 3
+extract from "abc" "0" graphemes - grapheme_extract starting at byte position 2 with $next = == $next=2 == 2
+extract from "http%3A%2F%2Fnews.bbc.co.uk%2F2%2Fhi%2Fmiddle_east%2F7831588.stm" "48" graphemes - grapheme_extract starting at byte position 48 with $next = tm == tm $next=50 == 50
+extract from "a%CC%8Abc" "3" graphemes - grapheme_extract = a%CC%8Abc == a%CC%8Abc
+extract from "a%CC%8Abc" "2" graphemes - grapheme_extract = a%CC%8Ab == a%CC%8Ab
+extract from "a%CC%8Abc" "1" graphemes - grapheme_extract = a%CC%8A == a%CC%8A
+extract from "a%CC%8Abc" "3" graphemes - grapheme_extract starting at byte position 0 with $next = a%CC%8Abc == a%CC%8Abc $next=5 == 5
+extract from "a%CC%8Abc" "2" graphemes - grapheme_extract starting at byte position 0 with $next = a%CC%8Ab == a%CC%8Ab $next=4 == 4
+extract from "a%CC%8Abc" "1" graphemes - grapheme_extract starting at byte position 0 with $next = a%CC%8A == a%CC%8A $next=3 == 3
+extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position 3 with $next = bc == bc $next=5 == 5
+extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position 4 with $next = cd == cd $next=6 == 6
+extract from "a%CC%8Abcdea%CC%8Af" "4" graphemes - grapheme_extract starting at byte position 5 with $next = dea%CC%8Af == dea%CC%8Af $next=11 == 11
+extract from "a%CC%8Ao%CC%88o%CC%88" "3" graphemes - grapheme_extract = a%CC%8Ao%CC%88o%CC%88 == a%CC%8Ao%CC%88o%CC%88
+extract from "a%CC%8Ao%CC%88o%CC%88" "2" graphemes - grapheme_extract = a%CC%8Ao%CC%88 == a%CC%8Ao%CC%88
+extract from "a%CC%8Ao%CC%88c" "1" graphemes - grapheme_extract = a%CC%8A == a%CC%8A
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "1" graphemes - grapheme_extract starting at byte position 0 = o%CC%88 == o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "1" graphemes - grapheme_extract starting at byte position 2 = o%CC%88 == o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "1" graphemes - grapheme_extract starting at byte position 3 = o%CC%88 == o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "1" graphemes - grapheme_extract starting at byte position 4 = %CC%88 == %CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 0 = o%CC%88o%CC%88 == o%CC%88o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 2 = o%CC%88o%CC%88 == o%CC%88o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 3 = o%CC%88o%CC%88 == o%CC%88o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 4 = %CC%88o%CC%88 == %CC%88o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 7 = %CC%88o%CC%88 == %CC%88o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 8 = o%CC%88 == o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 10 = %CC%88 == %CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 11 = false == false
+
+function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXBYTES, $start = 0)
+
+extract from "abc" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = abc == abc
+extract from "abc" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = ab == ab
+extract from "abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a == a
+extract from "abc" "0" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = ==
+extract from "a%CC%8Abc" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Abc == a%CC%8Abc
+extract from "a%CC%8Abc" "4" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ab == a%CC%8Ab
+extract from "a%CC%8Abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = ==
+extract from "a%CC%8Ao%CC%88o%CC%88" "9" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88o%CC%88 == a%CC%8Ao%CC%88o%CC%88
+extract from "a%CC%8Ao%CC%88o%CC%88" "10" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88o%CC%88 == a%CC%8Ao%CC%88o%CC%88
+extract from "a%CC%8Ao%CC%88o%CC%88" "11" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88o%CC%88 == a%CC%8Ao%CC%88o%CC%88
+extract from "a%CC%8Ao%CC%88o%CC%88" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88 == a%CC%8Ao%CC%88
+extract from "a%CC%8Ao%CC%88c" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8A == a%CC%8A
+extract from "a%CC%8Ao%CC%88c" "4" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8A == a%CC%8A
+extract from "a%CC%8Ao%CC%88c" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8A == a%CC%8A
+extract from "a%CC%8Ao%CC%88c" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88 == a%CC%8Ao%CC%88
+extract from "a%CC%8Ao%CC%88c" "7" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88c == a%CC%8Ao%CC%88c
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 0 = o%CC%88 == o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 2 = o%CC%88 == o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 3 = o%CC%88 == o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 4 = %CC%88 == %CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 0 = o%CC%88o%CC%88 == o%CC%88o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 2 = o%CC%88o%CC%88 == o%CC%88o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 3 = o%CC%88o%CC%88 == o%CC%88o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 4 = %CC%88o%CC%88 == %CC%88o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 7 = %CC%88o%CC%88 == %CC%88o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 8 = o%CC%88 == o%CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 10 = %CC%88 == %CC%88
+extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 11 = false == false
+
+function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXCHARS, $start = 0)
+
+extract from "abc" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = abc == abc
+extract from "abc" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ab == ab
+extract from "abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = a == a
+extract from "abc" "0" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ==
+extract from "abco%CC%88" "0" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ==
+extract from "abco%CC%88" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = a == a
+extract from "abco%CC%88" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ab == ab
+extract from "abco%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = abc == abc
+extract from "abco%CC%88" "4" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = abc == abc
+extract from "abco%CC%88" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = abco%CC%88 == abco%CC%88
+extract from "abco%CC%88" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = abco%CC%88 == abco%CC%88
+extract from "o%CC%88abc" "0" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ==
+extract from "o%CC%88abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ==
+extract from "o%CC%88abc" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88 == o%CC%88
+extract from "o%CC%88abc" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88a == o%CC%88a
+extract from "o%CC%88abc" "4" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88ab == o%CC%88ab
+extract from "o%CC%88abca%CC%8Axyz" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88abc == o%CC%88abc
+extract from "o%CC%88abca%CC%8Axyz" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88abc == o%CC%88abc
+extract from "o%CC%88abca%CC%8Axyz" "7" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88abca%CC%8A == o%CC%88abca%CC%8A
+extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88abca%CC%8Ax == o%CC%88abca%CC%8Ax
+extract from "abc" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 0 = abc == abc
+extract from "abc" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 1 = bc == bc
+extract from "abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 2 = c == c
+extract from "abc" "0" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 3 = false == false
+extract from "abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 3 = false == false
+extract from "abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 999 = false == false
+extract from "o%CC%88abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 6 = false == false
+extract from "o%CC%88abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 999 = false == false
+extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 0 = o%CC%88abca%CC%8Ax == o%CC%88abca%CC%8Ax
+extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 1 = %CC%88abca%CC%8Axy == %CC%88abca%CC%8Axy
+extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 2 = abca%CC%8Axyz == abca%CC%8Axyz
+extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 3 = abca%CC%8Axyz == abca%CC%8Axyz
+extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 4 = bca%CC%8Axyz == bca%CC%8Axyz
+extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 5 = ca%CC%8Axyz == ca%CC%8Axyz
+extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 6 = a%CC%8Axyz == a%CC%8Axyz
+
diff --git a/ext/intl/tests/idn.phpt b/ext/intl/tests/idn.phpt
new file mode 100644
index 0000000..fde822a
--- /dev/null
+++ b/ext/intl/tests/idn.phpt
@@ -0,0 +1,18 @@
+--TEST--
+IDN
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Test IDN functions (procedural only)
+ */
+
+echo idn_to_ascii("t\xC3\xA4st.de")."\n";
+echo urlencode(idn_to_utf8('xn--tst-qla.de'))."\n";
+
+?>
+--EXPECT--
+xn--tst-qla.de
+t%C3%A4st.de \ No newline at end of file
diff --git a/ext/intl/tests/idn_uts46_basic.phpt b/ext/intl/tests/idn_uts46_basic.phpt
new file mode 100644
index 0000000..2ca1850
--- /dev/null
+++ b/ext/intl/tests/idn_uts46_basic.phpt
@@ -0,0 +1,53 @@
+--TEST--
+IDN UTS #46 API basic tests
+--SKIPIF--
+<?php
+ if (!extension_loaded('intl'))
+ die('skip');
+ if (!defined('INTL_IDNA_VARIANT_UTS46'))
+ die('skip no UTS #46 API');
+--FILE--
+<?php
+$utf8dn = "www.fußball.com";
+$asciiNonTrans = "www.xn--fuball-cta.com";
+
+echo "all ok, no details:", "\n";
+var_dump(idn_to_ascii($utf8dn,
+ IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46));
+
+echo "all ok, no details, transitional:", "\n";
+var_dump(idn_to_ascii($utf8dn, 0, INTL_IDNA_VARIANT_UTS46));
+
+echo "all ok, with details:", "\n";
+var_dump(idn_to_ascii($utf8dn, IDNA_NONTRANSITIONAL_TO_ASCII,
+ INTL_IDNA_VARIANT_UTS46, $info));
+var_dump($info);
+
+echo "reverse, ok, with details:", "\n";
+var_dump(idn_to_utf8($asciiNonTrans, 0, INTL_IDNA_VARIANT_UTS46, $info));
+var_dump($info);
+--EXPECT--
+all ok, no details:
+string(22) "www.xn--fuball-cta.com"
+all ok, no details, transitional:
+string(16) "www.fussball.com"
+all ok, with details:
+string(22) "www.xn--fuball-cta.com"
+array(3) {
+ ["result"]=>
+ string(22) "www.xn--fuball-cta.com"
+ ["isTransitionalDifferent"]=>
+ bool(true)
+ ["errors"]=>
+ int(0)
+}
+reverse, ok, with details:
+string(16) "www.fußball.com"
+array(3) {
+ ["result"]=>
+ string(16) "www.fußball.com"
+ ["isTransitionalDifferent"]=>
+ bool(false)
+ ["errors"]=>
+ int(0)
+}
diff --git a/ext/intl/tests/idn_uts46_errors.phpt b/ext/intl/tests/idn_uts46_errors.phpt
new file mode 100644
index 0000000..a336e69
--- /dev/null
+++ b/ext/intl/tests/idn_uts46_errors.phpt
@@ -0,0 +1,89 @@
+--TEST--
+IDN UTS #46 API error tests
+--SKIPIF--
+<?php
+ if (!extension_loaded('intl'))
+ die('skip');
+ if (!defined('INTL_IDNA_VARIANT_UTS46'))
+ die('skip no UTS #46 API');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+echo "=> PHP level errors", "\n";
+
+echo "bad args:", "\n";
+var_dump(idn_to_ascii("", 0, array()));
+var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46, $foo, null));
+
+echo "bad variant:", "\n";
+var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46 + 10));
+
+echo "empty domain:", "\n";
+var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46));
+
+echo "fourth arg for 2003 variant (only notice raised):", "\n";
+var_dump(idn_to_ascii("foo.com", 0, INTL_IDNA_VARIANT_2003, $foo));
+
+echo "with error, but no details arg:", "\n";
+var_dump(idn_to_ascii("www.fußball.com-", 0, INTL_IDNA_VARIANT_UTS46));
+
+echo "with error, with details arg:", "\n";
+var_dump(idn_to_ascii("www.fußball.com-", IDNA_NONTRANSITIONAL_TO_ASCII,
+ INTL_IDNA_VARIANT_UTS46, $foo));
+var_dump($foo);
+
+echo "with error, with details arg, contextj:", "\n";
+var_dump(idn_to_ascii(
+ html_entity_decode("www.a&#x200D;b.com", 0, "UTF-8"),
+ IDNA_NONTRANSITIONAL_TO_ASCII | IDNA_CHECK_CONTEXTJ,
+ INTL_IDNA_VARIANT_UTS46, $foo));
+var_dump($foo);
+var_dump($foo["errors"]==IDNA_ERROR_CONTEXTJ);
+--EXPECTF--
+=> PHP level errors
+bad args:
+
+Warning: idn_to_ascii() expects parameter 3 to be long, array given in %s on line %d
+
+Warning: idn_to_ascii(): idn_to_ascii: bad arguments in %s on line %d
+NULL
+
+Warning: idn_to_ascii() expects at most 4 parameters, 5 given in %s on line %d
+
+Warning: idn_to_ascii(): idn_to_ascii: bad arguments in %s on line %d
+NULL
+bad variant:
+
+Warning: idn_to_ascii(): idn_to_ascii: invalid variant, must be one of {INTL_IDNA_VARIANT_2003, INTL_IDNA_VARIANT_UTS46} in %s on line %d
+bool(false)
+empty domain:
+
+Warning: idn_to_ascii(): idn_to_ascii: empty domain name in %s on line %d
+bool(false)
+fourth arg for 2003 variant (only notice raised):
+
+Notice: idn_to_ascii(): 4 arguments were provided, but INTL_IDNA_VARIANT_2003 only takes 3 - extra argument ignored in %s on line %d
+string(7) "foo.com"
+with error, but no details arg:
+bool(false)
+with error, with details arg:
+bool(false)
+array(3) {
+ ["result"]=>
+ string(23) "www.xn--fuball-cta.com-"
+ ["isTransitionalDifferent"]=>
+ bool(true)
+ ["errors"]=>
+ int(16)
+}
+with error, with details arg, contextj:
+bool(false)
+array(3) {
+ ["result"]=>
+ string(18) "www.xn--ab-m1t.com"
+ ["isTransitionalDifferent"]=>
+ bool(true)
+ ["errors"]=>
+ int(4096)
+}
+bool(true)
diff --git a/ext/intl/tests/intl_error_name.phpt b/ext/intl/tests/intl_error_name.phpt
new file mode 100644
index 0000000..8f5b2dc
--- /dev/null
+++ b/ext/intl/tests/intl_error_name.phpt
@@ -0,0 +1,25 @@
+--TEST--
+intl_error_name()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Check getting error string by integer error code.
+ */
+
+
+function check( $err_code )
+{
+ echo intl_error_name( $err_code ) . "\n";
+}
+
+check( U_ZERO_ERROR );
+check( U_ILLEGAL_ARGUMENT_ERROR );
+check( U_USING_FALLBACK_WARNING );
+?>
+--EXPECT--
+U_ZERO_ERROR
+U_ILLEGAL_ARGUMENT_ERROR
+U_USING_FALLBACK_WARNING
diff --git a/ext/intl/tests/intl_get_error_code.phpt b/ext/intl/tests/intl_get_error_code.phpt
new file mode 100644
index 0000000..6cd361b
--- /dev/null
+++ b/ext/intl/tests/intl_get_error_code.phpt
@@ -0,0 +1,24 @@
+--TEST--
+intl_get_error_code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+/*
+ * Check getting global error code.
+ */
+
+// Suppress warning messages.
+error_reporting( E_ERROR );
+
+if( collator_get_locale() !== false )
+ echo "failed\n";
+else
+{
+ $check_code = ( intl_get_error_code() != 0 );
+ echo ( $check_code ? "ok" : "failed" ) . "\n";
+}
+
+?>
+--EXPECT--
+ok
diff --git a/ext/intl/tests/intl_get_error_message.phpt b/ext/intl/tests/intl_get_error_message.phpt
new file mode 100644
index 0000000..f81b5c0
--- /dev/null
+++ b/ext/intl/tests/intl_get_error_message.phpt
@@ -0,0 +1,21 @@
+--TEST--
+intl_get_error_message()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+/*
+ * Check getting global error message.
+ */
+
+// Suppress warning messages.
+error_reporting( E_ERROR );
+
+if( collator_get_locale() !== false )
+ echo "failed\n";
+else
+ printf( "%s\n", intl_get_error_message() );
+
+?>
+--EXPECT--
+collator_get_locale: unable to parse input params: U_ILLEGAL_ARGUMENT_ERROR
diff --git a/ext/intl/tests/intl_icu_data_version_constant.phpt b/ext/intl/tests/intl_icu_data_version_constant.phpt
new file mode 100644
index 0000000..ad01218
--- /dev/null
+++ b/ext/intl/tests/intl_icu_data_version_constant.phpt
@@ -0,0 +1,10 @@
+--TEST--
+INTL_ICU_DATA_VERSION constant
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) || version_compare('INTL_ICU_VERSION', '4.4', '<') ) print 'skip'; ?>
+--FILE--
+<?php
+var_dump(defined("INTL_ICU_DATA_VERSION"));
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/intl/tests/intl_icu_version_constant.phpt b/ext/intl/tests/intl_icu_version_constant.phpt
new file mode 100644
index 0000000..1316069
--- /dev/null
+++ b/ext/intl/tests/intl_icu_version_constant.phpt
@@ -0,0 +1,10 @@
+--TEST--
+INTL_ICU_VERSION constant
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+var_dump(defined("INTL_ICU_VERSION"));
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/intl/tests/intl_is_failure.phpt b/ext/intl/tests/intl_is_failure.phpt
new file mode 100644
index 0000000..e07df8f
--- /dev/null
+++ b/ext/intl/tests/intl_is_failure.phpt
@@ -0,0 +1,25 @@
+--TEST--
+intl_is_failure()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+/*
+ * Check determining failure error codes.
+ */
+
+
+function check( $err_code )
+{
+ var_export( intl_is_failure( $err_code ) );
+ echo "\n";
+}
+
+check( U_ZERO_ERROR );
+check( U_USING_FALLBACK_WARNING );
+check( U_ILLEGAL_ARGUMENT_ERROR );
+?>
+--EXPECT--
+false
+false
+true
diff --git a/ext/intl/tests/locale_accept.phpt b/ext/intl/tests/locale_accept.phpt
new file mode 100644
index 0000000..cf1dc6e
--- /dev/null
+++ b/ext/intl/tests/locale_accept.phpt
@@ -0,0 +1,46 @@
+--TEST--
+locale_accept_from_http
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try parsing different Locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = "";
+ $http_acc = array(
+ 'en-us,en;q=0.5',
+ 'da, en-gb;q=0.8, en;q=0.7',
+ 'zh, en-us;q=0.8, en;q=0.7',
+ 'xx, fr-FR;q=0.3, de-DE;q=0.5',
+ 'none',
+ array()
+ );
+
+ foreach($http_acc as $http) {
+ $res = ut_loc_accept_http($http);
+ $res_str .= @"Accepting $http: $res\n";
+ }
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTF--
+Warning: Locale::acceptFromHttp() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: locale_accept_from_http() expects parameter 1 to be string, array given in %s on line %d
+Accepting en-us,en;q=0.5: en_US
+Accepting da, en-gb;q=0.8, en;q=0.7: da
+Accepting zh, en-us;q=0.8, en;q=0.7: zh
+Accepting xx, fr-FR;q=0.3, de-DE;q=0.5: de_DE
+Accepting none:
+Accepting Array:
diff --git a/ext/intl/tests/locale_compose_locale.phpt b/ext/intl/tests/locale_compose_locale.phpt
new file mode 100644
index 0000000..2d0ca54
--- /dev/null
+++ b/ext/intl/tests/locale_compose_locale.phpt
@@ -0,0 +1,189 @@
+--TEST--
+locale_compose_locale()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try parsing different Locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $loc_parts_arr1 = array(
+ Locale::LANG_TAG =>'sl' ,
+ Locale::SCRIPT_TAG =>'Latn' ,
+ Locale::REGION_TAG =>'IT'
+ );
+ $loc_parts_arr2 = array(
+ Locale::LANG_TAG =>'de' ,
+ Locale::REGION_TAG =>'DE'
+ );
+ $loc_parts_arr3 = array(
+ Locale::LANG_TAG =>'hi'
+ );
+ $loc_parts_arr4 = array(
+ Locale::LANG_TAG =>'zh' ,
+ Locale::SCRIPT_TAG =>'Hans' ,
+ Locale::REGION_TAG =>'CN'
+ );
+ $loc_parts_arr5 = array(
+ Locale::LANG_TAG =>'es' ,
+ Locale::SCRIPT_TAG =>'Hans' ,
+ Locale::REGION_TAG =>'CN'
+ );
+ $loc_parts_arr6 = array(
+ Locale::LANG_TAG =>'en' ,
+ Locale::SCRIPT_TAG =>'Hans' ,
+ Locale::REGION_TAG =>'CN',
+ Locale::VARIANT_TAG.'14' =>'rozaj' ,
+ 'variant1'=>'nedis'
+ );
+ $loc_parts_arr7 = array(
+ Locale::LANG_TAG =>'en' ,
+ Locale::SCRIPT_TAG =>'Hans' ,
+ Locale::REGION_TAG =>'CN',
+ 'variant14'=>'rozaj' ,
+ 'variant1'=>'nedis' ,
+ 'extlang0'=>'lng' ,
+ 'extlang1'=>'ing'
+ );
+ $loc_parts_arr8 = array(
+ Locale::LANG_TAG =>'en' ,
+ Locale::SCRIPT_TAG =>'Hans' ,
+ Locale::REGION_TAG =>'CN',
+ 'variant14'=>'rozaj' ,
+ 'variant1'=>'nedis' ,
+ 'extlang0'=>'lng' ,
+ 'extlang1'=>'ing',
+ 'private7'=>'prv1' ,
+ 'private9'=>'prv2'
+ );
+ $loc_parts_arr9 = array(
+ Locale::REGION_TAG =>'DE'
+ );
+ $loc_parts_arr10 = array(
+ Locale::LANG_TAG => 45,
+ Locale::REGION_TAG => false,
+ Locale::SCRIPT_TAG => 15
+ );
+ $loc_parts_arr11 = array(
+ Locale::LANG_TAG =>'de' ,
+ Locale::REGION_TAG =>'DE',
+ 'private0' => 13,
+ 'variant1' => array(),
+ 'extlang2' => false
+ );
+ $loc_parts_arr12 = array(
+ Locale::LANG_TAG =>'en' ,
+ Locale::SCRIPT_TAG =>'Hans' ,
+ Locale::REGION_TAG =>'CN',
+ Locale::VARIANT_TAG => array('nedis', 'rozaj'),
+ Locale::PRIVATE_TAG => array('prv1', 'prv2'),
+ Locale::EXTLANG_TAG => array('lng', 'ing')
+ );
+
+
+ $loc_parts_arr = array(
+ 'loc1' => $loc_parts_arr1 ,
+ 'loc2' => $loc_parts_arr2 ,
+ 'loc3' => $loc_parts_arr3 ,
+ 'loc4' => $loc_parts_arr4 ,
+ 'loc5' => $loc_parts_arr5 ,
+ 'loc6' => $loc_parts_arr6 ,
+ 'loc7' => $loc_parts_arr7 ,
+ 'loc8' => $loc_parts_arr8 ,
+ 'loc9' => $loc_parts_arr9 ,
+ 'loc10' => $loc_parts_arr10 ,
+ 'loc11' => $loc_parts_arr11 ,
+ 'loc12' => $loc_parts_arr12
+ );
+
+ error_reporting( E_ERROR );
+
+ $cnt = 0;
+ $res_str = '';
+ foreach($loc_parts_arr as $key => $value ){
+ $res_str .= "\n------------";
+ $res_str .= "\nInput Array name is : loc".(++$cnt) ;
+/*
+ foreach($value as $valKey => $valValue ){
+ $res_str .= $valKey ."->".$valValue." " ;
+ }
+*/
+
+ $locale = ut_loc_locale_compose( $value);
+ $res_str .= "\n\nComposed Locale: ";
+ if( $locale){
+ $res_str .= "$locale";
+ }else{
+ $res_str .= "No values found from Locale compose due to the following error:\n";
+ $res_str .= intl_get_error_message() ;
+ }
+ }
+
+ $res_str .= "\n------------";
+ $res_str .= "\n";
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+------------
+Input Array name is : loc1
+
+Composed Locale: sl_Latn_IT
+------------
+Input Array name is : loc2
+
+Composed Locale: de_DE
+------------
+Input Array name is : loc3
+
+Composed Locale: hi
+------------
+Input Array name is : loc4
+
+Composed Locale: zh_Hans_CN
+------------
+Input Array name is : loc5
+
+Composed Locale: es_Hans_CN
+------------
+Input Array name is : loc6
+
+Composed Locale: en_Hans_CN_nedis_rozaj
+------------
+Input Array name is : loc7
+
+Composed Locale: en_lng_ing_Hans_CN_nedis_rozaj
+------------
+Input Array name is : loc8
+
+Composed Locale: en_lng_ing_Hans_CN_nedis_rozaj_x_prv1_prv2
+------------
+Input Array name is : loc9
+
+Composed Locale: No values found from Locale compose due to the following error:
+locale_compose: parameter array does not contain 'language' tag.: U_ILLEGAL_ARGUMENT_ERROR
+------------
+Input Array name is : loc10
+
+Composed Locale: No values found from Locale compose due to the following error:
+locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR
+------------
+Input Array name is : loc11
+
+Composed Locale: No values found from Locale compose due to the following error:
+locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR
+------------
+Input Array name is : loc12
+
+Composed Locale: en_lng_ing_Hans_CN_nedis_rozaj_x_prv1_prv2
+------------
diff --git a/ext/intl/tests/locale_filter_matches.phpt b/ext/intl/tests/locale_filter_matches.phpt
new file mode 100644
index 0000000..cada499
--- /dev/null
+++ b/ext/intl/tests/locale_filter_matches.phpt
@@ -0,0 +1,366 @@
+--TEST--
+locale_filter_matches.phpt() 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
+
+/*
+ * Try parsing different Locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $loc_ranges = array(
+ 'de-de',
+ 'sl_IT',
+ 'sl_IT_Nedis',
+ 'jbo',
+ 'art-lojban',
+ 'sl_IT'
+ );
+
+ $lang_tags = array(
+ 'de-DEVA',
+ 'de-DE-1996',
+ 'de-DE',
+ 'zh_Hans',
+ 'de-CH-1996',
+ 'sl_IT',
+ 'sl_IT_nedis-a-kirti-x-xyz',
+ 'sl_IT_rozaj',
+ 'sl_IT_NEDIS_ROJAZ_1901',
+ 'i-enochian',
+ 'sgn-CH-de',
+ 'art-lojban',
+ 'i-lux',
+ 'art-lojban',
+ 'jbo',
+ 'en_sl_IT'
+ );
+
+ $res_str = '';
+ $isCanonical = false;
+ foreach($loc_ranges as $loc_range){
+ foreach($lang_tags as $lang_tag){
+ $res_str .="--------------\n";
+ $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , $isCanonical);
+ $res_str .= "loc_range:$loc_range matches lang_tag $lang_tag ? ";
+ if( $result){
+ $res_str .= "YES\n";
+ }else{
+ $res_str .= "NO\n";
+ }
+//canonicalized version
+ $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , !($isCanonical));
+ $can_loc_range = ut_loc_canonicalize($loc_range);
+ $can_lang_tag = ut_loc_canonicalize($lang_tag);
+ $res_str .= "loc_range:$can_loc_range canonically matches lang_tag $can_lang_tag ? ";
+ if( $result){
+ $res_str .= "YES\n";
+ }else{
+ $res_str .= "NO\n";
+ }
+ }
+ }
+
+ $res_str .= "\n";
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+--------------
+loc_range:de-de matches lang_tag de-DEVA ? NO
+loc_range:de_DE canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:de-de matches lang_tag de-DE-1996 ? YES
+loc_range:de_DE canonically matches lang_tag de_DE_1996 ? YES
+--------------
+loc_range:de-de matches lang_tag de-DE ? YES
+loc_range:de_DE canonically matches lang_tag de_DE ? YES
+--------------
+loc_range:de-de matches lang_tag zh_Hans ? NO
+loc_range:de_DE canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:de-de matches lang_tag de-CH-1996 ? NO
+loc_range:de_DE canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:de-de matches lang_tag sl_IT ? NO
+loc_range:de_DE canonically matches lang_tag sl_IT ? NO
+--------------
+loc_range:de-de matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
+loc_range:de_DE canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
+--------------
+loc_range:de-de matches lang_tag sl_IT_rozaj ? NO
+loc_range:de_DE canonically matches lang_tag sl_IT_ROZAJ ? NO
+--------------
+loc_range:de-de matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+loc_range:de_DE canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+--------------
+loc_range:de-de matches lang_tag i-enochian ? NO
+loc_range:de_DE canonically matches lang_tag i-enochian ? NO
+--------------
+loc_range:de-de matches lang_tag sgn-CH-de ? NO
+loc_range:de_DE canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:de-de matches lang_tag art-lojban ? NO
+loc_range:de_DE canonically matches lang_tag jbo ? NO
+--------------
+loc_range:de-de matches lang_tag i-lux ? NO
+loc_range:de_DE canonically matches lang_tag i-lux ? NO
+--------------
+loc_range:de-de matches lang_tag art-lojban ? NO
+loc_range:de_DE canonically matches lang_tag jbo ? NO
+--------------
+loc_range:de-de matches lang_tag jbo ? NO
+loc_range:de_DE canonically matches lang_tag jbo ? NO
+--------------
+loc_range:de-de matches lang_tag en_sl_IT ? NO
+loc_range:de_DE canonically matches lang_tag en_SL_IT ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DEVA ? NO
+loc_range:sl_IT canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DE-1996 ? NO
+loc_range:sl_IT canonically matches lang_tag de_DE_1996 ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DE ? NO
+loc_range:sl_IT canonically matches lang_tag de_DE ? NO
+--------------
+loc_range:sl_IT matches lang_tag zh_Hans ? NO
+loc_range:sl_IT canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-CH-1996 ? NO
+loc_range:sl_IT canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:sl_IT matches lang_tag sl_IT ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_rozaj ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_ROZAJ ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+--------------
+loc_range:sl_IT matches lang_tag i-enochian ? NO
+loc_range:sl_IT canonically matches lang_tag i-enochian ? NO
+--------------
+loc_range:sl_IT matches lang_tag sgn-CH-de ? NO
+loc_range:sl_IT canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:sl_IT matches lang_tag art-lojban ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag i-lux ? NO
+loc_range:sl_IT canonically matches lang_tag i-lux ? NO
+--------------
+loc_range:sl_IT matches lang_tag art-lojban ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag jbo ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag en_sl_IT ? NO
+loc_range:sl_IT canonically matches lang_tag en_SL_IT ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag de-DEVA ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag de-DE-1996 ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag de_DE_1996 ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag de-DE ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag de_DE ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag zh_Hans ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag de-CH-1996 ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag sl_IT ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
+loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
+--------------
+loc_range:sl_IT_Nedis matches lang_tag sl_IT_rozaj ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_ROZAJ ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+--------------
+loc_range:sl_IT_Nedis matches lang_tag i-enochian ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag i-enochian ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag sgn-CH-de ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag art-lojban ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag i-lux ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag i-lux ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag art-lojban ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag jbo ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag en_sl_IT ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag en_SL_IT ? NO
+--------------
+loc_range:jbo matches lang_tag de-DEVA ? NO
+loc_range:jbo canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:jbo matches lang_tag de-DE-1996 ? NO
+loc_range:jbo canonically matches lang_tag de_DE_1996 ? NO
+--------------
+loc_range:jbo matches lang_tag de-DE ? NO
+loc_range:jbo canonically matches lang_tag de_DE ? NO
+--------------
+loc_range:jbo matches lang_tag zh_Hans ? NO
+loc_range:jbo canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:jbo matches lang_tag de-CH-1996 ? NO
+loc_range:jbo canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:jbo matches lang_tag sl_IT ? NO
+loc_range:jbo canonically matches lang_tag sl_IT ? NO
+--------------
+loc_range:jbo matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
+--------------
+loc_range:jbo matches lang_tag sl_IT_rozaj ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_ROZAJ ? NO
+--------------
+loc_range:jbo matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+--------------
+loc_range:jbo matches lang_tag i-enochian ? NO
+loc_range:jbo canonically matches lang_tag i-enochian ? NO
+--------------
+loc_range:jbo matches lang_tag sgn-CH-de ? NO
+loc_range:jbo canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:jbo matches lang_tag art-lojban ? NO
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:jbo matches lang_tag i-lux ? NO
+loc_range:jbo canonically matches lang_tag i-lux ? NO
+--------------
+loc_range:jbo matches lang_tag art-lojban ? NO
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:jbo matches lang_tag jbo ? YES
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:jbo matches lang_tag en_sl_IT ? NO
+loc_range:jbo canonically matches lang_tag en_SL_IT ? NO
+--------------
+loc_range:art-lojban matches lang_tag de-DEVA ? NO
+loc_range:jbo canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:art-lojban matches lang_tag de-DE-1996 ? NO
+loc_range:jbo canonically matches lang_tag de_DE_1996 ? NO
+--------------
+loc_range:art-lojban matches lang_tag de-DE ? NO
+loc_range:jbo canonically matches lang_tag de_DE ? NO
+--------------
+loc_range:art-lojban matches lang_tag zh_Hans ? NO
+loc_range:jbo canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:art-lojban matches lang_tag de-CH-1996 ? NO
+loc_range:jbo canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:art-lojban matches lang_tag sl_IT ? NO
+loc_range:jbo canonically matches lang_tag sl_IT ? NO
+--------------
+loc_range:art-lojban matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
+--------------
+loc_range:art-lojban matches lang_tag sl_IT_rozaj ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_ROZAJ ? NO
+--------------
+loc_range:art-lojban matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+--------------
+loc_range:art-lojban matches lang_tag i-enochian ? NO
+loc_range:jbo canonically matches lang_tag i-enochian ? NO
+--------------
+loc_range:art-lojban matches lang_tag sgn-CH-de ? NO
+loc_range:jbo canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:art-lojban matches lang_tag art-lojban ? YES
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:art-lojban matches lang_tag i-lux ? NO
+loc_range:jbo canonically matches lang_tag i-lux ? NO
+--------------
+loc_range:art-lojban matches lang_tag art-lojban ? YES
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:art-lojban matches lang_tag jbo ? NO
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:art-lojban matches lang_tag en_sl_IT ? NO
+loc_range:jbo canonically matches lang_tag en_SL_IT ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DEVA ? NO
+loc_range:sl_IT canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DE-1996 ? NO
+loc_range:sl_IT canonically matches lang_tag de_DE_1996 ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DE ? NO
+loc_range:sl_IT canonically matches lang_tag de_DE ? NO
+--------------
+loc_range:sl_IT matches lang_tag zh_Hans ? NO
+loc_range:sl_IT canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-CH-1996 ? NO
+loc_range:sl_IT canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:sl_IT matches lang_tag sl_IT ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_rozaj ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_ROZAJ ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+--------------
+loc_range:sl_IT matches lang_tag i-enochian ? NO
+loc_range:sl_IT canonically matches lang_tag i-enochian ? NO
+--------------
+loc_range:sl_IT matches lang_tag sgn-CH-de ? NO
+loc_range:sl_IT canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:sl_IT matches lang_tag art-lojban ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag i-lux ? NO
+loc_range:sl_IT canonically matches lang_tag i-lux ? NO
+--------------
+loc_range:sl_IT matches lang_tag art-lojban ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag jbo ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag en_sl_IT ? NO
+loc_range:sl_IT canonically matches lang_tag en_SL_IT ? NO
diff --git a/ext/intl/tests/locale_filter_matches2.phpt b/ext/intl/tests/locale_filter_matches2.phpt
new file mode 100644
index 0000000..37f9e5a
--- /dev/null
+++ b/ext/intl/tests/locale_filter_matches2.phpt
@@ -0,0 +1,366 @@
+--TEST--
+locale_filter_matches.phpt() 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 parsing different Locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $loc_ranges = array(
+ 'de-de',
+ 'sl_IT',
+ 'sl_IT_Nedis',
+ 'jbo',
+ 'art-lojban',
+ 'sl_IT'
+ );
+
+ $lang_tags = array(
+ 'de-DEVA',
+ 'de-DE-1996',
+ 'de-DE',
+ 'zh_Hans',
+ 'de-CH-1996',
+ 'sl_IT',
+ 'sl_IT_nedis-a-kirti-x-xyz',
+ 'sl_IT_rozaj',
+ 'sl_IT_NEDIS_ROJAZ_1901',
+ 'i-enochian',
+ 'sgn-CH-de',
+ 'art-lojban',
+ 'i-lux',
+ 'art-lojban',
+ 'jbo',
+ 'en_sl_IT'
+ );
+
+ $res_str = '';
+ $isCanonical = false;
+ foreach($loc_ranges as $loc_range){
+ foreach($lang_tags as $lang_tag){
+ $res_str .="--------------\n";
+ $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , $isCanonical);
+ $res_str .= "loc_range:$loc_range matches lang_tag $lang_tag ? ";
+ if( $result){
+ $res_str .= "YES\n";
+ }else{
+ $res_str .= "NO\n";
+ }
+//canonicalized version
+ $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , !($isCanonical));
+ $can_loc_range = ut_loc_canonicalize($loc_range);
+ $can_lang_tag = ut_loc_canonicalize($lang_tag);
+ $res_str .= "loc_range:$can_loc_range canonically matches lang_tag $can_lang_tag ? ";
+ if( $result){
+ $res_str .= "YES\n";
+ }else{
+ $res_str .= "NO\n";
+ }
+ }
+ }
+
+ $res_str .= "\n";
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+--------------
+loc_range:de-de matches lang_tag de-DEVA ? NO
+loc_range:de_DE canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:de-de matches lang_tag de-DE-1996 ? YES
+loc_range:de_DE canonically matches lang_tag de_DE_1996 ? YES
+--------------
+loc_range:de-de matches lang_tag de-DE ? YES
+loc_range:de_DE canonically matches lang_tag de_DE ? YES
+--------------
+loc_range:de-de matches lang_tag zh_Hans ? NO
+loc_range:de_DE canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:de-de matches lang_tag de-CH-1996 ? NO
+loc_range:de_DE canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:de-de matches lang_tag sl_IT ? NO
+loc_range:de_DE canonically matches lang_tag sl_IT ? NO
+--------------
+loc_range:de-de matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
+loc_range:de_DE canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
+--------------
+loc_range:de-de matches lang_tag sl_IT_rozaj ? NO
+loc_range:de_DE canonically matches lang_tag sl_IT_ROZAJ ? NO
+--------------
+loc_range:de-de matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+loc_range:de_DE canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+--------------
+loc_range:de-de matches lang_tag i-enochian ? NO
+loc_range:de_DE canonically matches lang_tag @x=i-enochian ? NO
+--------------
+loc_range:de-de matches lang_tag sgn-CH-de ? NO
+loc_range:de_DE canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:de-de matches lang_tag art-lojban ? NO
+loc_range:de_DE canonically matches lang_tag jbo ? NO
+--------------
+loc_range:de-de matches lang_tag i-lux ? NO
+loc_range:de_DE canonically matches lang_tag lb ? NO
+--------------
+loc_range:de-de matches lang_tag art-lojban ? NO
+loc_range:de_DE canonically matches lang_tag jbo ? NO
+--------------
+loc_range:de-de matches lang_tag jbo ? NO
+loc_range:de_DE canonically matches lang_tag jbo ? NO
+--------------
+loc_range:de-de matches lang_tag en_sl_IT ? NO
+loc_range:de_DE canonically matches lang_tag en_SL_IT ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DEVA ? NO
+loc_range:sl_IT canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DE-1996 ? NO
+loc_range:sl_IT canonically matches lang_tag de_DE_1996 ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DE ? NO
+loc_range:sl_IT canonically matches lang_tag de_DE ? NO
+--------------
+loc_range:sl_IT matches lang_tag zh_Hans ? NO
+loc_range:sl_IT canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-CH-1996 ? NO
+loc_range:sl_IT canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:sl_IT matches lang_tag sl_IT ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_rozaj ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_ROZAJ ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+--------------
+loc_range:sl_IT matches lang_tag i-enochian ? NO
+loc_range:sl_IT canonically matches lang_tag @x=i-enochian ? NO
+--------------
+loc_range:sl_IT matches lang_tag sgn-CH-de ? NO
+loc_range:sl_IT canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:sl_IT matches lang_tag art-lojban ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag i-lux ? NO
+loc_range:sl_IT canonically matches lang_tag lb ? NO
+--------------
+loc_range:sl_IT matches lang_tag art-lojban ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag jbo ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag en_sl_IT ? NO
+loc_range:sl_IT canonically matches lang_tag en_SL_IT ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag de-DEVA ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag de-DE-1996 ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag de_DE_1996 ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag de-DE ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag de_DE ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag zh_Hans ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag de-CH-1996 ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag sl_IT ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
+loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
+--------------
+loc_range:sl_IT_Nedis matches lang_tag sl_IT_rozaj ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_ROZAJ ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+--------------
+loc_range:sl_IT_Nedis matches lang_tag i-enochian ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag @x=i-enochian ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag sgn-CH-de ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag art-lojban ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag i-lux ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag lb ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag art-lojban ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag jbo ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT_Nedis matches lang_tag en_sl_IT ? NO
+loc_range:sl_IT_NEDIS canonically matches lang_tag en_SL_IT ? NO
+--------------
+loc_range:jbo matches lang_tag de-DEVA ? NO
+loc_range:jbo canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:jbo matches lang_tag de-DE-1996 ? NO
+loc_range:jbo canonically matches lang_tag de_DE_1996 ? NO
+--------------
+loc_range:jbo matches lang_tag de-DE ? NO
+loc_range:jbo canonically matches lang_tag de_DE ? NO
+--------------
+loc_range:jbo matches lang_tag zh_Hans ? NO
+loc_range:jbo canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:jbo matches lang_tag de-CH-1996 ? NO
+loc_range:jbo canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:jbo matches lang_tag sl_IT ? NO
+loc_range:jbo canonically matches lang_tag sl_IT ? NO
+--------------
+loc_range:jbo matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
+--------------
+loc_range:jbo matches lang_tag sl_IT_rozaj ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_ROZAJ ? NO
+--------------
+loc_range:jbo matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+--------------
+loc_range:jbo matches lang_tag i-enochian ? NO
+loc_range:jbo canonically matches lang_tag @x=i-enochian ? NO
+--------------
+loc_range:jbo matches lang_tag sgn-CH-de ? NO
+loc_range:jbo canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:jbo matches lang_tag art-lojban ? NO
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:jbo matches lang_tag i-lux ? NO
+loc_range:jbo canonically matches lang_tag lb ? NO
+--------------
+loc_range:jbo matches lang_tag art-lojban ? NO
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:jbo matches lang_tag jbo ? YES
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:jbo matches lang_tag en_sl_IT ? NO
+loc_range:jbo canonically matches lang_tag en_SL_IT ? NO
+--------------
+loc_range:art-lojban matches lang_tag de-DEVA ? NO
+loc_range:jbo canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:art-lojban matches lang_tag de-DE-1996 ? NO
+loc_range:jbo canonically matches lang_tag de_DE_1996 ? NO
+--------------
+loc_range:art-lojban matches lang_tag de-DE ? NO
+loc_range:jbo canonically matches lang_tag de_DE ? NO
+--------------
+loc_range:art-lojban matches lang_tag zh_Hans ? NO
+loc_range:jbo canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:art-lojban matches lang_tag de-CH-1996 ? NO
+loc_range:jbo canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:art-lojban matches lang_tag sl_IT ? NO
+loc_range:jbo canonically matches lang_tag sl_IT ? NO
+--------------
+loc_range:art-lojban matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
+--------------
+loc_range:art-lojban matches lang_tag sl_IT_rozaj ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_ROZAJ ? NO
+--------------
+loc_range:art-lojban matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
+--------------
+loc_range:art-lojban matches lang_tag i-enochian ? NO
+loc_range:jbo canonically matches lang_tag @x=i-enochian ? NO
+--------------
+loc_range:art-lojban matches lang_tag sgn-CH-de ? NO
+loc_range:jbo canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:art-lojban matches lang_tag art-lojban ? YES
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:art-lojban matches lang_tag i-lux ? NO
+loc_range:jbo canonically matches lang_tag lb ? NO
+--------------
+loc_range:art-lojban matches lang_tag art-lojban ? YES
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:art-lojban matches lang_tag jbo ? NO
+loc_range:jbo canonically matches lang_tag jbo ? YES
+--------------
+loc_range:art-lojban matches lang_tag en_sl_IT ? NO
+loc_range:jbo canonically matches lang_tag en_SL_IT ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DEVA ? NO
+loc_range:sl_IT canonically matches lang_tag de_Deva ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DE-1996 ? NO
+loc_range:sl_IT canonically matches lang_tag de_DE_1996 ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-DE ? NO
+loc_range:sl_IT canonically matches lang_tag de_DE ? NO
+--------------
+loc_range:sl_IT matches lang_tag zh_Hans ? NO
+loc_range:sl_IT canonically matches lang_tag zh_Hans ? NO
+--------------
+loc_range:sl_IT matches lang_tag de-CH-1996 ? NO
+loc_range:sl_IT canonically matches lang_tag de_CH_1996 ? NO
+--------------
+loc_range:sl_IT matches lang_tag sl_IT ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_rozaj ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_ROZAJ ? YES
+--------------
+loc_range:sl_IT matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
+--------------
+loc_range:sl_IT matches lang_tag i-enochian ? NO
+loc_range:sl_IT canonically matches lang_tag @x=i-enochian ? NO
+--------------
+loc_range:sl_IT matches lang_tag sgn-CH-de ? NO
+loc_range:sl_IT canonically matches lang_tag sgn_CH_DE ? NO
+--------------
+loc_range:sl_IT matches lang_tag art-lojban ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag i-lux ? NO
+loc_range:sl_IT canonically matches lang_tag lb ? NO
+--------------
+loc_range:sl_IT matches lang_tag art-lojban ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag jbo ? NO
+loc_range:sl_IT canonically matches lang_tag jbo ? NO
+--------------
+loc_range:sl_IT matches lang_tag en_sl_IT ? NO
+loc_range:sl_IT canonically matches lang_tag en_SL_IT ? NO
diff --git a/ext/intl/tests/locale_get_all_variants.phpt b/ext/intl/tests/locale_get_all_variants.phpt
new file mode 100644
index 0000000..864b8a2
--- /dev/null
+++ b/ext/intl/tests/locale_get_all_variants.phpt
@@ -0,0 +1,62 @@
+--TEST--
+locale_get_all_variants.phpt()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try parsing different Locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $locales = array(
+ 'sl_IT_nedis_KIRTI',
+ 'sl_IT_nedis-a-kirti-x-xyz',
+ 'sl_IT_rozaj',
+ 'sl_IT_NEDIS_ROJAZ_1901',
+ 'i-enochian',
+ 'zh-hakka',
+ 'zh-wuu',
+ 'i-tay',
+ 'sgn-BE-nl',
+ 'sgn-CH-de',
+ 'sl_IT_rozaj@currency=EUR'
+ );
+ $res_str = '';
+ foreach($locales as $locale){
+ $variants_arr = ut_loc_locale_get_all_variants( $locale);
+ $res_str .= "$locale : variants ";
+ if( $variants_arr){
+ foreach($variants_arr as $variant){
+ $res_str .= "'$variant',";
+ }
+ }else{
+ $res_str .= "--none";
+ }
+ $res_str .= "\n";
+ }
+
+ $res_str .= "\n";
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+sl_IT_nedis_KIRTI : variants 'NEDIS','KIRTI',
+sl_IT_nedis-a-kirti-x-xyz : variants 'NEDIS',
+sl_IT_rozaj : variants 'ROZAJ',
+sl_IT_NEDIS_ROJAZ_1901 : variants 'NEDIS','ROJAZ','1901',
+i-enochian : variants --none
+zh-hakka : variants --none
+zh-wuu : variants --none
+i-tay : variants --none
+sgn-BE-nl : variants --none
+sgn-CH-de : variants --none
+sl_IT_rozaj@currency=EUR : variants 'ROZAJ',
diff --git a/ext/intl/tests/locale_get_default.phpt b/ext/intl/tests/locale_get_default.phpt
new file mode 100644
index 0000000..57c46cc
--- /dev/null
+++ b/ext/intl/tests/locale_get_default.phpt
@@ -0,0 +1,46 @@
+--TEST--
+locale_get_default()
+--INI--
+intl.default_locale=en-US
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try getting the default Locale with different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $lang = ut_loc_get_default() ;
+ $res_str .= "Default locale: $lang";
+ $res_str .= "\n";
+
+ locale_set_default('de-DE');
+ $lang = ut_loc_get_default() ;
+ $res_str .= "Default locale: $lang";
+ $res_str .= "\n";
+
+ ini_set('intl.default_locale', 'fr');
+ $lang = ut_loc_get_default() ;
+ $res_str .= "Default locale: $lang";
+ $res_str .= "\n";
+
+ ini_restore("intl.default_locale");
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+Default locale: en-US
+Default locale: de-DE
+Default locale: fr
diff --git a/ext/intl/tests/locale_get_display_language.phpt b/ext/intl/tests/locale_get_display_language.phpt
new file mode 100644
index 0000000..2e00056
--- /dev/null
+++ b/ext/intl/tests/locale_get_display_language.phpt
@@ -0,0 +1,280 @@
+--TEST--
+locale_get_display_language()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try getting the display_language for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str='';
+
+ $disp_locales=array('en','fr','de');
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+ 'art-lojban', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $res_str .= "locale='$locale'\n";
+ foreach( $disp_locales as $disp_locale )
+ {
+ $scr = ut_loc_get_display_language( $locale ,$disp_locale );
+ $res_str .= "disp_locale=$disp_locale : display_language=$scr";
+ $res_str .= "\n";
+ }
+ $res_str .= "-----------------\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTREGEX--
+locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
+disp_locale=en : display_language=Ukrainian
+disp_locale=fr : display_language=ukrainien
+disp_locale=de : display_language=Ukrainisch
+-----------------
+locale='root'
+disp_locale=en : display_language=Root
+disp_locale=fr : display_language=racine
+disp_locale=de : display_language=[rR]oot
+-----------------
+locale='uk@currency=EURO'
+disp_locale=en : display_language=Ukrainian
+disp_locale=fr : display_language=ukrainien
+disp_locale=de : display_language=Ukrainisch
+-----------------
+locale='Hindi'
+disp_locale=en : display_language=hindi
+disp_locale=fr : display_language=hindi
+disp_locale=de : display_language=hindi
+-----------------
+locale='de'
+disp_locale=en : display_language=German
+disp_locale=fr : display_language=allemand
+disp_locale=de : display_language=Deutsch
+-----------------
+locale='fr'
+disp_locale=en : display_language=French
+disp_locale=fr : display_language=français
+disp_locale=de : display_language=Französisch
+-----------------
+locale='ja'
+disp_locale=en : display_language=Japanese
+disp_locale=fr : display_language=japonais
+disp_locale=de : display_language=Japanisch
+-----------------
+locale='i-enochian'
+disp_locale=en : display_language=i-enochian
+disp_locale=fr : display_language=i-enochian
+disp_locale=de : display_language=i-enochian
+-----------------
+locale='art-lojban'
+disp_locale=en : display_language=Lojban
+disp_locale=fr : display_language=lojban
+disp_locale=de : display_language=Lojban
+-----------------
+locale='zh-Hant'
+disp_locale=en : display_language=Chinese
+disp_locale=fr : display_language=chinois
+disp_locale=de : display_language=Chinesisch
+-----------------
+locale='zh-Hans'
+disp_locale=en : display_language=Chinese
+disp_locale=fr : display_language=chinois
+disp_locale=de : display_language=Chinesisch
+-----------------
+locale='sr-Cyrl'
+disp_locale=en : display_language=Serbian
+disp_locale=fr : display_language=serbe
+disp_locale=de : display_language=Serbisch
+-----------------
+locale='sr-Latn'
+disp_locale=en : display_language=Serbian
+disp_locale=fr : display_language=serbe
+disp_locale=de : display_language=Serbisch
+-----------------
+locale='zh-Hans-CN'
+disp_locale=en : display_language=Chinese
+disp_locale=fr : display_language=chinois
+disp_locale=de : display_language=Chinesisch
+-----------------
+locale='sr-Latn-CS'
+disp_locale=en : display_language=Serbian
+disp_locale=fr : display_language=serbe
+disp_locale=de : display_language=Serbisch
+-----------------
+locale='sl-rozaj'
+disp_locale=en : display_language=Slovenian
+disp_locale=fr : display_language=slovène
+disp_locale=de : display_language=Slowenisch
+-----------------
+locale='sl-nedis'
+disp_locale=en : display_language=Slovenian
+disp_locale=fr : display_language=slovène
+disp_locale=de : display_language=Slowenisch
+-----------------
+locale='de-CH-1901'
+disp_locale=en : display_language=German
+disp_locale=fr : display_language=allemand
+disp_locale=de : display_language=Deutsch
+-----------------
+locale='sl-IT-nedis'
+disp_locale=en : display_language=Slovenian
+disp_locale=fr : display_language=slovène
+disp_locale=de : display_language=Slowenisch
+-----------------
+locale='sl-Latn-IT-nedis'
+disp_locale=en : display_language=Slovenian
+disp_locale=fr : display_language=slovène
+disp_locale=de : display_language=Slowenisch
+-----------------
+locale='de-DE'
+disp_locale=en : display_language=German
+disp_locale=fr : display_language=allemand
+disp_locale=de : display_language=Deutsch
+-----------------
+locale='en-US'
+disp_locale=en : display_language=English
+disp_locale=fr : display_language=anglais
+disp_locale=de : display_language=Englisch
+-----------------
+locale='es-419'
+disp_locale=en : display_language=Spanish
+disp_locale=fr : display_language=espagnol
+disp_locale=de : display_language=Spanisch
+-----------------
+locale='de-CH-x-phonebk'
+disp_locale=en : display_language=German
+disp_locale=fr : display_language=allemand
+disp_locale=de : display_language=Deutsch
+-----------------
+locale='az-Arab-x-AZE-derbend'
+disp_locale=en : display_language=Azerbaijani
+disp_locale=fr : display_language=azéri
+disp_locale=de : display_language=Aserbaidschanisch
+-----------------
+locale='zh-min'
+disp_locale=en : display_language=Chinese
+disp_locale=fr : display_language=chinois
+disp_locale=de : display_language=Chinesisch
+-----------------
+locale='zh-min-nan-Hant-CN'
+disp_locale=en : display_language=Chinese
+disp_locale=fr : display_language=chinois
+disp_locale=de : display_language=Chinesisch
+-----------------
+locale='x-whatever'
+disp_locale=en : display_language=x-whatever
+disp_locale=fr : display_language=x-whatever
+disp_locale=de : display_language=x-whatever
+-----------------
+locale='qaa-Qaaa-QM-x-southern'
+disp_locale=en : display_language=qaa
+disp_locale=fr : display_language=qaa
+disp_locale=de : display_language=qaa
+-----------------
+locale='sr-Latn-QM'
+disp_locale=en : display_language=Serbian
+disp_locale=fr : display_language=serbe
+disp_locale=de : display_language=Serbisch
+-----------------
+locale='sr-Qaaa-CS'
+disp_locale=en : display_language=Serbian
+disp_locale=fr : display_language=serbe
+disp_locale=de : display_language=Serbisch
+-----------------
+locale='en-US-u-islamCal'
+disp_locale=en : display_language=English
+disp_locale=fr : display_language=anglais
+disp_locale=de : display_language=Englisch
+-----------------
+locale='zh-CN-a-myExt-x-private'
+disp_locale=en : display_language=Chinese
+disp_locale=fr : display_language=chinois
+disp_locale=de : display_language=Chinesisch
+-----------------
+locale='en-a-myExt-b-another'
+disp_locale=en : display_language=English
+disp_locale=fr : display_language=anglais
+disp_locale=de : display_language=Englisch
+-----------------
+locale='de-419-DE'
+disp_locale=en : display_language=German
+disp_locale=fr : display_language=allemand
+disp_locale=de : display_language=Deutsch
+-----------------
+locale='a-DE'
+disp_locale=en : display_language=a
+disp_locale=fr : display_language=a
+disp_locale=de : display_language=a
+-----------------
+locale='ar-a-aaa-b-bbb-a-ccc'
+disp_locale=en : display_language=Arabic
+disp_locale=fr : display_language=arabe
+disp_locale=de : display_language=Arabisch
+-----------------
diff --git a/ext/intl/tests/locale_get_display_name.phpt b/ext/intl/tests/locale_get_display_name.phpt
new file mode 100644
index 0000000..b128734
--- /dev/null
+++ b/ext/intl/tests/locale_get_display_name.phpt
@@ -0,0 +1,342 @@
+--TEST--
+locale_get_display_name() 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
+
+/*
+ * Try getting the display_name for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str='';
+
+ $disp_locales=array('en','fr','de');
+
+ $locales = array(
+ 'sl_IT_nedis_KIRTI',
+ 'sl_IT_nedis-a-kirti-x-xyz',
+ 'sl_IT_rozaj',
+ 'sl_IT_NEDIS_ROJAZ_1901',
+ 'i-enochian',
+ 'zh-hakka',
+ 'zh-wuu',
+ 'i-tay',
+ 'sgn-BE-nl',
+ 'sgn-CH-de',
+ 'sl_IT_rozaj@currency=EUR',
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $res_str .= "locale='$locale'\n";
+ foreach( $disp_locales as $disp_locale )
+ {
+ $scr = ut_loc_get_display_name( $locale ,$disp_locale );
+ $scr = str_replace(array('(', ')'), '#', $scr);
+ $res_str .= "disp_locale=$disp_locale : display_name=$scr";
+ $res_str .= "\n";
+ }
+ $res_str .= "-----------------\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTREGEX--
+locale='sl_IT_nedis_KIRTI'
+disp_locale=en : display_name=Slovenian #Italy, NEDIS_KIRTI#
+disp_locale=fr : display_name=slovène #Italie, NEDIS_KIRTI#
+disp_locale=de : display_name=Slowenisch #Italien, NEDIS_KIRTI#
+-----------------
+locale='sl_IT_nedis-a-kirti-x-xyz'
+disp_locale=en : display_name=Slovenian #Italy, NEDIS_A_KIRTI_X_XYZ#
+disp_locale=fr : display_name=slovène #Italie, NEDIS_A_KIRTI_X_XYZ#
+disp_locale=de : display_name=Slowenisch #Italien, NEDIS_A_KIRTI_X_XYZ#
+-----------------
+locale='sl_IT_rozaj'
+disp_locale=en : display_name=Slovenian #Italy, Resian#
+disp_locale=fr : display_name=slovène #Italie, dialecte de Resia#
+disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch)#
+-----------------
+locale='sl_IT_NEDIS_ROJAZ_1901'
+disp_locale=en : display_name=Slovenian #Italy, NEDIS_ROJAZ_1901#
+disp_locale=fr : display_name=slovène #Italie, NEDIS_ROJAZ_1901#
+disp_locale=de : display_name=Slowenisch #Italien, NEDIS_ROJAZ_1901#
+-----------------
+locale='i-enochian'
+disp_locale=en : display_name=i-enochian
+disp_locale=fr : display_name=i-enochian
+disp_locale=de : display_name=i-enochian
+-----------------
+locale='zh-hakka'
+disp_locale=en : display_name=Chinese( #HAKKA#)?
+disp_locale=fr : display_name=chinois( #HAKKA#)?
+disp_locale=de : display_name=Chinesisch( #HAKKA#)?
+-----------------
+locale='zh-wuu'
+disp_locale=en : display_name=Chinese #WUU#
+disp_locale=fr : display_name=chinois #WUU#
+disp_locale=de : display_name=Chinesisch #WUU#
+-----------------
+locale='i-tay'
+disp_locale=en : display_name=i-tay
+disp_locale=fr : display_name=i-tay
+disp_locale=de : display_name=i-tay
+-----------------
+locale='sgn-BE-nl'
+disp_locale=en : display_name=Sign Languages? #Belgium, NL#
+disp_locale=fr : display_name=langues? des signes #Belgique, NL#
+disp_locale=de : display_name=Gebärdensprache #Belgien, NL#
+-----------------
+locale='sgn-CH-de'
+disp_locale=en : display_name=Sign Languages? #Switzerland, DE#
+disp_locale=fr : display_name=langues? des signes #Suisse, DE#
+disp_locale=de : display_name=Gebärdensprache #Schweiz, DE#
+-----------------
+locale='sl_IT_rozaj@currency=EUR'
+disp_locale=en : display_name=Slovenian #Italy, Resian, [Cc]urrency=Euro#
+disp_locale=fr : display_name=slovène #Italie, dialecte de Resia, Devise=euro#
+disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch), Währung=Euro#
+-----------------
+locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
+disp_locale=en : display_name=Ukrainian #Ukraine, CALIFORNIA, [Cc]urrency#
+disp_locale=fr : display_name=ukrainien #Ukraine, CALIFORNIA, Devise#
+disp_locale=de : display_name=Ukrainisch #Ukraine, CALIFORNIA, Währung#
+-----------------
+locale='root'
+disp_locale=en : display_name=Root
+disp_locale=fr : display_name=racine
+disp_locale=de : display_name=[Rr]oot
+-----------------
+locale='uk@currency=EURO'
+disp_locale=en : display_name=Ukrainian #[Cc]urrency=EURO#
+disp_locale=fr : display_name=ukrainien #Devise=EURO#
+disp_locale=de : display_name=Ukrainisch #Währung=EURO#
+-----------------
+locale='Hindi'
+disp_locale=en : display_name=hindi
+disp_locale=fr : display_name=hindi
+disp_locale=de : display_name=hindi
+-----------------
+locale='de'
+disp_locale=en : display_name=German
+disp_locale=fr : display_name=allemand
+disp_locale=de : display_name=Deutsch
+-----------------
+locale='fr'
+disp_locale=en : display_name=French
+disp_locale=fr : display_name=français
+disp_locale=de : display_name=Französisch
+-----------------
+locale='ja'
+disp_locale=en : display_name=Japanese
+disp_locale=fr : display_name=japonais
+disp_locale=de : display_name=Japanisch
+-----------------
+locale='i-enochian'
+disp_locale=en : display_name=i-enochian
+disp_locale=fr : display_name=i-enochian
+disp_locale=de : display_name=i-enochian
+-----------------
+locale='zh-Hant'
+disp_locale=en : display_name=Chinese #Traditional Han#
+disp_locale=fr : display_name=chinois #idéogrammes han (#variante traditionnelle#|traditionnels)#
+disp_locale=de : display_name=Chinesisch #Traditionelle Chinesische Schrift#
+-----------------
+locale='zh-Hans'
+disp_locale=en : display_name=Chinese #Simplified Han#
+disp_locale=fr : display_name=chinois #idéogrammes han (#variante simplifiée#|simplifiés)#
+disp_locale=de : display_name=Chinesisch #Vereinfachte Chinesische Schrift#
+-----------------
+locale='sr-Cyrl'
+disp_locale=en : display_name=Serbian #Cyrillic#
+disp_locale=fr : display_name=serbe #cyrillique#
+disp_locale=de : display_name=Serbisch #Kyrillisch#
+-----------------
+locale='sr-Latn'
+disp_locale=en : display_name=Serbian #Latin#
+disp_locale=fr : display_name=serbe #latin#
+disp_locale=de : display_name=Serbisch #Lateinisch#
+-----------------
+locale='zh-Hans-CN'
+disp_locale=en : display_name=Chinese #Simplified Han, China#
+disp_locale=fr : display_name=chinois #idéogrammes han (#variante simplifiée#|simplifiés), Chine#
+disp_locale=de : display_name=Chinesisch #Vereinfachte Chinesische Schrift, China#
+-----------------
+locale='sr-Latn-CS'
+disp_locale=en : display_name=Serbian #Latin, Serbia [aA]nd Montenegro#
+disp_locale=fr : display_name=serbe #latin, Serbie-et-Monténégro#
+disp_locale=de : display_name=Serbisch #Lateinisch, Serbien und Montenegro#
+-----------------
+locale='sl-rozaj'
+disp_locale=en : display_name=Slovenian( #ROZAJ#)?
+disp_locale=fr : display_name=slovène( #ROZAJ#)?
+disp_locale=de : display_name=Slowenisch( #(ROZAJ|Resianisch)#)?
+-----------------
+locale='sl-nedis'
+disp_locale=en : display_name=Slovenian( #NEDIS#)?
+disp_locale=fr : display_name=slovène( #NEDIS#)?
+disp_locale=de : display_name=Slowenisch( #NEDIS#)?
+-----------------
+locale='de-CH-1901'
+disp_locale=en : display_name=German #Switzerland, Traditional German orthography#
+disp_locale=fr : display_name=allemand #Suisse, orthographe allemande traditionnelle#
+disp_locale=de : display_name=Deutsch #Schweiz, (1901|[aA]lte deutsche Rechtschreibung)#
+-----------------
+locale='sl-IT-nedis'
+disp_locale=en : display_name=Slovenian #Italy, Natisone dialect#
+disp_locale=fr : display_name=slovène #Italie, dialecte de Natisone#
+disp_locale=de : display_name=Slowenisch #Italien, (NEDIS|Natisone-Dialekt)#
+-----------------
+locale='sl-Latn-IT-nedis'
+disp_locale=en : display_name=Slovenian #Latin, Italy, Natisone dialect#
+disp_locale=fr : display_name=slovène #latin, Italie, dialecte de Natisone#
+disp_locale=de : display_name=Slowenisch #Lateinisch, Italien, (NEDIS|Natisone-Dialekt)#
+-----------------
+locale='de-DE'
+disp_locale=en : display_name=German #Germany#
+disp_locale=fr : display_name=allemand #Allemagne#
+disp_locale=de : display_name=Deutsch #Deutschland#
+-----------------
+locale='en-US'
+disp_locale=en : display_name=English #United States#
+disp_locale=fr : display_name=anglais #États-Unis#
+disp_locale=de : display_name=Englisch #Vereinigte Staaten#
+-----------------
+locale='es-419'
+disp_locale=en : display_name=Spanish #Latin America and the Caribbean#
+disp_locale=fr : display_name=espagnol #Amérique latine et Caraïbes#
+disp_locale=de : display_name=Spanisch #Lateinamerika und Karibik#
+-----------------
+locale='de-CH-x-phonebk'
+disp_locale=en : display_name=German #Switzerland, X_PHONEBK#
+disp_locale=fr : display_name=allemand #Suisse, X_PHONEBK#
+disp_locale=de : display_name=Deutsch #Schweiz, X_PHONEBK#
+-----------------
+locale='az-Arab-x-AZE-derbend'
+disp_locale=en : display_name=Azerbaijani #Arabic(, X, AZE_DERBEND)?#
+disp_locale=fr : display_name=azéri #arabe(, X, AZE_DERBEND)?#
+disp_locale=de : display_name=Aserbaidschanisch #Arabisch(, X, AZE_DERBEND)?#
+-----------------
+locale='zh-min'
+disp_locale=en : display_name=Chinese #MIN#
+disp_locale=fr : display_name=chinois #MIN#
+disp_locale=de : display_name=Chinesisch #MIN#
+-----------------
+locale='zh-min-nan-Hant-CN'
+disp_locale=en : display_name=Chinese #MIN, NAN_HANT_CN#
+disp_locale=fr : display_name=chinois #MIN, NAN_HANT_CN#
+disp_locale=de : display_name=Chinesisch #MIN, NAN_HANT_CN#
+-----------------
+locale='x-whatever'
+disp_locale=en : display_name=x-whatever
+disp_locale=fr : display_name=x-whatever
+disp_locale=de : display_name=x-whatever
+-----------------
+locale='qaa-Qaaa-QM-x-southern'
+disp_locale=en : display_name=qaa #Qaaa, QM, X_SOUTHERN#
+disp_locale=fr : display_name=qaa #Qaaa, QM, X_SOUTHERN#
+disp_locale=de : display_name=qaa #Qaaa, QM, X_SOUTHERN#
+-----------------
+locale='sr-Latn-QM'
+disp_locale=en : display_name=Serbian #Latin, QM#
+disp_locale=fr : display_name=serbe #latin, QM#
+disp_locale=de : display_name=Serbisch #Lateinisch, QM#
+-----------------
+locale='sr-Qaaa-CS'
+disp_locale=en : display_name=Serbian #Qaaa, Serbia [aA]nd Montenegro#
+disp_locale=fr : display_name=serbe #Qaaa, Serbie-et-Monténégro#
+disp_locale=de : display_name=Serbisch #Qaaa, Serbien und Montenegro#
+-----------------
+locale='en-US-u-islamCal'
+disp_locale=en : display_name=English #United States, U_ISLAMCAL#
+disp_locale=fr : display_name=anglais #États-Unis, U_ISLAMCAL#
+disp_locale=de : display_name=Englisch #Vereinigte Staaten, U_ISLAMCAL#
+-----------------
+locale='zh-CN-a-myExt-x-private'
+disp_locale=en : display_name=Chinese #China, A_MYEXT_X_PRIVATE#
+disp_locale=fr : display_name=chinois #Chine, A_MYEXT_X_PRIVATE#
+disp_locale=de : display_name=Chinesisch #China, A_MYEXT_X_PRIVATE#
+-----------------
+locale='en-a-myExt-b-another'
+disp_locale=en : display_name=English( #A, MYEXT_B_ANOTHER#)?
+disp_locale=fr : display_name=anglais( #A, MYEXT_B_ANOTHER#)?
+disp_locale=de : display_name=Englisch( #A, MYEXT_B_ANOTHER#)?
+-----------------
+locale='de-419-DE'
+disp_locale=en : display_name=German #Latin America and the Caribbean, DE#
+disp_locale=fr : display_name=allemand #Amérique latine et Caraïbes, DE#
+disp_locale=de : display_name=Deutsch #Lateinamerika und Karibik, DE#
+-----------------
+locale='a-DE'
+disp_locale=en : display_name=a #Germany#
+disp_locale=fr : display_name=a #Allemagne#
+disp_locale=de : display_name=a #Deutschland#
+-----------------
+locale='ar-a-aaa-b-bbb-a-ccc'
+disp_locale=en : display_name=Arabic( #A, AAA_B_BBB_A_CCC#)?
+disp_locale=fr : display_name=arabe( #A, AAA_B_BBB_A_CCC#)?
+disp_locale=de : display_name=Arabisch( #A, AAA_B_BBB_A_CCC#)?
+-----------------
diff --git a/ext/intl/tests/locale_get_display_name2.phpt b/ext/intl/tests/locale_get_display_name2.phpt
new file mode 100644
index 0000000..40ccc0c
--- /dev/null
+++ b/ext/intl/tests/locale_get_display_name2.phpt
@@ -0,0 +1,342 @@
+--TEST--
+locale_get_display_name() 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 getting the display_name for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str='';
+
+ $disp_locales=array('en','fr','de');
+
+ $locales = array(
+ 'sl_IT_nedis_KIRTI',
+ 'sl_IT_nedis-a-kirti-x-xyz',
+ 'sl_IT_rozaj',
+ 'sl_IT_NEDIS_ROJAZ_1901',
+ 'i-enochian',
+ 'zh-hakka',
+ 'zh-wuu',
+ 'i-tay',
+ 'sgn-BE-nl',
+ 'sgn-CH-de',
+ 'sl_IT_rozaj@currency=EUR',
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $res_str .= "locale='$locale'\n";
+ foreach( $disp_locales as $disp_locale )
+ {
+ $scr = ut_loc_get_display_name( $locale ,$disp_locale );
+ $scr = str_replace(array('(', ')'), '#', $scr);
+ $res_str .= "disp_locale=$disp_locale : display_name=$scr";
+ $res_str .= "\n";
+ }
+ $res_str .= "-----------------\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTREGEX--
+locale='sl_IT_nedis_KIRTI'
+disp_locale=en : display_name=Slovenian #Italy, NEDIS_KIRTI#
+disp_locale=fr : display_name=slovène #Italie, NEDIS_KIRTI#
+disp_locale=de : display_name=Slowenisch #Italien, NEDIS_KIRTI#
+-----------------
+locale='sl_IT_nedis-a-kirti-x-xyz'
+disp_locale=en : display_name=Slovenian #Italy, NEDIS_A_KIRTI_X_XYZ#
+disp_locale=fr : display_name=slovène #Italie, NEDIS_A_KIRTI_X_XYZ#
+disp_locale=de : display_name=Slowenisch #Italien, NEDIS_A_KIRTI_X_XYZ#
+-----------------
+locale='sl_IT_rozaj'
+disp_locale=en : display_name=Slovenian #Italy, Resian#
+disp_locale=fr : display_name=slovène #Italie, dialecte de Resia#
+disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch)#
+-----------------
+locale='sl_IT_NEDIS_ROJAZ_1901'
+disp_locale=en : display_name=Slovenian #Italy, NEDIS_ROJAZ_1901#
+disp_locale=fr : display_name=slovène #Italie, NEDIS_ROJAZ_1901#
+disp_locale=de : display_name=Slowenisch #Italien, NEDIS_ROJAZ_1901#
+-----------------
+locale='i-enochian'
+disp_locale=en : display_name=i-enochian #Private-Use=i-enochian#
+disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian#
+disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian#
+-----------------
+locale='zh-hakka'
+disp_locale=en : display_name=Chinese( #HAKKA#)?
+disp_locale=fr : display_name=chinois( #HAKKA#)?
+disp_locale=de : display_name=Chinesisch( #HAKKA#)?
+-----------------
+locale='zh-wuu'
+disp_locale=en : display_name=Chinese #WUU#
+disp_locale=fr : display_name=chinois #WUU#
+disp_locale=de : display_name=Chinesisch #WUU#
+-----------------
+locale='i-tay'
+disp_locale=en : display_name=i-tay
+disp_locale=fr : display_name=i-tay
+disp_locale=de : display_name=i-tay
+-----------------
+locale='sgn-BE-nl'
+disp_locale=en : display_name=Sign Languages? #Belgium, NL#
+disp_locale=fr : display_name=langues? des signes #Belgique, NL#
+disp_locale=de : display_name=Gebärdensprache #Belgien, NL#
+-----------------
+locale='sgn-CH-de'
+disp_locale=en : display_name=Sign Languages? #Switzerland, DE#
+disp_locale=fr : display_name=langues? des signes #Suisse, DE#
+disp_locale=de : display_name=Gebärdensprache #Schweiz, DE#
+-----------------
+locale='sl_IT_rozaj@currency=EUR'
+disp_locale=en : display_name=Slovenian #Italy, Resian, [Cc]urrency=Euro#
+disp_locale=fr : display_name=slovène #Italie, dialecte de Resia, Devise=euro#
+disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch), Währung=Euro#
+-----------------
+locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
+disp_locale=en : display_name=Ukrainian #Ukraine, CALIFORNIA, [Cc]urrency#
+disp_locale=fr : display_name=ukrainien #Ukraine, CALIFORNIA, Devise#
+disp_locale=de : display_name=Ukrainisch #Ukraine, CALIFORNIA, Währung#
+-----------------
+locale='root'
+disp_locale=en : display_name=Root
+disp_locale=fr : display_name=racine
+disp_locale=de : display_name=[Rr]oot
+-----------------
+locale='uk@currency=EURO'
+disp_locale=en : display_name=Ukrainian #[Cc]urrency=EURO#
+disp_locale=fr : display_name=ukrainien #Devise=EURO#
+disp_locale=de : display_name=Ukrainisch #Währung=EURO#
+-----------------
+locale='Hindi'
+disp_locale=en : display_name=hindi
+disp_locale=fr : display_name=hindi
+disp_locale=de : display_name=hindi
+-----------------
+locale='de'
+disp_locale=en : display_name=German
+disp_locale=fr : display_name=allemand
+disp_locale=de : display_name=Deutsch
+-----------------
+locale='fr'
+disp_locale=en : display_name=French
+disp_locale=fr : display_name=français
+disp_locale=de : display_name=Französisch
+-----------------
+locale='ja'
+disp_locale=en : display_name=Japanese
+disp_locale=fr : display_name=japonais
+disp_locale=de : display_name=Japanisch
+-----------------
+locale='i-enochian'
+disp_locale=en : display_name=i-enochian #Private-Use=i-enochian#
+disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian#
+disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian#
+-----------------
+locale='zh-Hant'
+disp_locale=en : display_name=Chinese #Traditional#
+disp_locale=fr : display_name=chinois #idéogrammes han (#variante traditionnelle#|traditionnels)#
+disp_locale=de : display_name=Chinesisch #Traditionell#
+-----------------
+locale='zh-Hans'
+disp_locale=en : display_name=Chinese #Simplified#
+disp_locale=fr : display_name=chinois #idéogrammes han (#variante simplifiée#|simplifiés)#
+disp_locale=de : display_name=Chinesisch #Vereinfacht#
+-----------------
+locale='sr-Cyrl'
+disp_locale=en : display_name=Serbian #Cyrillic#
+disp_locale=fr : display_name=serbe #cyrillique#
+disp_locale=de : display_name=Serbisch #Kyrillisch#
+-----------------
+locale='sr-Latn'
+disp_locale=en : display_name=Serbian #Latin#
+disp_locale=fr : display_name=serbe #latin#
+disp_locale=de : display_name=Serbisch #Lateinisch#
+-----------------
+locale='zh-Hans-CN'
+disp_locale=en : display_name=Chinese #Simplified, China#
+disp_locale=fr : display_name=chinois #idéogrammes han (#variante simplifiée#|simplifiés), Chine#
+disp_locale=de : display_name=Chinesisch #Vereinfacht, China#
+-----------------
+locale='sr-Latn-CS'
+disp_locale=en : display_name=Serbian #Latin, Serbia [aA]nd Montenegro#
+disp_locale=fr : display_name=serbe #latin, Serbie-et-Monténégro#
+disp_locale=de : display_name=Serbisch #Lateinisch, Serbien und Montenegro#
+-----------------
+locale='sl-rozaj'
+disp_locale=en : display_name=Slovenian #Resian#
+disp_locale=fr : display_name=slovène #dialecte de Resia#
+disp_locale=de : display_name=Slowenisch( #(ROZAJ|Resianisch)#)?
+-----------------
+locale='sl-nedis'
+disp_locale=en : display_name=Slovenian #Natisone dialect#
+disp_locale=fr : display_name=slovène #dialecte de Natisone#
+disp_locale=de : display_name=Slowenisch #Natisone-Dialekt#
+-----------------
+locale='de-CH-1901'
+disp_locale=en : display_name=German #Switzerland, Traditional German orthography#
+disp_locale=fr : display_name=allemand #Suisse, orthographe allemande traditionnelle#
+disp_locale=de : display_name=Deutsch #Schweiz, (1901|[aA]lte deutsche Rechtschreibung)#
+-----------------
+locale='sl-IT-nedis'
+disp_locale=en : display_name=Slovenian #Italy, Natisone dialect#
+disp_locale=fr : display_name=slovène #Italie, dialecte de Natisone#
+disp_locale=de : display_name=Slowenisch #Italien, (NEDIS|Natisone-Dialekt)#
+-----------------
+locale='sl-Latn-IT-nedis'
+disp_locale=en : display_name=Slovenian #Latin, Italy, Natisone dialect#
+disp_locale=fr : display_name=slovène #latin, Italie, dialecte de Natisone#
+disp_locale=de : display_name=Slowenisch #Lateinisch, Italien, (NEDIS|Natisone-Dialekt)#
+-----------------
+locale='de-DE'
+disp_locale=en : display_name=German #Germany#
+disp_locale=fr : display_name=allemand #Allemagne#
+disp_locale=de : display_name=Deutsch #Deutschland#
+-----------------
+locale='en-US'
+disp_locale=en : display_name=English #United States#
+disp_locale=fr : display_name=anglais #États-Unis#
+disp_locale=de : display_name=Englisch #Vereinigte Staaten#
+-----------------
+locale='es-419'
+disp_locale=en : display_name=Spanish #Latin America#
+disp_locale=fr : display_name=espagnol #Amérique latine#
+disp_locale=de : display_name=Spanisch #Lateinamerika#
+-----------------
+locale='de-CH-x-phonebk'
+disp_locale=en : display_name=German #Switzerland, Private-Use=phonebk#
+disp_locale=fr : display_name=allemand #Suisse, Usage privé=phonebk#
+disp_locale=de : display_name=Deutsch #Schweiz, Privatnutzung=phonebk#
+-----------------
+locale='az-Arab-x-AZE-derbend'
+disp_locale=en : display_name=Azerbaijani #Arabic, Private-Use=aze-derbend#
+disp_locale=fr : display_name=azéri #arabe, Usage privé=aze-derbend#
+disp_locale=de : display_name=Aserbaidschanisch #Arabisch, Privatnutzung=aze-derbend#
+-----------------
+locale='zh-min'
+disp_locale=en : display_name=Chinese #MIN#
+disp_locale=fr : display_name=chinois #MIN#
+disp_locale=de : display_name=Chinesisch #MIN#
+-----------------
+locale='zh-min-nan-Hant-CN'
+disp_locale=en : display_name=Chinese #MIN, NAN_HANT_CN#
+disp_locale=fr : display_name=chinois #MIN, NAN_HANT_CN#
+disp_locale=de : display_name=Chinesisch #MIN, NAN_HANT_CN#
+-----------------
+locale='x-whatever'
+disp_locale=en : display_name=x-whatever #Private-Use=whatever#
+disp_locale=fr : display_name=x-whatever #Usage privé=whatever#
+disp_locale=de : display_name=x-whatever #Privatnutzung=whatever#
+-----------------
+locale='qaa-Qaaa-QM-x-southern'
+disp_locale=en : display_name=qaa #Qaaa, QM, Private-Use=southern#
+disp_locale=fr : display_name=qaa #Qaaa, QM, Usage privé=southern#
+disp_locale=de : display_name=qaa #Qaaa, QM, Privatnutzung=southern#
+-----------------
+locale='sr-Latn-QM'
+disp_locale=en : display_name=Serbian #Latin, QM#
+disp_locale=fr : display_name=serbe #latin, QM#
+disp_locale=de : display_name=Serbisch #Lateinisch, QM#
+-----------------
+locale='sr-Qaaa-CS'
+disp_locale=en : display_name=Serbian #Qaaa, Serbia [aA]nd Montenegro#
+disp_locale=fr : display_name=serbe #Qaaa, Serbie-et-Monténégro#
+disp_locale=de : display_name=Serbisch #Qaaa, Serbien und Montenegro#
+-----------------
+locale='en-US-u-islamCal'
+disp_locale=en : display_name=English #United States, attribute=islamcal#
+disp_locale=fr : display_name=anglais #États-Unis, attribute=islamcal#
+disp_locale=de : display_name=Englisch #Vereinigte Staaten, attribute=islamcal#
+-----------------
+locale='zh-CN-a-myExt-x-private'
+disp_locale=en : display_name=Chinese #China, a=myext, Private-Use=private#
+disp_locale=fr : display_name=chinois #Chine, a=myext, Usage privé=private#
+disp_locale=de : display_name=Chinesisch #China, a=myext, Privatnutzung=private#
+-----------------
+locale='en-a-myExt-b-another'
+disp_locale=en : display_name=English #a=myext, b=another#
+disp_locale=fr : display_name=anglais #a=myext, b=another#
+disp_locale=de : display_name=Englisch #a=myext, b=another#
+-----------------
+locale='de-419-DE'
+disp_locale=en : display_name=German #Latin America, DE#
+disp_locale=fr : display_name=allemand #Amérique latine, DE#
+disp_locale=de : display_name=Deutsch #Lateinamerika, DE#
+-----------------
+locale='a-DE'
+disp_locale=en : display_name=a #Germany#
+disp_locale=fr : display_name=a #Allemagne#
+disp_locale=de : display_name=a #Deutschland#
+-----------------
+locale='ar-a-aaa-b-bbb-a-ccc'
+disp_locale=en : display_name=Arabic #a=aaa, b=bbb#
+disp_locale=fr : display_name=arabe #a=aaa, b=bbb#
+disp_locale=de : display_name=Arabisch #a=aaa, b=bbb#
+-----------------
diff --git a/ext/intl/tests/locale_get_display_region.phpt b/ext/intl/tests/locale_get_display_region.phpt
new file mode 100644
index 0000000..9a6e75d
--- /dev/null
+++ b/ext/intl/tests/locale_get_display_region.phpt
@@ -0,0 +1,275 @@
+--TEST--
+locale_get_display_region() 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
+
+/*
+ * Try getting the display_region for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $disp_locales=array('en','fr','de');
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $res_str .= "locale='$locale'\n";
+ foreach( $disp_locales as $disp_locale )
+ {
+ $scr = ut_loc_get_display_region( $locale ,$disp_locale );
+ $res_str .= "disp_locale=$disp_locale : display_region=$scr";
+ $res_str .= "\n";
+ }
+ $res_str .= "-----------------\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTREGEX--
+locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
+disp_locale=en : display_region=Ukraine
+disp_locale=fr : display_region=Ukraine
+disp_locale=de : display_region=Ukraine
+-----------------
+locale='root'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='uk@currency=EURO'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='Hindi'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='de'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='fr'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='ja'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='i-enochian'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='zh-Hant'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='zh-Hans'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='sr-Cyrl'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='sr-Latn'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='zh-Hans-CN'
+disp_locale=en : display_region=China
+disp_locale=fr : display_region=Chine
+disp_locale=de : display_region=China
+-----------------
+locale='sr-Latn-CS'
+disp_locale=en : display_region=Serbia [Aa]nd Montenegro
+disp_locale=fr : display_region=Serbie-et-Monténégro
+disp_locale=de : display_region=Serbien und Montenegro
+-----------------
+locale='sl-rozaj'
+disp_locale=en : display_region=(ROZAJ)?
+disp_locale=fr : display_region=(ROZAJ)?
+disp_locale=de : display_region=(ROZAJ)?
+-----------------
+locale='sl-nedis'
+disp_locale=en : display_region=(NEDIS)?
+disp_locale=fr : display_region=(NEDIS)?
+disp_locale=de : display_region=(NEDIS)?
+-----------------
+locale='de-CH-1901'
+disp_locale=en : display_region=Switzerland
+disp_locale=fr : display_region=Suisse
+disp_locale=de : display_region=Schweiz
+-----------------
+locale='sl-IT-nedis'
+disp_locale=en : display_region=Italy
+disp_locale=fr : display_region=Italie
+disp_locale=de : display_region=Italien
+-----------------
+locale='sl-Latn-IT-nedis'
+disp_locale=en : display_region=Italy
+disp_locale=fr : display_region=Italie
+disp_locale=de : display_region=Italien
+-----------------
+locale='de-DE'
+disp_locale=en : display_region=Germany
+disp_locale=fr : display_region=Allemagne
+disp_locale=de : display_region=Deutschland
+-----------------
+locale='en-US'
+disp_locale=en : display_region=United States
+disp_locale=fr : display_region=États-Unis
+disp_locale=de : display_region=Vereinigte Staaten
+-----------------
+locale='es-419'
+disp_locale=en : display_region=Latin America and the Caribbean
+disp_locale=fr : display_region=Amérique latine et Caraïbes
+disp_locale=de : display_region=Lateinamerika und Karibik
+-----------------
+locale='de-CH-x-phonebk'
+disp_locale=en : display_region=Switzerland
+disp_locale=fr : display_region=Suisse
+disp_locale=de : display_region=Schweiz
+-----------------
+locale='az-Arab-x-AZE-derbend'
+disp_locale=en : display_region=X?
+disp_locale=fr : display_region=X?
+disp_locale=de : display_region=X?
+-----------------
+locale='zh-min'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='zh-min-nan-Hant-CN'
+disp_locale=en : display_region=MIN
+disp_locale=fr : display_region=MIN
+disp_locale=de : display_region=MIN
+-----------------
+locale='x-whatever'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='qaa-Qaaa-QM-x-southern'
+disp_locale=en : display_region=QM
+disp_locale=fr : display_region=QM
+disp_locale=de : display_region=QM
+-----------------
+locale='sr-Latn-QM'
+disp_locale=en : display_region=QM
+disp_locale=fr : display_region=QM
+disp_locale=de : display_region=QM
+-----------------
+locale='sr-Qaaa-CS'
+disp_locale=en : display_region=Serbia [Aa]nd Montenegro
+disp_locale=fr : display_region=Serbie-et-Monténégro
+disp_locale=de : display_region=Serbien und Montenegro
+-----------------
+locale='en-US-u-islamCal'
+disp_locale=en : display_region=United States
+disp_locale=fr : display_region=États-Unis
+disp_locale=de : display_region=Vereinigte Staaten
+-----------------
+locale='zh-CN-a-myExt-x-private'
+disp_locale=en : display_region=China
+disp_locale=fr : display_region=Chine
+disp_locale=de : display_region=China
+-----------------
+locale='en-a-myExt-b-another'
+disp_locale=en : display_region=A?
+disp_locale=fr : display_region=A?
+disp_locale=de : display_region=A?
+-----------------
+locale='de-419-DE'
+disp_locale=en : display_region=Latin America and the Caribbean
+disp_locale=fr : display_region=Amérique latine et Caraïbes
+disp_locale=de : display_region=Lateinamerika und Karibik
+-----------------
+locale='a-DE'
+disp_locale=en : display_region=Germany
+disp_locale=fr : display_region=Allemagne
+disp_locale=de : display_region=Deutschland
+-----------------
+locale='ar-a-aaa-b-bbb-a-ccc'
+disp_locale=en : display_region=A?
+disp_locale=fr : display_region=A?
+disp_locale=de : display_region=A?
+-----------------
diff --git a/ext/intl/tests/locale_get_display_region2.phpt b/ext/intl/tests/locale_get_display_region2.phpt
new file mode 100644
index 0000000..f1b5841
--- /dev/null
+++ b/ext/intl/tests/locale_get_display_region2.phpt
@@ -0,0 +1,275 @@
+--TEST--
+locale_get_display_region() 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 getting the display_region for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $disp_locales=array('en','fr','de');
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $res_str .= "locale='$locale'\n";
+ foreach( $disp_locales as $disp_locale )
+ {
+ $scr = ut_loc_get_display_region( $locale ,$disp_locale );
+ $res_str .= "disp_locale=$disp_locale : display_region=$scr";
+ $res_str .= "\n";
+ }
+ $res_str .= "-----------------\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTREGEX--
+locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
+disp_locale=en : display_region=Ukraine
+disp_locale=fr : display_region=Ukraine
+disp_locale=de : display_region=Ukraine
+-----------------
+locale='root'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='uk@currency=EURO'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='Hindi'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='de'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='fr'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='ja'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='i-enochian'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='zh-Hant'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='zh-Hans'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='sr-Cyrl'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='sr-Latn'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='zh-Hans-CN'
+disp_locale=en : display_region=China
+disp_locale=fr : display_region=Chine
+disp_locale=de : display_region=China
+-----------------
+locale='sr-Latn-CS'
+disp_locale=en : display_region=Serbia [Aa]nd Montenegro
+disp_locale=fr : display_region=Serbie-et-Monténégro
+disp_locale=de : display_region=Serbien und Montenegro
+-----------------
+locale='sl-rozaj'
+disp_locale=en : display_region=(ROZAJ)?
+disp_locale=fr : display_region=(ROZAJ)?
+disp_locale=de : display_region=(ROZAJ)?
+-----------------
+locale='sl-nedis'
+disp_locale=en : display_region=(NEDIS)?
+disp_locale=fr : display_region=(NEDIS)?
+disp_locale=de : display_region=(NEDIS)?
+-----------------
+locale='de-CH-1901'
+disp_locale=en : display_region=Switzerland
+disp_locale=fr : display_region=Suisse
+disp_locale=de : display_region=Schweiz
+-----------------
+locale='sl-IT-nedis'
+disp_locale=en : display_region=Italy
+disp_locale=fr : display_region=Italie
+disp_locale=de : display_region=Italien
+-----------------
+locale='sl-Latn-IT-nedis'
+disp_locale=en : display_region=Italy
+disp_locale=fr : display_region=Italie
+disp_locale=de : display_region=Italien
+-----------------
+locale='de-DE'
+disp_locale=en : display_region=Germany
+disp_locale=fr : display_region=Allemagne
+disp_locale=de : display_region=Deutschland
+-----------------
+locale='en-US'
+disp_locale=en : display_region=United States
+disp_locale=fr : display_region=États-Unis
+disp_locale=de : display_region=Vereinigte Staaten
+-----------------
+locale='es-419'
+disp_locale=en : display_region=Latin America
+disp_locale=fr : display_region=Amérique latine
+disp_locale=de : display_region=Lateinamerika
+-----------------
+locale='de-CH-x-phonebk'
+disp_locale=en : display_region=Switzerland
+disp_locale=fr : display_region=Suisse
+disp_locale=de : display_region=Schweiz
+-----------------
+locale='az-Arab-x-AZE-derbend'
+disp_locale=en : display_region=X?
+disp_locale=fr : display_region=X?
+disp_locale=de : display_region=X?
+-----------------
+locale='zh-min'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='zh-min-nan-Hant-CN'
+disp_locale=en : display_region=MIN
+disp_locale=fr : display_region=MIN
+disp_locale=de : display_region=MIN
+-----------------
+locale='x-whatever'
+disp_locale=en : display_region=
+disp_locale=fr : display_region=
+disp_locale=de : display_region=
+-----------------
+locale='qaa-Qaaa-QM-x-southern'
+disp_locale=en : display_region=QM
+disp_locale=fr : display_region=QM
+disp_locale=de : display_region=QM
+-----------------
+locale='sr-Latn-QM'
+disp_locale=en : display_region=QM
+disp_locale=fr : display_region=QM
+disp_locale=de : display_region=QM
+-----------------
+locale='sr-Qaaa-CS'
+disp_locale=en : display_region=Serbia [Aa]nd Montenegro
+disp_locale=fr : display_region=Serbie-et-Monténégro
+disp_locale=de : display_region=Serbien und Montenegro
+-----------------
+locale='en-US-u-islamCal'
+disp_locale=en : display_region=United States
+disp_locale=fr : display_region=États-Unis
+disp_locale=de : display_region=Vereinigte Staaten
+-----------------
+locale='zh-CN-a-myExt-x-private'
+disp_locale=en : display_region=China
+disp_locale=fr : display_region=Chine
+disp_locale=de : display_region=China
+-----------------
+locale='en-a-myExt-b-another'
+disp_locale=en : display_region=A?
+disp_locale=fr : display_region=A?
+disp_locale=de : display_region=A?
+-----------------
+locale='de-419-DE'
+disp_locale=en : display_region=Latin America
+disp_locale=fr : display_region=Amérique latine
+disp_locale=de : display_region=Lateinamerika
+-----------------
+locale='a-DE'
+disp_locale=en : display_region=Germany
+disp_locale=fr : display_region=Allemagne
+disp_locale=de : display_region=Deutschland
+-----------------
+locale='ar-a-aaa-b-bbb-a-ccc'
+disp_locale=en : display_region=A?
+disp_locale=fr : display_region=A?
+disp_locale=de : display_region=A?
+-----------------
diff --git a/ext/intl/tests/locale_get_display_script.phpt b/ext/intl/tests/locale_get_display_script.phpt
new file mode 100644
index 0000000..0440dfb
--- /dev/null
+++ b/ext/intl/tests/locale_get_display_script.phpt
@@ -0,0 +1,275 @@
+--TEST--
+locale_get_display_script() 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
+
+/*
+ * Try getting the display_script for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $disp_locales=array('en','fr','de');
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $res_str .= "locale='$locale'\n";
+ foreach( $disp_locales as $disp_locale )
+ {
+ $scr = ut_loc_get_display_script( $locale ,$disp_locale );
+ $res_str .= "disp_locale=$disp_locale : display_script=$scr";
+ $res_str .= "\n";
+ }
+ $res_str .= "-----------------\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTREGEX--
+locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='root'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='uk@currency=EURO'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='Hindi'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='fr'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='ja'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='i-enochian'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='zh-Hant'
+disp_locale=en : display_script=Traditional Han
+disp_locale=fr : display_script=idéogrammes han (\(variante traditionnelle\)|traditionnels)
+disp_locale=de : display_script=Traditionelle Chinesische Schrift
+-----------------
+locale='zh-Hans'
+disp_locale=en : display_script=Simplified Han
+disp_locale=fr : display_script=idéogrammes han (\(variante simplifiée\)|simplifiés)
+disp_locale=de : display_script=Vereinfachte Chinesische Schrift
+-----------------
+locale='sr-Cyrl'
+disp_locale=en : display_script=Cyrillic
+disp_locale=fr : display_script=cyrillique
+disp_locale=de : display_script=Kyrillisch
+-----------------
+locale='sr-Latn'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='zh-Hans-CN'
+disp_locale=en : display_script=Simplified Han
+disp_locale=fr : display_script=idéogrammes han (\(variante simplifiée\)|simplifiés)
+disp_locale=de : display_script=Vereinfachte Chinesische Schrift
+-----------------
+locale='sr-Latn-CS'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='sl-rozaj'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='sl-nedis'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de-CH-1901'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='sl-IT-nedis'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='sl-Latn-IT-nedis'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='de-DE'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='en-US'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='es-419'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de-CH-x-phonebk'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='az-Arab-x-AZE-derbend'
+disp_locale=en : display_script=Arabic
+disp_locale=fr : display_script=arabe
+disp_locale=de : display_script=Arabisch
+-----------------
+locale='zh-min'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='zh-min-nan-Hant-CN'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='x-whatever'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='qaa-Qaaa-QM-x-southern'
+disp_locale=en : display_script=Qaaa
+disp_locale=fr : display_script=Qaaa
+disp_locale=de : display_script=Qaaa
+-----------------
+locale='sr-Latn-QM'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='sr-Qaaa-CS'
+disp_locale=en : display_script=Qaaa
+disp_locale=fr : display_script=Qaaa
+disp_locale=de : display_script=Qaaa
+-----------------
+locale='en-US-u-islamCal'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='zh-CN-a-myExt-x-private'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='en-a-myExt-b-another'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de-419-DE'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='a-DE'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='ar-a-aaa-b-bbb-a-ccc'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
diff --git a/ext/intl/tests/locale_get_display_script2.phpt b/ext/intl/tests/locale_get_display_script2.phpt
new file mode 100644
index 0000000..2b9e037
--- /dev/null
+++ b/ext/intl/tests/locale_get_display_script2.phpt
@@ -0,0 +1,275 @@
+--TEST--
+locale_get_display_script() icu = 4.8
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0 || version_compare(INTL_ICU_VERSION, '49') >= 0) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try getting the display_script for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $disp_locales=array('en','fr','de');
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $res_str .= "locale='$locale'\n";
+ foreach( $disp_locales as $disp_locale )
+ {
+ $scr = ut_loc_get_display_script( $locale ,$disp_locale );
+ $res_str .= "disp_locale=$disp_locale : display_script=$scr";
+ $res_str .= "\n";
+ }
+ $res_str .= "-----------------\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTREGEX--
+locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='root'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='uk@currency=EURO'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='Hindi'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='fr'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='ja'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='i-enochian'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='zh-Hant'
+disp_locale=en : display_script=Traditional
+disp_locale=fr : display_script=idéogrammes han (\(variante traditionnelle\)|traditionnels)
+disp_locale=de : display_script=Traditionell
+-----------------
+locale='zh-Hans'
+disp_locale=en : display_script=Simplified
+disp_locale=fr : display_script=idéogrammes han (\(variante simplifiée\)|simplifiés)
+disp_locale=de : display_script=Vereinfacht
+-----------------
+locale='sr-Cyrl'
+disp_locale=en : display_script=Cyrillic
+disp_locale=fr : display_script=cyrillique
+disp_locale=de : display_script=Kyrillisch
+-----------------
+locale='sr-Latn'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='zh-Hans-CN'
+disp_locale=en : display_script=Simplified
+disp_locale=fr : display_script=idéogrammes han (\(variante simplifiée\)|simplifiés)
+disp_locale=de : display_script=Vereinfacht
+-----------------
+locale='sr-Latn-CS'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='sl-rozaj'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='sl-nedis'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de-CH-1901'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='sl-IT-nedis'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='sl-Latn-IT-nedis'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='de-DE'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='en-US'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='es-419'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de-CH-x-phonebk'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='az-Arab-x-AZE-derbend'
+disp_locale=en : display_script=Arabic
+disp_locale=fr : display_script=arabe
+disp_locale=de : display_script=Arabisch
+-----------------
+locale='zh-min'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='zh-min-nan-Hant-CN'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='x-whatever'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='qaa-Qaaa-QM-x-southern'
+disp_locale=en : display_script=Qaaa
+disp_locale=fr : display_script=Qaaa
+disp_locale=de : display_script=Qaaa
+-----------------
+locale='sr-Latn-QM'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='sr-Qaaa-CS'
+disp_locale=en : display_script=Qaaa
+disp_locale=fr : display_script=Qaaa
+disp_locale=de : display_script=Qaaa
+-----------------
+locale='en-US-u-islamCal'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='zh-CN-a-myExt-x-private'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='en-a-myExt-b-another'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de-419-DE'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='a-DE'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='ar-a-aaa-b-bbb-a-ccc'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
diff --git a/ext/intl/tests/locale_get_display_script3.phpt b/ext/intl/tests/locale_get_display_script3.phpt
new file mode 100644
index 0000000..447766e
--- /dev/null
+++ b/ext/intl/tests/locale_get_display_script3.phpt
@@ -0,0 +1,275 @@
+--TEST--
+locale_get_display_script() icu >= 49
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if(version_compare(INTL_ICU_VERSION, '49') < 0) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try getting the display_script for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $disp_locales=array('en','fr','de');
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $res_str .= "locale='$locale'\n";
+ foreach( $disp_locales as $disp_locale )
+ {
+ $scr = ut_loc_get_display_script( $locale ,$disp_locale );
+ $res_str .= "disp_locale=$disp_locale : display_script=$scr";
+ $res_str .= "\n";
+ }
+ $res_str .= "-----------------\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='root'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='uk@currency=EURO'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='Hindi'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='fr'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='ja'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='i-enochian'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='zh-Hant'
+disp_locale=en : display_script=Traditional Han
+disp_locale=fr : display_script=chinois traditionnel
+disp_locale=de : display_script=Traditionelles Chinesisch
+-----------------
+locale='zh-Hans'
+disp_locale=en : display_script=Simplified Han
+disp_locale=fr : display_script=chinois simplifié
+disp_locale=de : display_script=Vereinfachtes Chinesisch
+-----------------
+locale='sr-Cyrl'
+disp_locale=en : display_script=Cyrillic
+disp_locale=fr : display_script=cyrillique
+disp_locale=de : display_script=Kyrillisch
+-----------------
+locale='sr-Latn'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='zh-Hans-CN'
+disp_locale=en : display_script=Simplified Han
+disp_locale=fr : display_script=chinois simplifié
+disp_locale=de : display_script=Vereinfachtes Chinesisch
+-----------------
+locale='sr-Latn-CS'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='sl-rozaj'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='sl-nedis'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de-CH-1901'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='sl-IT-nedis'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='sl-Latn-IT-nedis'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='de-DE'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='en-US'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='es-419'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de-CH-x-phonebk'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='az-Arab-x-AZE-derbend'
+disp_locale=en : display_script=Arabic
+disp_locale=fr : display_script=arabe
+disp_locale=de : display_script=Arabisch
+-----------------
+locale='zh-min'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='zh-min-nan-Hant-CN'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='x-whatever'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='qaa-Qaaa-QM-x-southern'
+disp_locale=en : display_script=Qaaa
+disp_locale=fr : display_script=Qaaa
+disp_locale=de : display_script=Qaaa
+-----------------
+locale='sr-Latn-QM'
+disp_locale=en : display_script=Latin
+disp_locale=fr : display_script=latin
+disp_locale=de : display_script=Lateinisch
+-----------------
+locale='sr-Qaaa-CS'
+disp_locale=en : display_script=Qaaa
+disp_locale=fr : display_script=Qaaa
+disp_locale=de : display_script=Qaaa
+-----------------
+locale='en-US-u-islamCal'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='zh-CN-a-myExt-x-private'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='en-a-myExt-b-another'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='de-419-DE'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='a-DE'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
+locale='ar-a-aaa-b-bbb-a-ccc'
+disp_locale=en : display_script=
+disp_locale=fr : display_script=
+disp_locale=de : display_script=
+-----------------
diff --git a/ext/intl/tests/locale_get_display_variant.phpt b/ext/intl/tests/locale_get_display_variant.phpt
new file mode 100644
index 0000000..9f72ee0
--- /dev/null
+++ b/ext/intl/tests/locale_get_display_variant.phpt
@@ -0,0 +1,275 @@
+--TEST--
+locale_get_display_variant() 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
+
+/*
+ * Try getting the display_variant for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $disp_locales=array('en','fr','de');
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $res_str .= "locale='$locale'\n";
+ foreach( $disp_locales as $disp_locale )
+ {
+ $scr = ut_loc_get_display_variant( $locale ,$disp_locale );
+ $res_str .= "disp_locale=$disp_locale : display_variant=$scr";
+ $res_str .= "\n";
+ }
+ $res_str .= "-----------------\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTREGEX--
+locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
+disp_locale=en : display_variant=CALIFORNIA
+disp_locale=fr : display_variant=CALIFORNIA
+disp_locale=de : display_variant=CALIFORNIA
+-----------------
+locale='root'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='uk@currency=EURO'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='Hindi'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='de'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='fr'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='ja'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='i-enochian'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='zh-Hant'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='zh-Hans'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sr-Cyrl'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sr-Latn'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='zh-Hans-CN'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sr-Latn-CS'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sl-rozaj'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sl-nedis'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='de-CH-1901'
+disp_locale=en : display_variant=Traditional German orthography
+disp_locale=fr : display_variant=orthographe allemande traditionnelle
+disp_locale=de : display_variant=(1901|[Aa]lte deutsche Rechtschreibung)
+-----------------
+locale='sl-IT-nedis'
+disp_locale=en : display_variant=Natisone dialect
+disp_locale=fr : display_variant=dialecte de Natisone
+disp_locale=de : display_variant=(NEDIS|Natisone-Dialekt)
+-----------------
+locale='sl-Latn-IT-nedis'
+disp_locale=en : display_variant=Natisone dialect
+disp_locale=fr : display_variant=dialecte de Natisone
+disp_locale=de : display_variant=(NEDIS|Natisone-Dialekt)
+-----------------
+locale='de-DE'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='en-US'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='es-419'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='de-CH-x-phonebk'
+disp_locale=en : display_variant=X_PHONEBK
+disp_locale=fr : display_variant=X_PHONEBK
+disp_locale=de : display_variant=X_PHONEBK
+-----------------
+locale='az-Arab-x-AZE-derbend'
+disp_locale=en : display_variant=(AZE_DERBEND)?
+disp_locale=fr : display_variant=(AZE_DERBEND)?
+disp_locale=de : display_variant=(AZE_DERBEND)?
+-----------------
+locale='zh-min'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='zh-min-nan-Hant-CN'
+disp_locale=en : display_variant=NAN_HANT_CN
+disp_locale=fr : display_variant=NAN_HANT_CN
+disp_locale=de : display_variant=NAN_HANT_CN
+-----------------
+locale='x-whatever'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='qaa-Qaaa-QM-x-southern'
+disp_locale=en : display_variant=X_SOUTHERN
+disp_locale=fr : display_variant=X_SOUTHERN
+disp_locale=de : display_variant=X_SOUTHERN
+-----------------
+locale='sr-Latn-QM'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sr-Qaaa-CS'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='en-US-u-islamCal'
+disp_locale=en : display_variant=U_ISLAMCAL
+disp_locale=fr : display_variant=U_ISLAMCAL
+disp_locale=de : display_variant=U_ISLAMCAL
+-----------------
+locale='zh-CN-a-myExt-x-private'
+disp_locale=en : display_variant=A_MYEXT_X_PRIVATE
+disp_locale=fr : display_variant=A_MYEXT_X_PRIVATE
+disp_locale=de : display_variant=A_MYEXT_X_PRIVATE
+-----------------
+locale='en-a-myExt-b-another'
+disp_locale=en : display_variant=(MYEXT_B_ANOTHER)?
+disp_locale=fr : display_variant=(MYEXT_B_ANOTHER)?
+disp_locale=de : display_variant=(MYEXT_B_ANOTHER)?
+-----------------
+locale='de-419-DE'
+disp_locale=en : display_variant=DE
+disp_locale=fr : display_variant=DE
+disp_locale=de : display_variant=DE
+-----------------
+locale='a-DE'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='ar-a-aaa-b-bbb-a-ccc'
+disp_locale=en : display_variant=(AAA_B_BBB_A_CCC)?
+disp_locale=fr : display_variant=(AAA_B_BBB_A_CCC)?
+disp_locale=de : display_variant=(AAA_B_BBB_A_CCC)?
+-----------------
diff --git a/ext/intl/tests/locale_get_display_variant2.phpt b/ext/intl/tests/locale_get_display_variant2.phpt
new file mode 100644
index 0000000..2517240
--- /dev/null
+++ b/ext/intl/tests/locale_get_display_variant2.phpt
@@ -0,0 +1,275 @@
+--TEST--
+locale_get_display_variant() 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 getting the display_variant for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $disp_locales=array('en','fr','de');
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $res_str .= "locale='$locale'\n";
+ foreach( $disp_locales as $disp_locale )
+ {
+ $scr = ut_loc_get_display_variant( $locale ,$disp_locale );
+ $res_str .= "disp_locale=$disp_locale : display_variant=$scr";
+ $res_str .= "\n";
+ }
+ $res_str .= "-----------------\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTREGEX--
+locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
+disp_locale=en : display_variant=CALIFORNIA
+disp_locale=fr : display_variant=CALIFORNIA
+disp_locale=de : display_variant=CALIFORNIA
+-----------------
+locale='root'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='uk@currency=EURO'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='Hindi'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='de'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='fr'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='ja'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='i-enochian'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='zh-Hant'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='zh-Hans'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sr-Cyrl'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sr-Latn'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='zh-Hans-CN'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sr-Latn-CS'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sl-rozaj'
+disp_locale=en : display_variant=Resian
+disp_locale=fr : display_variant=dialecte de Resia
+disp_locale=de : display_variant=Resianisch
+-----------------
+locale='sl-nedis'
+disp_locale=en : display_variant=Natisone dialect
+disp_locale=fr : display_variant=dialecte de Natisone
+disp_locale=de : display_variant=Natisone-Dialekt
+-----------------
+locale='de-CH-1901'
+disp_locale=en : display_variant=Traditional German orthography
+disp_locale=fr : display_variant=orthographe allemande traditionnelle
+disp_locale=de : display_variant=(1901|[Aa]lte deutsche Rechtschreibung)
+-----------------
+locale='sl-IT-nedis'
+disp_locale=en : display_variant=Natisone dialect
+disp_locale=fr : display_variant=dialecte de Natisone
+disp_locale=de : display_variant=(NEDIS|Natisone-Dialekt)
+-----------------
+locale='sl-Latn-IT-nedis'
+disp_locale=en : display_variant=Natisone dialect
+disp_locale=fr : display_variant=dialecte de Natisone
+disp_locale=de : display_variant=(NEDIS|Natisone-Dialekt)
+-----------------
+locale='de-DE'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='en-US'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='es-419'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='de-CH-x-phonebk'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='az-Arab-x-AZE-derbend'
+disp_locale=en : display_variant=(AZE_DERBEND)?
+disp_locale=fr : display_variant=(AZE_DERBEND)?
+disp_locale=de : display_variant=(AZE_DERBEND)?
+-----------------
+locale='zh-min'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='zh-min-nan-Hant-CN'
+disp_locale=en : display_variant=NAN_HANT_CN
+disp_locale=fr : display_variant=NAN_HANT_CN
+disp_locale=de : display_variant=NAN_HANT_CN
+-----------------
+locale='x-whatever'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='qaa-Qaaa-QM-x-southern'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sr-Latn-QM'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='sr-Qaaa-CS'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='en-US-u-islamCal'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='zh-CN-a-myExt-x-private'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='en-a-myExt-b-another'
+disp_locale=en : display_variant=(MYEXT_B_ANOTHER)?
+disp_locale=fr : display_variant=(MYEXT_B_ANOTHER)?
+disp_locale=de : display_variant=(MYEXT_B_ANOTHER)?
+-----------------
+locale='de-419-DE'
+disp_locale=en : display_variant=DE
+disp_locale=fr : display_variant=DE
+disp_locale=de : display_variant=DE
+-----------------
+locale='a-DE'
+disp_locale=en : display_variant=
+disp_locale=fr : display_variant=
+disp_locale=de : display_variant=
+-----------------
+locale='ar-a-aaa-b-bbb-a-ccc'
+disp_locale=en : display_variant=(AAA_B_BBB_A_CCC)?
+disp_locale=fr : display_variant=(AAA_B_BBB_A_CCC)?
+disp_locale=de : display_variant=(AAA_B_BBB_A_CCC)?
+-----------------
diff --git a/ext/intl/tests/locale_get_keywords.phpt b/ext/intl/tests/locale_get_keywords.phpt
new file mode 100644
index 0000000..4a09f54
--- /dev/null
+++ b/ext/intl/tests/locale_get_keywords.phpt
@@ -0,0 +1,140 @@
+--TEST--
+locale_get_keywords() 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
+
+/*
+ * Try getting the keywords for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $locales = array(
+ "de_DE@currency=EUR;collation=PHONEBOOK",
+ 'uk-ua_CALIFORNIA@currency=GRN'
+ );
+
+ $locales = array(
+ 'de_DE@currency=EUR;collation=PHONEBOOK',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $keywords_arr = ut_loc_get_keywords( $locale);
+ $res_str .= "$locale: ";
+ if( $keywords_arr){
+ foreach( $keywords_arr as $key => $value){
+ $res_str .= "Key is $key and Value is $value \n";
+ }
+ }
+ else{
+ $res_str .= "No keywords found.";
+ }
+ $res_str .= "\n";
+ }
+
+ $res_str .= "\n";
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+de_DE@currency=EUR;collation=PHONEBOOK: Key is collation and Value is PHONEBOOK
+Key is currency and Value is EUR
+
+root: No keywords found.
+uk@currency=EURO: Key is currency and Value is EURO
+
+Hindi: No keywords found.
+de: No keywords found.
+fr: No keywords found.
+ja: No keywords found.
+i-enochian: No keywords found.
+zh-Hant: No keywords found.
+zh-Hans: No keywords found.
+sr-Cyrl: No keywords found.
+sr-Latn: No keywords found.
+zh-Hans-CN: No keywords found.
+sr-Latn-CS: No keywords found.
+sl-rozaj: No keywords found.
+sl-nedis: No keywords found.
+de-CH-1901: No keywords found.
+sl-IT-nedis: No keywords found.
+sl-Latn-IT-nedis: No keywords found.
+de-DE: No keywords found.
+en-US: No keywords found.
+es-419: No keywords found.
+de-CH-x-phonebk: No keywords found.
+az-Arab-x-AZE-derbend: No keywords found.
+zh-min: No keywords found.
+zh-min-nan-Hant-CN: No keywords found.
+x-whatever: No keywords found.
+qaa-Qaaa-QM-x-southern: No keywords found.
+sr-Latn-QM: No keywords found.
+sr-Qaaa-CS: No keywords found.
+en-US-u-islamCal: No keywords found.
+zh-CN-a-myExt-x-private: No keywords found.
+en-a-myExt-b-another: No keywords found.
+de-419-DE: No keywords found.
+a-DE: No keywords found.
+ar-a-aaa-b-bbb-a-ccc: No keywords found.
diff --git a/ext/intl/tests/locale_get_keywords2.phpt b/ext/intl/tests/locale_get_keywords2.phpt
new file mode 100644
index 0000000..7bcaca1
--- /dev/null
+++ b/ext/intl/tests/locale_get_keywords2.phpt
@@ -0,0 +1,151 @@
+--TEST--
+locale_get_keywords() 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 getting the keywords for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $locales = array(
+ "de_DE@currency=EUR;collation=PHONEBOOK",
+ 'uk-ua_CALIFORNIA@currency=GRN'
+ );
+
+ $locales = array(
+ 'de_DE@currency=EUR;collation=PHONEBOOK',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $keywords_arr = ut_loc_get_keywords( $locale);
+ $res_str .= "$locale: ";
+ if( $keywords_arr){
+ foreach( $keywords_arr as $key => $value){
+ $res_str .= "Key is $key and Value is $value \n";
+ }
+ }
+ else{
+ $res_str .= "No keywords found.";
+ }
+ $res_str .= "\n";
+ }
+
+ $res_str .= "\n";
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+de_DE@currency=EUR;collation=PHONEBOOK: Key is collation and Value is PHONEBOOK
+Key is currency and Value is EUR
+
+root: No keywords found.
+uk@currency=EURO: Key is currency and Value is EURO
+
+Hindi: No keywords found.
+de: No keywords found.
+fr: No keywords found.
+ja: No keywords found.
+i-enochian: Key is x and Value is i-enochian
+
+zh-Hant: No keywords found.
+zh-Hans: No keywords found.
+sr-Cyrl: No keywords found.
+sr-Latn: No keywords found.
+zh-Hans-CN: No keywords found.
+sr-Latn-CS: No keywords found.
+sl-rozaj: No keywords found.
+sl-nedis: No keywords found.
+de-CH-1901: No keywords found.
+sl-IT-nedis: No keywords found.
+sl-Latn-IT-nedis: No keywords found.
+de-DE: No keywords found.
+en-US: No keywords found.
+es-419: No keywords found.
+de-CH-x-phonebk: Key is x and Value is phonebk
+
+az-Arab-x-AZE-derbend: Key is x and Value is aze-derbend
+
+zh-min: No keywords found.
+zh-min-nan-Hant-CN: No keywords found.
+x-whatever: Key is x and Value is whatever
+
+qaa-Qaaa-QM-x-southern: Key is x and Value is southern
+
+sr-Latn-QM: No keywords found.
+sr-Qaaa-CS: No keywords found.
+en-US-u-islamCal: Key is attribute and Value is islamcal
+
+zh-CN-a-myExt-x-private: Key is a and Value is myext
+Key is x and Value is private
+
+en-a-myExt-b-another: Key is a and Value is myext
+Key is b and Value is another
+
+de-419-DE: No keywords found.
+a-DE: No keywords found.
+ar-a-aaa-b-bbb-a-ccc: Key is a and Value is aaa
+Key is b and Value is bbb
diff --git a/ext/intl/tests/locale_get_primary_language.phpt b/ext/intl/tests/locale_get_primary_language.phpt
new file mode 100644
index 0000000..bc92e92
--- /dev/null
+++ b/ext/intl/tests/locale_get_primary_language.phpt
@@ -0,0 +1,121 @@
+--TEST--
+locale_get_primary_language()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try getting the prmary language for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $lang = ut_loc_get_primary_language( $locale);
+ $res_str .= "$locale: primary_language='$lang'";
+ $res_str .= "\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+uk-ua_CALIFORNIA@currency=;currency=GRN: primary_language='uk'
+root: primary_language='root'
+uk@currency=EURO: primary_language='uk'
+Hindi: primary_language='hindi'
+de: primary_language='de'
+fr: primary_language='fr'
+ja: primary_language='ja'
+i-enochian: primary_language='i-enochian'
+zh-Hant: primary_language='zh'
+zh-Hans: primary_language='zh'
+sr-Cyrl: primary_language='sr'
+sr-Latn: primary_language='sr'
+zh-Hans-CN: primary_language='zh'
+sr-Latn-CS: primary_language='sr'
+sl-rozaj: primary_language='sl'
+sl-nedis: primary_language='sl'
+de-CH-1901: primary_language='de'
+sl-IT-nedis: primary_language='sl'
+sl-Latn-IT-nedis: primary_language='sl'
+de-DE: primary_language='de'
+en-US: primary_language='en'
+es-419: primary_language='es'
+de-CH-x-phonebk: primary_language='de'
+az-Arab-x-AZE-derbend: primary_language='az'
+zh-min: primary_language='zh-min'
+zh-min-nan-Hant-CN: primary_language='zh'
+qaa-Qaaa-QM-x-southern: primary_language='qaa'
+sr-Latn-QM: primary_language='sr'
+sr-Qaaa-CS: primary_language='sr'
+en-US-u-islamCal: primary_language='en'
+zh-CN-a-myExt-x-private: primary_language='zh'
+en-a-myExt-b-another: primary_language='en'
+de-419-DE: primary_language='de'
+a-DE: primary_language='a'
+ar-a-aaa-b-bbb-a-ccc: primary_language='ar'
diff --git a/ext/intl/tests/locale_get_region.phpt b/ext/intl/tests/locale_get_region.phpt
new file mode 100644
index 0000000..0baae49
--- /dev/null
+++ b/ext/intl/tests/locale_get_region.phpt
@@ -0,0 +1,123 @@
+--TEST--
+locale_get_region()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try getting the region for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $scr = ut_loc_get_region( $locale);
+ $res_str .= "$locale: region='$scr'";
+ $res_str .= "\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTF--
+uk-ua_CALIFORNIA@currency=;currency=GRN: region='UA'
+root: region=''
+uk@currency=EURO: region=''
+Hindi: region=''
+de: region=''
+fr: region=''
+ja: region=''
+i-enochian: region=''
+zh-Hant: region=''
+zh-Hans: region=''
+sr-Cyrl: region=''
+sr-Latn: region=''
+zh-Hans-CN: region='CN'
+sr-Latn-CS: region='CS'
+sl-rozaj: region='%r(ROZAJ)?%r'
+sl-nedis: region='%r(NEDIS)?%r'
+de-CH-1901: region='CH'
+sl-IT-nedis: region='IT'
+sl-Latn-IT-nedis: region='IT'
+de-DE: region='DE'
+en-US: region='US'
+es-419: region='419'
+de-CH-x-phonebk: region='CH'
+az-Arab-x-AZE-derbend: region='%r(X)?%r'
+zh-min: region=''
+zh-min-nan-Hant-CN: region='MIN'
+x-whatever: region=''
+qaa-Qaaa-QM-x-southern: region='QM'
+sr-Latn-QM: region='QM'
+sr-Qaaa-CS: region='CS'
+en-US-u-islamCal: region='US'
+zh-CN-a-myExt-x-private: region='CN'
+en-a-myExt-b-another: region='%r(A)?%r'
+de-419-DE: region='419'
+a-DE: region='DE'
+ar-a-aaa-b-bbb-a-ccc: region='%r(A)?%r'
diff --git a/ext/intl/tests/locale_get_script.phpt b/ext/intl/tests/locale_get_script.phpt
new file mode 100644
index 0000000..6a794fd
--- /dev/null
+++ b/ext/intl/tests/locale_get_script.phpt
@@ -0,0 +1,122 @@
+--TEST--
+locale_get_script()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try getting the prmary language for different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $scr = ut_loc_get_script( $locale);
+ $res_str .= "$locale: script='$scr'";
+ $res_str .= "\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+uk-ua_CALIFORNIA@currency=;currency=GRN: script=''
+root: script=''
+uk@currency=EURO: script=''
+Hindi: script=''
+de: script=''
+fr: script=''
+ja: script=''
+i-enochian: script=''
+zh-Hant: script='Hant'
+zh-Hans: script='Hans'
+sr-Cyrl: script='Cyrl'
+sr-Latn: script='Latn'
+zh-Hans-CN: script='Hans'
+sr-Latn-CS: script='Latn'
+sl-rozaj: script=''
+sl-nedis: script=''
+de-CH-1901: script=''
+sl-IT-nedis: script=''
+sl-Latn-IT-nedis: script='Latn'
+de-DE: script=''
+en-US: script=''
+es-419: script=''
+de-CH-x-phonebk: script=''
+az-Arab-x-AZE-derbend: script='Arab'
+zh-min: script=''
+zh-min-nan-Hant-CN: script=''
+x-whatever: script=''
+qaa-Qaaa-QM-x-southern: script='Qaaa'
+sr-Latn-QM: script='Latn'
+sr-Qaaa-CS: script='Qaaa'
+en-US-u-islamCal: script=''
+zh-CN-a-myExt-x-private: script=''
+en-a-myExt-b-another: script=''
+de-419-DE: script=''
+a-DE: script=''
+ar-a-aaa-b-bbb-a-ccc: script=''
+
diff --git a/ext/intl/tests/locale_lookup.phpt b/ext/intl/tests/locale_lookup.phpt
new file mode 100644
index 0000000..f0affaf
--- /dev/null
+++ b/ext/intl/tests/locale_lookup.phpt
@@ -0,0 +1,99 @@
+--TEST--
+locale_lookup.phpt()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try parsing different Locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $loc_ranges = array(
+ 'de-de',
+ 'sl_IT',
+ 'sl_IT_Nedis',
+ 'jbo',
+ 'art-lojban'
+ );
+
+ $lang_tags = array(
+ 'de-DEVA',
+ 'de-DE-1996',
+ 'de-DE',
+ 'zh_Hans',
+ 'de-CH-1996',
+ 'sl_IT',
+ 'sl_IT_nedis-a-kirti-x-xyz',
+ 'sl_IT_rozaj',
+ 'sl_IT_NEDIS_ROJAZ_1901',
+ 'i-enochian',
+ 'sgn-CH-de',
+ 'art-lojban',
+ 'i-lux',
+ 'art-lojban',
+ 'jbo',
+ 'en_sl_IT',
+ 'zh-Hant-CN-x-prv1-prv2'
+ );
+
+
+ $res_str = '';
+ $isCanonical = false;
+
+ foreach($loc_ranges as $loc_range){
+ $res_str .="--------------\n";
+ $result= ut_loc_locale_lookup( $lang_tags , $loc_range,$isCanonical,"en_US");
+ $comma_arr =implode(",",$lang_tags);
+ $res_str .= "loc_range:$loc_range \nlang_tags: $comma_arr\n";
+ $res_str .= "\nlookup result:$result\n";
+//canonicalized version
+ $result= ut_loc_locale_lookup( $lang_tags , $loc_range,!($isCanonical),"en_US");
+ $can_loc_range = ut_loc_canonicalize($loc_range);
+ $res_str .= "Canonical lookup result:$result\n";
+
+ }
+
+ $res_str .= "\n";
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+--------------
+loc_range:de-de
+lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
+
+lookup result:de-DE
+Canonical lookup result:de_de
+--------------
+loc_range:sl_IT
+lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
+
+lookup result:sl_IT
+Canonical lookup result:sl_it
+--------------
+loc_range:sl_IT_Nedis
+lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
+
+lookup result:sl_IT
+Canonical lookup result:sl_it
+--------------
+loc_range:jbo
+lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
+
+lookup result:jbo
+Canonical lookup result:jbo
+--------------
+loc_range:art-lojban
+lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
+
+lookup result:art-lojban
+Canonical lookup result:jbo
diff --git a/ext/intl/tests/locale_parse_locale.phpt b/ext/intl/tests/locale_parse_locale.phpt
new file mode 100644
index 0000000..c8aa2f4
--- /dev/null
+++ b/ext/intl/tests/locale_parse_locale.phpt
@@ -0,0 +1,203 @@
+--TEST--
+locale_parse_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
+
+/*
+ * Try parsing different Locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $arr = ut_loc_locale_parse( $locale);
+ $res_str .= "---------------------\n";
+ $res_str .= "$locale:\n";
+ if( $arr){
+ foreach( $arr as $key => $value){
+ $res_str .= "$key : '$value' , ";
+ }
+ $res_str = rtrim($res_str);
+ }
+ else{
+ $res_str .= "No values found from Locale parsing.";
+ }
+ $res_str .= "\n";
+ }
+
+ $res_str .= "\n";
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTF--
+---------------------
+uk-ua_CALIFORNIA@currency=;currency=GRN:
+language : 'uk' , region : 'UA' , variant0 : 'CALIFORNIA' ,
+---------------------
+root:
+language : 'root' ,
+---------------------
+uk@currency=EURO:
+language : 'uk' ,
+---------------------
+Hindi:
+language : 'hindi' ,
+---------------------
+de:
+language : 'de' ,
+---------------------
+fr:
+language : 'fr' ,
+---------------------
+ja:
+language : 'ja' ,
+---------------------
+i-enochian:
+grandfathered : 'i-enochian' ,
+---------------------
+zh-Hant:
+language : 'zh' , script : 'Hant' ,
+---------------------
+zh-Hans:
+language : 'zh' , script : 'Hans' ,
+---------------------
+sr-Cyrl:
+language : 'sr' , script : 'Cyrl' ,
+---------------------
+sr-Latn:
+language : 'sr' , script : 'Latn' ,
+---------------------
+zh-Hans-CN:
+language : 'zh' , script : 'Hans' , region : 'CN' ,
+---------------------
+sr-Latn-CS:
+language : 'sr' , script : 'Latn' , region : 'CS' ,
+---------------------
+sl-rozaj:
+language : 'sl' ,%r( region : 'ROZAJ' ,)?%r
+---------------------
+sl-nedis:
+language : 'sl' ,%r( region : 'NEDIS' ,)?%r
+---------------------
+de-CH-1901:
+language : 'de' , region : 'CH' , variant0 : '1901' ,
+---------------------
+sl-IT-nedis:
+language : 'sl' , region : 'IT' , variant0 : 'NEDIS' ,
+---------------------
+sl-Latn-IT-nedis:
+language : 'sl' , script : 'Latn' , region : 'IT' , variant0 : 'NEDIS' ,
+---------------------
+de-DE:
+language : 'de' , region : 'DE' ,
+---------------------
+en-US:
+language : 'en' , region : 'US' ,
+---------------------
+es-419:
+language : 'es' , region : '419' ,
+---------------------
+de-CH-x-phonebk:
+language : 'de' , region : 'CH' , private0 : 'phonebk' ,
+---------------------
+az-Arab-x-AZE-derbend:
+language : 'az' , script : 'Arab' , private0 : 'AZE' , private1 : 'derbend' ,
+---------------------
+zh-min:
+grandfathered : 'zh-min' ,
+---------------------
+zh-min-nan-Hant-CN:
+language : 'zh' , region : 'MIN' , variant0 : 'NAN' , variant1 : 'HANT' , variant2 : 'CN' ,
+---------------------
+qaa-Qaaa-QM-x-southern:
+language : 'qaa' , script : 'Qaaa' , region : 'QM' , private0 : 'southern' ,
+---------------------
+sr-Latn-QM:
+language : 'sr' , script : 'Latn' , region : 'QM' ,
+---------------------
+sr-Qaaa-CS:
+language : 'sr' , script : 'Qaaa' , region : 'CS' ,
+---------------------
+en-US-u-islamCal:
+language : 'en' , region : 'US' ,
+---------------------
+zh-CN-a-myExt-x-private:
+language : 'zh' , region : 'CN' , private0 : 'private' ,
+---------------------
+en-a-myExt-b-another:
+language : 'en' ,
+---------------------
+de-419-DE:
+language : 'de' , region : '419' , variant0 : 'DE' ,
+---------------------
+a-DE:
+No values found from Locale parsing.
+---------------------
+ar-a-aaa-b-bbb-a-ccc:
+language : 'ar' ,
diff --git a/ext/intl/tests/locale_parse_locale2.phpt b/ext/intl/tests/locale_parse_locale2.phpt
new file mode 100644
index 0000000..6012862
--- /dev/null
+++ b/ext/intl/tests/locale_parse_locale2.phpt
@@ -0,0 +1,203 @@
+--TEST--
+locale_parse_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 parsing different Locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+/*Tags that use extensions (examples ONLY: extensions MUST be defined
+ by revision or update to this document or by RFC): */
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $arr = ut_loc_locale_parse( $locale);
+ $res_str .= "---------------------\n";
+ $res_str .= "$locale:\n";
+ if( $arr){
+ foreach( $arr as $key => $value){
+ $res_str .= "$key : '$value' , ";
+ }
+ $res_str = rtrim($res_str);
+ }
+ else{
+ $res_str .= "No values found from Locale parsing.";
+ }
+ $res_str .= "\n";
+ }
+
+ $res_str .= "\n";
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECTF--
+---------------------
+uk-ua_CALIFORNIA@currency=;currency=GRN:
+language : 'uk' , region : 'UA' , variant0 : 'CALIFORNIA' ,
+---------------------
+root:
+language : 'root' ,
+---------------------
+uk@currency=EURO:
+language : 'uk' ,
+---------------------
+Hindi:
+language : 'hindi' ,
+---------------------
+de:
+language : 'de' ,
+---------------------
+fr:
+language : 'fr' ,
+---------------------
+ja:
+language : 'ja' ,
+---------------------
+i-enochian:
+grandfathered : 'i-enochian' ,
+---------------------
+zh-Hant:
+language : 'zh' , script : 'Hant' ,
+---------------------
+zh-Hans:
+language : 'zh' , script : 'Hans' ,
+---------------------
+sr-Cyrl:
+language : 'sr' , script : 'Cyrl' ,
+---------------------
+sr-Latn:
+language : 'sr' , script : 'Latn' ,
+---------------------
+zh-Hans-CN:
+language : 'zh' , script : 'Hans' , region : 'CN' ,
+---------------------
+sr-Latn-CS:
+language : 'sr' , script : 'Latn' , region : 'CS' ,
+---------------------
+sl-rozaj:
+language : 'sl' , variant0 : 'ROZAJ' ,
+---------------------
+sl-nedis:
+language : 'sl' , variant0 : 'NEDIS' ,
+---------------------
+de-CH-1901:
+language : 'de' , region : 'CH' , variant0 : '1901' ,
+---------------------
+sl-IT-nedis:
+language : 'sl' , region : 'IT' , variant0 : 'NEDIS' ,
+---------------------
+sl-Latn-IT-nedis:
+language : 'sl' , script : 'Latn' , region : 'IT' , variant0 : 'NEDIS' ,
+---------------------
+de-DE:
+language : 'de' , region : 'DE' ,
+---------------------
+en-US:
+language : 'en' , region : 'US' ,
+---------------------
+es-419:
+language : 'es' , region : '419' ,
+---------------------
+de-CH-x-phonebk:
+language : 'de' , region : 'CH' , private0 : 'phonebk' ,
+---------------------
+az-Arab-x-AZE-derbend:
+language : 'az' , script : 'Arab' , private0 : 'AZE' , private1 : 'derbend' ,
+---------------------
+zh-min:
+grandfathered : 'zh-min' ,
+---------------------
+zh-min-nan-Hant-CN:
+language : 'zh' , region : 'MIN' , variant0 : 'NAN' , variant1 : 'HANT' , variant2 : 'CN' ,
+---------------------
+qaa-Qaaa-QM-x-southern:
+language : 'qaa' , script : 'Qaaa' , region : 'QM' , private0 : 'southern' ,
+---------------------
+sr-Latn-QM:
+language : 'sr' , script : 'Latn' , region : 'QM' ,
+---------------------
+sr-Qaaa-CS:
+language : 'sr' , script : 'Qaaa' , region : 'CS' ,
+---------------------
+en-US-u-islamCal:
+language : 'en' , region : 'US' ,
+---------------------
+zh-CN-a-myExt-x-private:
+language : 'zh' , region : 'CN' , private0 : 'private' ,
+---------------------
+en-a-myExt-b-another:
+language : 'en' ,
+---------------------
+de-419-DE:
+language : 'de' , region : '419' , variant0 : 'DE' ,
+---------------------
+a-DE:
+No values found from Locale parsing.
+---------------------
+ar-a-aaa-b-bbb-a-ccc:
+language : 'ar' ,
diff --git a/ext/intl/tests/locale_set_default.phpt b/ext/intl/tests/locale_set_default.phpt
new file mode 100644
index 0000000..7debf4d
--- /dev/null
+++ b/ext/intl/tests/locale_set_default.phpt
@@ -0,0 +1,133 @@
+--TEST--
+locale_set_default($locale)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try setting the default Locale with different locales
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $locales = array(
+ 'uk-ua_CALIFORNIA@currency=;currency=GRN',
+ 'root',
+ 'uk@currency=EURO',
+ 'Hindi',
+//Simple language subtag
+ 'de',
+ 'fr',
+ 'ja',
+ 'i-enochian', //(example of a grandfathered tag)
+//Language subtag plus Script subtag:
+ 'zh-Hant',
+ 'zh-Hans',
+ 'sr-Cyrl',
+ 'sr-Latn',
+//Language-Script-Region
+ 'zh-Hans-CN',
+ 'sr-Latn-CS',
+//Language-Variant
+ 'sl-rozaj',
+ 'sl-nedis',
+//Language-Region-Variant
+ 'de-CH-1901',
+ 'sl-IT-nedis',
+//Language-Script-Region-Variant
+ 'sl-Latn-IT-nedis',
+//Language-Region:
+ 'de-DE',
+ 'en-US',
+ 'es-419',
+//Private use subtags:
+ 'de-CH-x-phonebk',
+ 'az-Arab-x-AZE-derbend',
+//Extended language subtags
+ 'zh-min',
+ 'zh-min-nan-Hant-CN',
+//Private use registry values
+ 'x-whatever',
+ 'qaa-Qaaa-QM-x-southern',
+ 'sr-Latn-QM',
+ 'sr-Qaaa-CS',
+//Tags that use extensions (examples ONLY: extensions MUST be defined
+// by revision or update to this document or by RFC):
+ 'en-US-u-islamCal',
+ 'zh-CN-a-myExt-x-private',
+ 'en-a-myExt-b-another',
+//Some Invalid Tags:
+ 'de-419-DE',
+ 'a-DE',
+ 'ar-a-aaa-b-bbb-a-ccc'
+ );
+
+/*
+ $locales = array(
+ 'es'
+ );
+*/
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $isSuccessful = ut_loc_set_default( $locale);
+ if ($isSuccessful ){
+ $lang = ut_loc_get_default( );
+ $res_str .= "$locale: set locale '$lang'";
+ }
+ else{
+ $res_str .= "$locale: Error in set locale";
+ }
+ $res_str .= "\n";
+ }
+
+ return $res_str;
+
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+uk-ua_CALIFORNIA@currency=;currency=GRN: set locale 'uk-ua_CALIFORNIA@currency=;currency=GRN'
+root: set locale 'root'
+uk@currency=EURO: set locale 'uk@currency=EURO'
+Hindi: set locale 'Hindi'
+de: set locale 'de'
+fr: set locale 'fr'
+ja: set locale 'ja'
+i-enochian: set locale 'i-enochian'
+zh-Hant: set locale 'zh-Hant'
+zh-Hans: set locale 'zh-Hans'
+sr-Cyrl: set locale 'sr-Cyrl'
+sr-Latn: set locale 'sr-Latn'
+zh-Hans-CN: set locale 'zh-Hans-CN'
+sr-Latn-CS: set locale 'sr-Latn-CS'
+sl-rozaj: set locale 'sl-rozaj'
+sl-nedis: set locale 'sl-nedis'
+de-CH-1901: set locale 'de-CH-1901'
+sl-IT-nedis: set locale 'sl-IT-nedis'
+sl-Latn-IT-nedis: set locale 'sl-Latn-IT-nedis'
+de-DE: set locale 'de-DE'
+en-US: set locale 'en-US'
+es-419: set locale 'es-419'
+de-CH-x-phonebk: set locale 'de-CH-x-phonebk'
+az-Arab-x-AZE-derbend: set locale 'az-Arab-x-AZE-derbend'
+zh-min: set locale 'zh-min'
+zh-min-nan-Hant-CN: set locale 'zh-min-nan-Hant-CN'
+x-whatever: set locale 'x-whatever'
+qaa-Qaaa-QM-x-southern: set locale 'qaa-Qaaa-QM-x-southern'
+sr-Latn-QM: set locale 'sr-Latn-QM'
+sr-Qaaa-CS: set locale 'sr-Qaaa-CS'
+en-US-u-islamCal: set locale 'en-US-u-islamCal'
+zh-CN-a-myExt-x-private: set locale 'zh-CN-a-myExt-x-private'
+en-a-myExt-b-another: set locale 'en-a-myExt-b-another'
+de-419-DE: set locale 'de-419-DE'
+a-DE: set locale 'a-DE'
+ar-a-aaa-b-bbb-a-ccc: set locale 'ar-a-aaa-b-bbb-a-ccc'
diff --git a/ext/intl/tests/msgfmt_clone.phpt b/ext/intl/tests/msgfmt_clone.phpt
new file mode 100644
index 0000000..9d8ea64
--- /dev/null
+++ b/ext/intl/tests/msgfmt_clone.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Cloning msgfmt
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+include_once( 'ut_common.inc' );
+$GLOBALS['oo-mode'] = true;
+$res_str = '';
+/*
+ * Clone
+ */
+$fmt = ut_msgfmt_create( "en_US", "{0,number} monkeys on {1,number} trees" );
+
+// Get default patten.
+$res_str .= "Formatting result: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n";
+$fmt_clone = clone $fmt;
+// Set a new pattern.
+$pattern = "{0,number} trees hosting {1,number} monkeys";
+$res = ut_msgfmt_set_pattern( $fmt, $pattern );
+$res_str .= "Formatting result: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n";
+$res_str .= "Formatting clone result: " . ut_msgfmt_format( $fmt_clone, array(123, 456) ) . "\n";
+
+echo $res_str;
+
+?>
+--EXPECTF--
+Formatting result: 123 monkeys on 456 trees
+Formatting result: 123 trees hosting 456 monkeys
+Formatting clone result: 123 monkeys on 456 trees
diff --git a/ext/intl/tests/msgfmt_clone_bad_obj.phpt b/ext/intl/tests/msgfmt_clone_bad_obj.phpt
new file mode 100644
index 0000000..4832109
--- /dev/null
+++ b/ext/intl/tests/msgfmt_clone_bad_obj.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Cloning unconstructed MessageFormatter
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+class A extends MessageFormatter {
+ function __construct() {}
+}
+
+$a = new A;
+try {
+ $b = clone $a;
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+--EXPECTF--
+string(%d) "Cannot clone unconstructed MessageFormatter"
diff --git a/ext/intl/tests/msgfmt_fail.phpt b/ext/intl/tests/msgfmt_fail.phpt
new file mode 100644
index 0000000..bffb71c
--- /dev/null
+++ b/ext/intl/tests/msgfmt_fail.phpt
@@ -0,0 +1,102 @@
+--TEST--
+msgfmt creation failures 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
+
+function err($fmt) {
+ if(!$fmt) {
+ echo var_export(intl_get_error_message(), true)."\n";
+ }
+}
+
+function crt($t, $l, $s) {
+ switch(true) {
+ case $t == "O":
+ return new MessageFormatter($l, $s);
+ break;
+ case $t == "C":
+ return MessageFormatter::create($l, $s);
+ break;
+ case $t == "P":
+ return msgfmt_create($l, $s);
+ break;
+ }
+}
+
+$args = array(
+ array(null, null),
+ array("whatever", "{0,whatever}"),
+ array(array(), array()),
+ array("en", "{0,choice}"),
+ array("fr", "{0,"),
+ array("en_US", "\xD0"),
+);
+
+$fmt = new MessageFormatter();
+err($fmt);
+$fmt = msgfmt_create();
+err($fmt);
+$fmt = MessageFormatter::create();
+err($fmt);
+$fmt = new MessageFormatter('en');
+err($fmt);
+$fmt = msgfmt_create('en');
+err($fmt);
+$fmt = MessageFormatter::create('en');
+err($fmt);
+
+foreach($args as $arg) {
+ $fmt = crt("O", $arg[0], $arg[1]);
+ err($fmt);
+ $fmt = crt("C", $arg[0], $arg[1]);
+ err($fmt);
+ $fmt = crt("P", $arg[0], $arg[1]);
+ err($fmt);
+}
+
+?>
+--EXPECTF--
+Warning: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: MessageFormatter::create() expects exactly 2 parameters, 0 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: MessageFormatter::create() expects exactly 2 parameters, 1 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: MessageFormatter::create() expects parameter 1 to be string, array given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: msgfmt_create() expects parameter 1 to be string, array given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
+'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
+'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
+'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
+'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
+'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
diff --git a/ext/intl/tests/msgfmt_fail2.phpt b/ext/intl/tests/msgfmt_fail2.phpt
new file mode 100644
index 0000000..eee2424
--- /dev/null
+++ b/ext/intl/tests/msgfmt_fail2.phpt
@@ -0,0 +1,102 @@
+--TEST--
+msgfmt creation failures 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
+
+function err($fmt) {
+ if(!$fmt) {
+ echo var_export(intl_get_error_message(), true)."\n";
+ }
+}
+
+function crt($t, $l, $s) {
+ switch(true) {
+ case $t == "O":
+ return new MessageFormatter($l, $s);
+ break;
+ case $t == "C":
+ return MessageFormatter::create($l, $s);
+ break;
+ case $t == "P":
+ return msgfmt_create($l, $s);
+ break;
+ }
+}
+
+$args = array(
+ array(null, null),
+ array("whatever", "{0,whatever}"),
+ array(array(), array()),
+ array("en", "{0,choice}"),
+ array("fr", "{0,"),
+ array("en_US", "\xD0"),
+);
+
+$fmt = new MessageFormatter();
+err($fmt);
+$fmt = msgfmt_create();
+err($fmt);
+$fmt = MessageFormatter::create();
+err($fmt);
+$fmt = new MessageFormatter('en');
+err($fmt);
+$fmt = msgfmt_create('en');
+err($fmt);
+$fmt = MessageFormatter::create('en');
+err($fmt);
+
+foreach($args as $arg) {
+ $fmt = crt("O", $arg[0], $arg[1]);
+ err($fmt);
+ $fmt = crt("C", $arg[0], $arg[1]);
+ err($fmt);
+ $fmt = crt("P", $arg[0], $arg[1]);
+ err($fmt);
+}
+
+?>
+--EXPECTF--
+Warning: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: MessageFormatter::create() expects exactly 2 parameters, 0 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: MessageFormatter::create() expects exactly 2 parameters, 1 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: MessageFormatter::create() expects parameter 1 to be string, array given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Warning: msgfmt_create() expects parameter 1 to be string, array given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
+'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
+'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
+'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
+'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
+'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
+'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
+'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
+'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
diff --git a/ext/intl/tests/msgfmt_format.phpt b/ext/intl/tests/msgfmt_format.phpt
new file mode 100644
index 0000000..c1bf5e9
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format.phpt
@@ -0,0 +1,70 @@
+--TEST--
+msgfmt_format()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Format a number using misc locales/patterns.
+ */
+
+
+function ut_main()
+{
+ $locales = array(
+ 'en_US' => "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree",
+ 'ru_UA' => "{0,number,integer} мавп на {1,number,integer} деревах це {2,number} мавпи на кожному деревi",
+ 'de' => "{0,number,integer} Affen über {1,number,integer} Bäume um {2,number} Affen pro Baum",
+ 'en_UK' => "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree",
+ 'root' => '{0,whatever} would not work!',
+ 'fr' => "C'est la vie!",
+ );
+
+ $str_res = '';
+ $m = 4560;
+ $t = 123;
+
+ foreach( $locales as $locale => $pattern )
+ {
+ $str_res .= "\nLocale is: $locale\n";
+ $fmt = ut_msgfmt_create( $locale, $pattern );
+ if(!$fmt) {
+ $str_res .= dump(intl_get_error_message())."\n";
+ continue;
+ }
+ $str_res .= dump( ut_msgfmt_format( $fmt, array($m, $t, $m/$t) ) ) . "\n";
+ $str_res .= dump( ut_msgfmt_format_message($locale, $pattern, array($m, $t, $m/$t))) . "\n";
+ }
+ return $str_res;
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+
+?>
+--EXPECT--
+Locale is: en_US
+'4,560 monkeys on 123 trees make 37.073 monkeys per tree'
+'4,560 monkeys on 123 trees make 37.073 monkeys per tree'
+
+Locale is: ru_UA
+'4 560 мавп на 123 деревах це 37,073 мавпи на кожному деревi'
+'4 560 мавп на 123 деревах це 37,073 мавпи на кожному деревi'
+
+Locale is: de
+'4.560 Affen über 123 Bäume um 37,073 Affen pro Baum'
+'4.560 Affen über 123 Bäume um 37,073 Affen pro Baum'
+
+Locale is: en_UK
+'4,560 monkeys on 123 trees make 37.073 monkeys per tree'
+'4,560 monkeys on 123 trees make 37.073 monkeys per tree'
+
+Locale is: root
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+
+Locale is: fr
+'C\'est la vie!'
+'C\'est la vie!'
diff --git a/ext/intl/tests/msgfmt_get_error.phpt b/ext/intl/tests/msgfmt_get_error.phpt
new file mode 100644
index 0000000..015c50d
--- /dev/null
+++ b/ext/intl/tests/msgfmt_get_error.phpt
@@ -0,0 +1,29 @@
+--TEST--
+msgmfmt_get_error_message/code()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Error handling.
+ */
+
+
+function ut_main()
+{
+ $fmt = ut_msgfmt_create( "en_US", "{0, number} monkeys on {1, number} trees" );
+ $num = ut_msgfmt_format( $fmt, array());
+ if( $num === false )
+ return $fmt->getErrorMessage() . " (" . $fmt->getErrorCode() . ")\n";
+ else
+ return "Ooops, an error should have occured.";
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+msgfmt_format: not enough parameters: U_ILLEGAL_ARGUMENT_ERROR (1)
diff --git a/ext/intl/tests/msgfmt_get_locale.phpt b/ext/intl/tests/msgfmt_get_locale.phpt
new file mode 100644
index 0000000..4c2651f
--- /dev/null
+++ b/ext/intl/tests/msgfmt_get_locale.phpt
@@ -0,0 +1,40 @@
+--TEST--
+msgfmt_get_locale()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Get locale.
+ */
+
+function ut_main()
+{
+ $locales = array(
+ 'en_UK',
+ 'en_US@California',
+ 'uk',
+ );
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $fmt = ut_msgfmt_create( $locale, "Test" );
+ $res_str .= "$locale: " . dump( ut_msgfmt_get_locale( $fmt ) );
+ $res_str .= "\n";
+ }
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+en_UK: 'en_UK'
+en_US@California: 'en_US@California'
+uk: 'uk'
diff --git a/ext/intl/tests/msgfmt_get_set_pattern.phpt b/ext/intl/tests/msgfmt_get_set_pattern.phpt
new file mode 100644
index 0000000..67b1aca
--- /dev/null
+++ b/ext/intl/tests/msgfmt_get_set_pattern.phpt
@@ -0,0 +1,53 @@
+--TEST--
+msgfmt_get/set_pattern()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Get/set pattern.
+ */
+
+
+function ut_main()
+{
+ $res_str = '';
+ $fmt = ut_msgfmt_create( "en_US", "{0,number} monkeys on {1,number} trees" );
+
+ // Get default patten.
+ $res_str .= "Default pattern: '" . ut_msgfmt_get_pattern( $fmt ) . "'\n";
+ $res_str .= "Formatting result: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n";
+
+ // Set a new pattern.
+ $pattern = "{0,number} trees hosting {1,number} monkeys";
+ $res = ut_msgfmt_set_pattern( $fmt, $pattern );
+ if( $res === false )
+ $res_str .= ut_msgfmt_get_error_message( $fmt ) . " (" . ut_msgfmt_get_error_code( $fmt ) . ")\n";
+
+ // Check if the pattern has been changed.
+ $res = ut_msgfmt_get_pattern( $fmt );
+ if( $res === false )
+ $res_str .= ut_msgfmt_get_error_message( $fmt ) . " (" . ut_msgfmt_get_error_code( $fmt ) . ")\n";
+ $res_str .= "New pattern: '" . ut_msgfmt_get_pattern( $fmt ) . "'\n";
+ $res_str .= "Formatted message: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n";
+
+ ut_msgfmt_set_pattern($fmt, str_repeat($pattern, 10));
+ $res_str .= "New pattern: '" . ut_msgfmt_get_pattern( $fmt ) . "'\n";
+ $res_str .= "Formatted message: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n";
+
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+Default pattern: '{0,number} monkeys on {1,number} trees'
+Formatting result: 123 monkeys on 456 trees
+New pattern: '{0,number} trees hosting {1,number} monkeys'
+Formatted message: 123 trees hosting 456 monkeys
+New pattern: '{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys'
+Formatted message: 123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys
diff --git a/ext/intl/tests/msgfmt_parse.phpt b/ext/intl/tests/msgfmt_parse.phpt
new file mode 100644
index 0000000..b9ec363
--- /dev/null
+++ b/ext/intl/tests/msgfmt_parse.phpt
@@ -0,0 +1,114 @@
+--TEST--
+msgfmt_parse() tests
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Format a number using misc locales/patterns.
+ */
+
+
+function ut_main()
+{
+ $locales = array(
+ 'en_US' => "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree",
+ 'ru_UA' => "{0,number,integer} мавп на {1,number,integer} деревах це {2,number} мавпи на кожному деревi",
+ 'de' => "{0,number,integer} Affen über {1,number,integer} Bäume um {2,number} Affen pro Baum",
+ 'en_UK' => "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree",
+ 'root' => '{0,whatever} would not work!',
+ 'fr' => 'C\'est {0,number,integer}',
+ );
+
+ $results = array(
+ 'en_US' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree",
+ 'ru_UA' => "4 560 мавп на 123 деревах це 37,073 мавпи на кожному деревi",
+ 'de' => "4.560 Affen über 123 Bäume um 37,073 Affen pro Baum",
+ 'en_UK' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree",
+ 'root' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree",
+ 'fr' => "C'est 42",
+
+ );
+
+ $str_res = '';
+
+ foreach( $locales as $locale => $pattern )
+ {
+ $str_res .= "\nLocale is: $locale\n";
+ $fmt = ut_msgfmt_create( $locale, $pattern );
+ if(!$fmt) {
+ $str_res .= dump(intl_get_error_message())."\n";
+ continue;
+ }
+ $str_res .= dump( ut_msgfmt_parse( $fmt, $results[$locale] ) ) . "\n";
+ $str_res .= dump( ut_msgfmt_parse_message($locale, $pattern, $results[$locale])) . "\n";
+ }
+ return $str_res;
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+
+?>
+--EXPECT--
+Locale is: en_US
+array (
+ 0 => 4560,
+ 1 => 123,
+ 2 => 37.073,
+)
+array (
+ 0 => 4560,
+ 1 => 123,
+ 2 => 37.073,
+)
+
+Locale is: ru_UA
+array (
+ 0 => 4560,
+ 1 => 123,
+ 2 => 37.073,
+)
+array (
+ 0 => 4560,
+ 1 => 123,
+ 2 => 37.073,
+)
+
+Locale is: de
+array (
+ 0 => 4560,
+ 1 => 123,
+ 2 => 37.073,
+)
+array (
+ 0 => 4560,
+ 1 => 123,
+ 2 => 37.073,
+)
+
+Locale is: en_UK
+array (
+ 0 => 4560,
+ 1 => 123,
+ 2 => 37.073,
+)
+array (
+ 0 => 4560,
+ 1 => 123,
+ 2 => 37.073,
+)
+
+Locale is: root
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+
+Locale is: fr
+array (
+ 0 => 42,
+)
+array (
+ 0 => 42,
+)
diff --git a/ext/intl/tests/normalizer_normalize.phpt b/ext/intl/tests/normalizer_normalize.phpt
new file mode 100644
index 0000000..238b742
--- /dev/null
+++ b/ext/intl/tests/normalizer_normalize.phpt
@@ -0,0 +1,160 @@
+--TEST--
+normalize()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Try normalization and test normalization
+ * with Procedural and Object methods.
+ */
+
+function ut_main()
+{
+ $res_str = '';
+
+ $forms = array(
+ Normalizer::FORM_C,
+ Normalizer::FORM_D,
+ Normalizer::FORM_KC,
+ Normalizer::FORM_KD,
+ Normalizer::NONE,
+ );
+
+ $forms_str = array (
+ Normalizer::FORM_C => 'UNORM_FORM_C',
+ Normalizer::FORM_D => 'UNORM_FORM_D',
+ Normalizer::FORM_KC => 'UNORM_FORM_KC',
+ Normalizer::FORM_KD => 'UNORM_FORM_KD',
+ Normalizer::NONE => 'UNORM_NONE',
+ );
+
+ /* just make sure all the form constants are defined as in the api spec */
+ if ( Normalizer::FORM_C != Normalizer::NFC ||
+ Normalizer::FORM_D != Normalizer::NFD ||
+ Normalizer::FORM_KC != Normalizer::NFKC ||
+ Normalizer::FORM_KD != Normalizer::NFKD ||
+ Normalizer::NONE == Normalizer::FORM_C ) {
+
+ $res_str .= "Invalid normalization form declarations!\n";
+ }
+
+ $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4)
+ $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5)
+ $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6)
+
+ $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B)
+ $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
+
+ $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126)
+ $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9)
+
+ $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A)
+
+ $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01)
+
+ $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B)
+
+ $strs = array(
+ 'ABC',
+ $char_a_diaeresis . '||' . $char_a_ring . '||' . $char_o_diaeresis,
+ $char_angstrom_sign . '||' . $char_A_ring . '||' . 'A' . $char_combining_ring_above,
+ $char_ohm_sign . '||' . $char_omega,
+ $char_fi_ligature,
+ $char_long_s_dot,
+ );
+
+ foreach( $forms as $form )
+ {
+ foreach( $strs as $str )
+ {
+ $str_norm = ut_norm_normalize( $str, $form );
+ $error_code = intl_get_error_code();
+ $error_message = intl_get_error_message();
+
+ $str_hex = urlencode($str);
+ $str_norm_hex = urlencode($str_norm);
+ $res_str .= "'$str_hex' normalized to form '{$forms_str[$form]}' is '$str_norm_hex'"
+ . "\terror info: '$error_message' ($error_code)\n"
+ . "";
+
+ $is_norm = ut_norm_is_normalized( $str, $form );
+ $error_code = intl_get_error_code();
+ $error_message = intl_get_error_message();
+
+ $res_str .= " is in form '{$forms_str[$form]}'? = " . ($is_norm ? "yes" : "no")
+ . "\terror info: '$error_message' ($error_code)\n"
+ . "";
+ }
+ }
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+'ABC' normalized to form 'UNORM_FORM_C' is 'ABC' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_C'? = yes error info: 'U_ZERO_ERROR' (0)
+'%C3%A4%7C%7C%C3%A5%7C%7C%C3%B6' normalized to form 'UNORM_FORM_C' is '%C3%A4%7C%7C%C3%A5%7C%7C%C3%B6' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_C'? = yes error info: 'U_ZERO_ERROR' (0)
+'%E2%84%AB%7C%7C%C3%85%7C%7CA%CC%8A' normalized to form 'UNORM_FORM_C' is '%C3%85%7C%7C%C3%85%7C%7C%C3%85' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_C'? = no error info: 'U_ZERO_ERROR' (0)
+'%E2%84%A6%7C%7C%CE%A9' normalized to form 'UNORM_FORM_C' is '%CE%A9%7C%7C%CE%A9' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_C'? = no error info: 'U_ZERO_ERROR' (0)
+'%EF%AC%81' normalized to form 'UNORM_FORM_C' is '%EF%AC%81' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_C'? = yes error info: 'U_ZERO_ERROR' (0)
+'%E1%BA%9B' normalized to form 'UNORM_FORM_C' is '%E1%BA%9B' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_C'? = yes error info: 'U_ZERO_ERROR' (0)
+'ABC' normalized to form 'UNORM_FORM_D' is 'ABC' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_D'? = yes error info: 'U_ZERO_ERROR' (0)
+'%C3%A4%7C%7C%C3%A5%7C%7C%C3%B6' normalized to form 'UNORM_FORM_D' is 'a%CC%88%7C%7Ca%CC%8A%7C%7Co%CC%88' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_D'? = no error info: 'U_ZERO_ERROR' (0)
+'%E2%84%AB%7C%7C%C3%85%7C%7CA%CC%8A' normalized to form 'UNORM_FORM_D' is 'A%CC%8A%7C%7CA%CC%8A%7C%7CA%CC%8A' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_D'? = no error info: 'U_ZERO_ERROR' (0)
+'%E2%84%A6%7C%7C%CE%A9' normalized to form 'UNORM_FORM_D' is '%CE%A9%7C%7C%CE%A9' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_D'? = no error info: 'U_ZERO_ERROR' (0)
+'%EF%AC%81' normalized to form 'UNORM_FORM_D' is '%EF%AC%81' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_D'? = yes error info: 'U_ZERO_ERROR' (0)
+'%E1%BA%9B' normalized to form 'UNORM_FORM_D' is '%C5%BF%CC%87' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_D'? = no error info: 'U_ZERO_ERROR' (0)
+'ABC' normalized to form 'UNORM_FORM_KC' is 'ABC' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KC'? = yes error info: 'U_ZERO_ERROR' (0)
+'%C3%A4%7C%7C%C3%A5%7C%7C%C3%B6' normalized to form 'UNORM_FORM_KC' is '%C3%A4%7C%7C%C3%A5%7C%7C%C3%B6' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KC'? = yes error info: 'U_ZERO_ERROR' (0)
+'%E2%84%AB%7C%7C%C3%85%7C%7CA%CC%8A' normalized to form 'UNORM_FORM_KC' is '%C3%85%7C%7C%C3%85%7C%7C%C3%85' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KC'? = no error info: 'U_ZERO_ERROR' (0)
+'%E2%84%A6%7C%7C%CE%A9' normalized to form 'UNORM_FORM_KC' is '%CE%A9%7C%7C%CE%A9' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KC'? = no error info: 'U_ZERO_ERROR' (0)
+'%EF%AC%81' normalized to form 'UNORM_FORM_KC' is 'fi' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KC'? = no error info: 'U_ZERO_ERROR' (0)
+'%E1%BA%9B' normalized to form 'UNORM_FORM_KC' is '%E1%B9%A1' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KC'? = no error info: 'U_ZERO_ERROR' (0)
+'ABC' normalized to form 'UNORM_FORM_KD' is 'ABC' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KD'? = yes error info: 'U_ZERO_ERROR' (0)
+'%C3%A4%7C%7C%C3%A5%7C%7C%C3%B6' normalized to form 'UNORM_FORM_KD' is 'a%CC%88%7C%7Ca%CC%8A%7C%7Co%CC%88' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KD'? = no error info: 'U_ZERO_ERROR' (0)
+'%E2%84%AB%7C%7C%C3%85%7C%7CA%CC%8A' normalized to form 'UNORM_FORM_KD' is 'A%CC%8A%7C%7CA%CC%8A%7C%7CA%CC%8A' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KD'? = no error info: 'U_ZERO_ERROR' (0)
+'%E2%84%A6%7C%7C%CE%A9' normalized to form 'UNORM_FORM_KD' is '%CE%A9%7C%7C%CE%A9' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KD'? = no error info: 'U_ZERO_ERROR' (0)
+'%EF%AC%81' normalized to form 'UNORM_FORM_KD' is 'fi' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KD'? = no error info: 'U_ZERO_ERROR' (0)
+'%E1%BA%9B' normalized to form 'UNORM_FORM_KD' is 's%CC%87' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_FORM_KD'? = no error info: 'U_ZERO_ERROR' (0)
+'ABC' normalized to form 'UNORM_NONE' is 'ABC' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_NONE'? = no error info: 'normalizer_normalize: illegal normalization form: U_ILLEGAL_ARGUMENT_ERROR' (1)
+'%C3%A4%7C%7C%C3%A5%7C%7C%C3%B6' normalized to form 'UNORM_NONE' is '%C3%A4%7C%7C%C3%A5%7C%7C%C3%B6' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_NONE'? = no error info: 'normalizer_normalize: illegal normalization form: U_ILLEGAL_ARGUMENT_ERROR' (1)
+'%E2%84%AB%7C%7C%C3%85%7C%7CA%CC%8A' normalized to form 'UNORM_NONE' is '%E2%84%AB%7C%7C%C3%85%7C%7CA%CC%8A' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_NONE'? = no error info: 'normalizer_normalize: illegal normalization form: U_ILLEGAL_ARGUMENT_ERROR' (1)
+'%E2%84%A6%7C%7C%CE%A9' normalized to form 'UNORM_NONE' is '%E2%84%A6%7C%7C%CE%A9' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_NONE'? = no error info: 'normalizer_normalize: illegal normalization form: U_ILLEGAL_ARGUMENT_ERROR' (1)
+'%EF%AC%81' normalized to form 'UNORM_NONE' is '%EF%AC%81' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_NONE'? = no error info: 'normalizer_normalize: illegal normalization form: U_ILLEGAL_ARGUMENT_ERROR' (1)
+'%E1%BA%9B' normalized to form 'UNORM_NONE' is '%E1%BA%9B' error info: 'U_ZERO_ERROR' (0)
+ is in form 'UNORM_NONE'? = no error info: 'normalizer_normalize: illegal normalization form: U_ILLEGAL_ARGUMENT_ERROR' (1)
+
diff --git a/ext/intl/tests/regression_sort_and_cow.phpt b/ext/intl/tests/regression_sort_and_cow.phpt
new file mode 100644
index 0000000..d7ff797
--- /dev/null
+++ b/ext/intl/tests/regression_sort_and_cow.phpt
@@ -0,0 +1,85 @@
+--TEST--
+Regression: sort() and copy-on-write.
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+/*
+ * Check if collator_sort() properly supports copy-on-write.
+ */
+
+
+/* Create two copies of the given array.
+ * Sort the array and the first copy.
+ * Check if the second copy remains unsorted.
+ */
+function test_COW( $locale, $test_array )
+{
+ $res_str = '';
+
+ $coll = ut_coll_create( $locale );
+
+ // Create two copies of the given array.
+ $copy1 = $test_array;
+ $copy2 = $test_array;
+
+ // Sort given array and the first copy of it.
+ ut_coll_sort( $coll, $test_array );
+ ut_coll_sort( $coll, $copy1 );
+
+ // Return contents of all the arrays.
+ // The second copy should remain unsorted.
+ $res_str .= dump( $test_array ) . "\n";
+ $res_str .= dump( $copy1 ) . "\n";
+ $res_str .= dump( $copy2 ) . "\n";
+
+ return $res_str;
+}
+
+function ut_main()
+{
+ $res_str = '';
+
+ $a1 = array( 'b', 'a', 'c' );
+ $a2 = array( 'в', 'а', 'б' );
+
+ $res_str .= test_COW( 'en_US', $a1 );
+ $res_str .= test_COW( 'ru_RU', $a2 );
+
+ return $res_str;
+}
+
+require_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+array (
+ 0 => 'a',
+ 1 => 'b',
+ 2 => 'c',
+)
+array (
+ 0 => 'a',
+ 1 => 'b',
+ 2 => 'c',
+)
+array (
+ 0 => 'b',
+ 1 => 'a',
+ 2 => 'c',
+)
+array (
+ 0 => 'а',
+ 1 => 'б',
+ 2 => 'в',
+)
+array (
+ 0 => 'а',
+ 1 => 'б',
+ 2 => 'в',
+)
+array (
+ 0 => 'в',
+ 1 => 'а',
+ 2 => 'б',
+)
diff --git a/ext/intl/tests/regression_sort_eq.phpt b/ext/intl/tests/regression_sort_eq.phpt
new file mode 100644
index 0000000..8676c5c
--- /dev/null
+++ b/ext/intl/tests/regression_sort_eq.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Regression: sort() eq but different len.
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+/*
+ * Test sorting strings that have different length but otherwise equal.
+ */
+
+function sort_using_locale( $locale, $test_array )
+{
+ $coll = ut_coll_create( $locale );
+
+ // Sort array.
+ ut_coll_sort( $coll, $test_array );
+
+ // And return the sorted array.
+ return dump( $test_array ) . "\n";
+}
+
+function ut_main()
+{
+ $res_str = '';
+
+ // Define a couple of arrays.
+ // Each array contains equal strings that differ only in their length.
+ $a1 = array( 'aa', 'aaa', 'a' );
+ $a2 = array( 'пп', 'ппп', 'п' );
+
+ // Sort them.
+ $res_str .= sort_using_locale( 'en_US', $a1 );
+ $res_str .= sort_using_locale( 'ru_RU', $a2 );
+
+ return $res_str;
+}
+
+require_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+array (
+ 0 => 'a',
+ 1 => 'aa',
+ 2 => 'aaa',
+)
+array (
+ 0 => 'п',
+ 1 => 'пп',
+ 2 => 'ппп',
+)
diff --git a/ext/intl/tests/regression_sortwsk_and_cow.phpt b/ext/intl/tests/regression_sortwsk_and_cow.phpt
new file mode 100644
index 0000000..a495323
--- /dev/null
+++ b/ext/intl/tests/regression_sortwsk_and_cow.phpt
@@ -0,0 +1,86 @@
+--TEST--
+Regression: sort_wsk() and copy-on-write.
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+/*
+ * Check if collator_sort_with_sort_keys()
+ * properly supports copy-on-write.
+ */
+
+
+/* Create two copies of the given array.
+ * Sort the array and the first copy.
+ * Check if the second copy remains unsorted.
+ */
+function test_COW( $locale, $test_array )
+{
+ $res_str = '';
+
+ $coll = ut_coll_create( $locale );
+
+ // Create two copies of the given array.
+ $copy1 = $test_array;
+ $copy2 = $test_array;
+
+ // Sort given array and the first copy of it.
+ ut_coll_sort_with_sort_keys( $coll, $test_array );
+ ut_coll_sort_with_sort_keys( $coll, $copy1 );
+
+ // Return contents of all the arrays.
+ // The second copy should remain unsorted.
+ $res_str .= dump( $test_array ) . "\n";
+ $res_str .= dump( $copy1 ) . "\n";
+ $res_str .= dump( $copy2 ) . "\n";
+
+ return $res_str;
+}
+
+function ut_main()
+{
+ $res_str = '';
+
+ $a1 = array( 'b', 'a', 'c' );
+ $a2 = array( 'в', 'а', 'б' );
+
+ $res_str .= test_COW( 'en_US', $a1 );
+ $res_str .= test_COW( 'ru_RU', $a2 );
+
+ return $res_str;
+}
+
+require_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+array (
+ 0 => 'a',
+ 1 => 'b',
+ 2 => 'c',
+)
+array (
+ 0 => 'a',
+ 1 => 'b',
+ 2 => 'c',
+)
+array (
+ 0 => 'b',
+ 1 => 'a',
+ 2 => 'c',
+)
+array (
+ 0 => 'а',
+ 1 => 'б',
+ 2 => 'в',
+)
+array (
+ 0 => 'а',
+ 1 => 'б',
+ 2 => 'в',
+)
+array (
+ 0 => 'в',
+ 1 => 'а',
+ 2 => 'б',
+)
diff --git a/ext/intl/tests/regression_sortwsk_eq.phpt b/ext/intl/tests/regression_sortwsk_eq.phpt
new file mode 100644
index 0000000..945bac3
--- /dev/null
+++ b/ext/intl/tests/regression_sortwsk_eq.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Regression: sort_wsk() eq but different len.
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+/*
+ * Test sorting strings that have different length but otherwise equal.
+ */
+
+function sort_using_locale( $locale, $test_array )
+{
+ $coll = ut_coll_create( $locale );
+
+ // Sort array.
+ ut_coll_sort_with_sort_keys( $coll, $test_array );
+
+ // And return the sorted array.
+ return dump( $test_array ) . "\n";
+}
+
+function ut_main()
+{
+ $res_str = '';
+
+ // Define a couple of arrays.
+ // Each array contains equal strings that differ only in their length.
+ $a1 = array( 'aa', 'aaa', 'a' );
+ $a2 = array( 'пп', 'ппп', 'п' );
+
+ // Sort them.
+ $res_str .= sort_using_locale( 'en_US', $a1 );
+ $res_str .= sort_using_locale( 'ru_RU', $a2 );
+
+ return $res_str;
+}
+
+require_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+array (
+ 0 => 'a',
+ 1 => 'aa',
+ 2 => 'aaa',
+)
+array (
+ 0 => 'п',
+ 1 => 'пп',
+ 2 => 'ппп',
+)
diff --git a/ext/intl/tests/resourcebundle.build b/ext/intl/tests/resourcebundle.build
new file mode 100644
index 0000000..6a7eeae
--- /dev/null
+++ b/ext/intl/tests/resourcebundle.build
@@ -0,0 +1,33 @@
+<?php
+// THIS SCRIPT WILL REBUILD ResourceBundle bundles from source files
+
+// DEFINE YOUR ICU TOOLS PATH HERE
+define("ICU_DIR", "C:/PROJECTS/ICU40/BIN/");
+
+$here = dirname(__FILE__);
+
+$dir = new GlobIterator("$here/_files/*.txt", FilesystemIterator::KEY_AS_FILENAME);
+
+foreach($dir as $file) {
+ passthru( ICU_DIR."genrb -s $here/_files/ -d $here/_files/resourcebundle ".$file->getFileName());
+}
+
+$dir = new GlobIterator("$here/_files/resourcebundle/*.res", FilesystemIterator::KEY_AS_FILENAME);
+foreach($dir as $file) {
+ if($file->getFileName() == "res_index.res") continue;
+ $list[] = str_replace(".res", "", $file->getFileName());
+}
+
+$filelist = join(" {\"\"}\n", $list);
+$res_index = <<<END
+res_index:table(nofallback) {
+ InstalledLocales {
+$filelist {""}
+ }
+}
+END;
+file_put_contents("$here/_files/res_index.txt", $res_index);
+
+passthru( ICU_DIR."genrb -s $here/_files/ -d $here/_files/resourcebundle res_index.txt");
+
+// passthru(ICU_DIR."icupkg -tl -a $here/rb.txt -s $here/_files -d $here/_files new $here/_files/resourcebundle.dat"); \ No newline at end of file
diff --git a/ext/intl/tests/resourcebundle.inc b/ext/intl/tests/resourcebundle.inc
new file mode 100644
index 0000000..2ec138b
--- /dev/null
+++ b/ext/intl/tests/resourcebundle.inc
@@ -0,0 +1,13 @@
+<?php
+define('BUNDLE', dirname(__FILE__)."/_files/resourcebundle");
+
+function debug( $res ) {
+ if (is_null( $res )) {
+ $ret = "NULL\n";
+ }
+ else {
+ $ret = print_r( $res, true ). "\n";
+ }
+ return $ret . sprintf( "%5d: %s\n", intl_get_error_code(), intl_get_error_message() );
+}
+
diff --git a/ext/intl/tests/resourcebundle_arrayaccess.phpt b/ext/intl/tests/resourcebundle_arrayaccess.phpt
new file mode 100644
index 0000000..d035a8d
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_arrayaccess.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Test ResourceBundle array access and count - existing/missing keys
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ include "resourcebundle.inc";
+
+ // fall back
+ $r = new ResourceBundle( 'en_US', BUNDLE );
+
+ printf( "length: %d\n", count($r) );
+ printf( "teststring: %s\n", $r['teststring'] );
+ printf( "testint: %d\n", $r['testint'] );
+
+ print_r( $r['testvector'] );
+
+ printf( "testbin: %s\n", bin2hex($r['testbin']) );
+
+ $r2 = $r['testtable'];
+ printf( "testtable: %d\n", $r2['major'] );
+
+ $r2 = $r['testarray'];
+ printf( "testarray: %s\n", $r2[2] );
+
+ $t = $r['nonexisting'];
+ echo debug( $t );
+?>
+--EXPECT--
+length: 6
+teststring: Hello World!
+testint: 2
+Array
+(
+ [0] => 1
+ [1] => 2
+ [2] => 3
+ [3] => 4
+ [4] => 5
+ [5] => 6
+ [6] => 7
+ [7] => 8
+ [8] => 9
+ [9] => 0
+)
+testbin: a1b2c3d4e5f67890
+testtable: 3
+testarray: string 3
+NULL
+ 2: Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR
diff --git a/ext/intl/tests/resourcebundle_create.phpt b/ext/intl/tests/resourcebundle_create.phpt
new file mode 100644
index 0000000..2bf4f55
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_create.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test ResourceBundle::__construct() - existing/missing bundles/locales
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+include "resourcebundle.inc";
+
+function ut_main() {
+ $str_res = '';
+ // all fine
+ $r1 = ut_resourcebundle_create( 'root', BUNDLE );
+ $str_res .= debug( $r1 );
+ $str_res .= print_r( $r1['teststring'], true)."\n";
+
+ // non-root one
+ $r1 = ut_resourcebundle_create( 'es', BUNDLE );
+ $str_res .= debug( $r1 );
+ $str_res .= print_r( $r1['teststring'], true)."\n";
+
+ // fall back
+ $r1 = ut_resourcebundle_create( 'en_US', BUNDLE );
+ $str_res .= debug( $r1 );
+ $str_res .= print_r( $r1['testsring'], true);
+
+ // fall out
+ $r2 = ut_resourcebundle_create( 'en_US', BUNDLE, false );
+ $str_res .= debug( $r2 );
+
+ // missing
+ $r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' );
+ $str_res .= debug( $r3 );
+
+ return $str_res;
+}
+
+ include_once( 'ut_common.inc' );
+ ut_run();
+?>
+--EXPECTF--
+ResourceBundle Object
+(
+)
+
+ 0: U_ZERO_ERROR
+Hello World!
+ResourceBundle Object
+(
+)
+
+ 0: U_ZERO_ERROR
+Hola Mundo!
+ResourceBundle Object
+(
+)
+
+ -127: U_USING_DEFAULT_WARNING
+NULL
+ 2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR
+NULL
+ 2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR
diff --git a/ext/intl/tests/resourcebundle_individual.phpt b/ext/intl/tests/resourcebundle_individual.phpt
new file mode 100644
index 0000000..dcbf1f5
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_individual.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test ResourceBundle::get() and length() - existing/missing keys
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ include "resourcebundle.inc";
+
+function ut_main() {
+ $str_res = '';
+ // fall back
+ $r = ut_resourcebundle_create( 'en_US', BUNDLE );
+
+ $str_res .= sprintf( "length: %d\n", ut_resourcebundle_count($r) );
+ $str_res .= sprintf( "teststring: %s\n", ut_resourcebundle_get($r, 'teststring' ) );
+ $str_res .= sprintf( "testint: %d\n", ut_resourcebundle_get($r, 'testint' ) );
+
+ $str_res .= print_r( ut_resourcebundle_get($r, 'testvector' ), true );
+
+ $str_res .= sprintf( "testbin: %s\n", bin2hex(ut_resourcebundle_get( $r,'testbin' )) );
+
+ $r2 = ut_resourcebundle_get($r, 'testtable' );
+ $str_res .= sprintf( "testtable: %d\n", ut_resourcebundle_get($r2, 'major' ) );
+
+ $r2 = ut_resourcebundle_get($r,'testarray' );
+ $str_res .= sprintf( "testarray: %s\n", ut_resourcebundle_get($r2, 2 ) );
+
+ $t = ut_resourcebundle_get( $r, 'nonexisting' );
+ $str_res .= debug( $t );
+
+ return $str_res;
+}
+ include_once( 'ut_common.inc' );
+ ut_run();
+?>
+--EXPECT--
+length: 6
+teststring: Hello World!
+testint: 2
+Array
+(
+ [0] => 1
+ [1] => 2
+ [2] => 3
+ [3] => 4
+ [4] => 5
+ [5] => 6
+ [6] => 7
+ [7] => 8
+ [8] => 9
+ [9] => 0
+)
+testbin: a1b2c3d4e5f67890
+testtable: 3
+testarray: string 3
+NULL
+ 2: Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR
diff --git a/ext/intl/tests/resourcebundle_internal.phpt b/ext/intl/tests/resourcebundle_internal.phpt
new file mode 100644
index 0000000..fe90081
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_internal.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Test ResourceBundle::__construct() with internal ICU bundles
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) || !defined('INTL_ICU_DATA_VERSION') || version_compare(INTL_ICU_DATA_VERSION, '4.4', '<') ) print 'skip'; ?>
+--FILE--
+<?php
+$b = new ResourceBundle('de_DE', 'ICUDATA-region');
+var_dump($b->get('Countries')->get('DE'));
+
+$b = new ResourceBundle('icuver', 'ICUDATA');
+var_dump($b->get('ICUVersion') !== NULL);
+
+$b = new ResourceBundle('supplementalData', 'ICUDATA', false);
+var_dump($b->get('cldrVersion') !== NULL);
+?>
+--EXPECTF--
+string(11) "Deutschland"
+bool(true)
+bool(true)
diff --git a/ext/intl/tests/resourcebundle_iterator.phpt b/ext/intl/tests/resourcebundle_iterator.phpt
new file mode 100644
index 0000000..a10b9de
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_iterator.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Test ResourceBundle iterator
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ include "resourcebundle.inc";
+
+ // fall back
+ $r = new ResourceBundle( 'en_US', BUNDLE );
+
+ foreach ($r as $onekey => $oneval) {
+ echo "Here comes $onekey:\n";
+ switch (gettype($oneval)) {
+ case 'string':
+ echo bin2hex( $oneval ) . "\n";
+ break;
+
+ case 'integer':
+ echo "$oneval\n";
+ break;
+
+ default:
+ print_r( $oneval );
+ }
+ echo "\n";
+ }
+
+ echo "Testarray Contents:\n";
+ $r = $r->get( 'testarray' );
+ foreach ($r as $onekey => $oneval) {
+ echo "$onekey => $oneval\n";
+ }
+?>
+--EXPECTF--
+Here comes testarray:
+ResourceBundle Object
+(
+)
+
+Here comes testbin:
+a1b2c3d4e5f67890
+
+Here comes testint:
+2
+
+Here comes teststring:
+48656c6c6f20576f726c6421
+
+Here comes testtable:
+ResourceBundle Object
+(
+)
+
+Here comes testvector:
+Array
+(
+ [0] => 1
+ [1] => 2
+ [2] => 3
+ [3] => 4
+ [4] => 5
+ [5] => 6
+ [6] => 7
+ [7] => 8
+ [8] => 9
+ [9] => 0
+)
+
+Testarray Contents:
+0 => string 1
+1 => string 2
+2 => string 3
diff --git a/ext/intl/tests/resourcebundle_locales.phpt b/ext/intl/tests/resourcebundle_locales.phpt
new file mode 100644
index 0000000..e14a7e5
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_locales.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test ResourceBundle::getLocales
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+include "resourcebundle.inc";
+
+function ut_main() {
+ $str_res = '';
+
+ $str_res .= join("\n", ut_resourcebundle_locales(BUNDLE));
+
+ return $str_res;
+}
+
+ include_once( 'ut_common.inc' );
+ ut_run();
+?>
+--EXPECT--
+es
+root
diff --git a/ext/intl/tests/resourcebundle_null_mandatory_args.phpt b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt
new file mode 100644
index 0000000..17fab6d
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt
@@ -0,0 +1,28 @@
+--TEST--
+ResourceBundle constructor bundle accepts NULL for first two arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip ICU >= 4.8 only');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$r = new ResourceBundle('en_US', NULL);
+$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0);
+var_dump($c);
+
+ini_set('intl.default_locale', 'pt_PT');
+$r = new ResourceBundle(NULL, NULL);
+$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0);
+var_dump($c);
+?>
+==DONE==
+--EXPECT--
+string(14) "h:mm:ss a zzzz"
+string(12) "H:mm:ss zzzz"
+==DONE==
diff --git a/ext/intl/tests/resourcebundle_traversable.phpt b/ext/intl/tests/resourcebundle_traversable.phpt
new file mode 100644
index 0000000..1e6af7b
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_traversable.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #55610: ResourceBundle does not implement Traversable
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ include "resourcebundle.inc";
+
+ $r = new ResourceBundle( 'es', BUNDLE );
+
+ var_dump($r instanceof Traversable);
+ var_dump(iterator_to_array($r->get('testarray')));
+?>
+--EXPECTF--
+bool(true)
+array(3) {
+ [0]=>
+ string(8) "cadena 1"
+ [1]=>
+ string(8) "cadena 2"
+ [2]=>
+ string(8) "cadena 3"
+}
diff --git a/ext/intl/tests/spoofchecker_001.phpt b/ext/intl/tests/spoofchecker_001.phpt
new file mode 100644
index 0000000..7904b3a
--- /dev/null
+++ b/ext/intl/tests/spoofchecker_001.phpt
@@ -0,0 +1,23 @@
+--TEST--
+spoofchecker suspicious character checker
+--SKIPIF--
+<?php if(!extension_loaded('intl') || !class_exists("Spoofchecker")) print 'skip'; ?>
+--FILE--
+<?php
+
+$url = "http://www.payp\xD0\xB0l.com";
+
+$x = new Spoofchecker();
+echo "paypal with Cyrillic spoof characters\n";
+var_dump($x->isSuspicious($url));
+
+echo "certain all-uppercase Latin sequences can be spoof of Greek\n";
+var_dump($x->isSuspicious("NAPKIN PEZ"));
+var_dump($x->isSuspicious("napkin pez"));
+?>
+--EXPECTF--
+paypal with Cyrillic spoof characters
+bool(true)
+certain all-uppercase Latin sequences can be spoof of Greek
+bool(true)
+bool(false)
diff --git a/ext/intl/tests/spoofchecker_002.phpt b/ext/intl/tests/spoofchecker_002.phpt
new file mode 100644
index 0000000..d570917
--- /dev/null
+++ b/ext/intl/tests/spoofchecker_002.phpt
@@ -0,0 +1,20 @@
+--TEST--
+spoofchecker confusable tests
+--SKIPIF--
+<?php if(!extension_loaded('intl') || !class_exists("Spoofchecker")) print 'skip'; ?>
+--FILE--
+<?php
+
+$url = "http://www.payp\xD0\xB0l.com";
+
+$x = new Spoofchecker();
+echo "Checking if words are confusable\n";
+var_dump($x->areConfusable("hello, world", "goodbye, world"));
+var_dump($x->areConfusable("hello, world", "hello, world"));
+var_dump($x->areConfusable("hello, world", "he11o, wor1d"));
+?>
+--EXPECTF--
+Checking if words are confusable
+bool(false)
+bool(true)
+bool(true)
diff --git a/ext/intl/tests/spoofchecker_003.phpt b/ext/intl/tests/spoofchecker_003.phpt
new file mode 100644
index 0000000..0be9bfa
--- /dev/null
+++ b/ext/intl/tests/spoofchecker_003.phpt
@@ -0,0 +1,25 @@
+--TEST--
+spoofchecker with locale settings
+--SKIPIF--
+<?php if(!extension_loaded('intl') || !class_exists("Spoofchecker")) print 'skip'; ?>
+--FILE--
+<?php
+
+$korean = "\xED\x95\x9C" . "\xEA\xB5\xAD" . "\xEB\xA7\x90";
+
+$x = new Spoofchecker();
+echo "Is suspcious, en_US\n";
+
+$x->setAllowedLocales('en_US');
+var_dump($x->isSuspicious($korean));
+
+echo "Is suspcious, ko_KR\n";
+
+$x->setAllowedLocales('en_US, ko_KR');
+var_dump($x->isSuspicious($korean));
+?>
+--EXPECTF--
+Is suspcious, en_US
+bool(true)
+Is suspcious, ko_KR
+bool(false)
diff --git a/ext/intl/tests/spoofchecker_004.phpt b/ext/intl/tests/spoofchecker_004.phpt
new file mode 100644
index 0000000..b38c61d
--- /dev/null
+++ b/ext/intl/tests/spoofchecker_004.phpt
@@ -0,0 +1,28 @@
+--TEST--
+spoofchecker with settings changed
+--SKIPIF--
+<?php if(!extension_loaded('intl') || !class_exists("Spoofchecker")) print 'skip'; ?>
+--FILE--
+<?php
+
+$korean = "\xED\x95\x9C" . "\xEA\xB5\xAD" . "\xEB\xA7\x90";
+
+$x = new Spoofchecker();
+echo "Check with default settings\n";
+var_dump($x->areConfusable("HELLO", "H\xD0\x95LLO"));
+var_dump($x->areConfusable("hello", "h\xD0\xB5llo"));
+
+echo "Change confusable settings\n";
+$x->setChecks(Spoofchecker::MIXED_SCRIPT_CONFUSABLE |
+ Spoofchecker::WHOLE_SCRIPT_CONFUSABLE |
+ Spoofchecker::SINGLE_SCRIPT_CONFUSABLE);
+var_dump($x->areConfusable("HELLO", "H\xD0\x95LLO"));
+var_dump($x->areConfusable("hello", "h\xD0\xB5llo"));
+?>
+--EXPECTF--
+Check with default settings
+bool(true)
+bool(true)
+Change confusable settings
+bool(false)
+bool(true)
diff --git a/ext/intl/tests/symfony_format_type_double_intl1.phpt b/ext/intl/tests/symfony_format_type_double_intl1.phpt
new file mode 100644
index 0000000..13a7ad7
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_double_intl1.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #1
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeDoubleIntl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:1:"1";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeDoubleIntl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ int(1)
+ [2]=>
+ string(1) "1"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_double_intl2.phpt b/ext/intl/tests/symfony_format_type_double_intl2.phpt
new file mode 100644
index 0000000..6bff7cc
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_double_intl2.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #2
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeDoubleIntl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:3:"1.1";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeDoubleIntl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(1.1)
+ [2]=>
+ string(3) "1.1"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_double_intl3.phpt b/ext/intl/tests/symfony_format_type_double_intl3.phpt
new file mode 100644
index 0000000..3b0d576
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_double_intl3.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #3
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeDoubleIntl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:7:"SFD1.00";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeDoubleIntl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ int(1)
+ [2]=>
+ string(7) "SFD1.00"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_double_intl4.phpt b/ext/intl/tests/symfony_format_type_double_intl4.phpt
new file mode 100644
index 0000000..3476e10
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_double_intl4.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #4
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeDoubleIntl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:7:"SFD1.10";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeDoubleIntl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(1.1)
+ [2]=>
+ string(7) "SFD1.10"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int32_intl1.phpt b/ext/intl/tests/symfony_format_type_int32_intl1.phpt
new file mode 100644
index 0000000..2867b35
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int32_intl1.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #1
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+// port of Symfony's Symfony\Component\Locale\Tests\Stub\StubNumberFormatterTest#testFormatTypeInt32Intl
+
+
+// Crashes on Windows
+// Windows note: the popup '...program has stopped working'(AEDebug Popup)
+// doesn't always show if you're rapidly running this test repeatedly.
+// regardless of that, the test always crashes every time.
+// (it will show up the first time, or if you wait a while before running it again.)
+// (the popup may also be disabled, which can be done with a registry setting.)
+// you can confirm it crashed by checking the exit code OR
+// the message this test prints at the very end (expected output for pass).
+//
+// Get Exit Code
+// Linux: echo $?
+// Windows: echo %ErrorLevel%
+
+
+
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:1:"1";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt32Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ int(1)
+ [2]=>
+ string(1) "1"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int32_intl2.phpt b/ext/intl/tests/symfony_format_type_int32_intl2.phpt
new file mode 100644
index 0000000..6a65a0a
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int32_intl2.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #2
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+// StubNumberFormatterTest#testFormatTypeInt32Intl is tested many times, each with different args.
+// there are 7 sets of args that crash PHP (and other args that don't), each of those 7 is now a separate PHPT test
+// to ensure that each of the 7 args are always tested.
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:1:"1";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt32Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(1.1)
+ [2]=>
+ string(1) "1"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int32_intl3.phpt b/ext/intl/tests/symfony_format_type_int32_intl3.phpt
new file mode 100644
index 0000000..5e657db
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int32_intl3.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #3
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
+$unit_test_args = unserialize('a:4:{i:0;O:15:"NumberFormatter":0:{}i:1;d:2147483648;i:2;s:14:"-2,147,483,648";i:3;s:83:"->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt32Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(4) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(2147483648)
+ [2]=>
+ string(14) "-2,147,483,648"
+ [3]=>
+ string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range."
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int32_intl4.phpt b/ext/intl/tests/symfony_format_type_int32_intl4.phpt
new file mode 100644
index 0000000..54043d9
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int32_intl4.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #4
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:7:"SFD1.00";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt32Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ int(1)
+ [2]=>
+ string(7) "SFD1.00"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int32_intl5.phpt b/ext/intl/tests/symfony_format_type_int32_intl5.phpt
new file mode 100644
index 0000000..d5f78d7
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int32_intl5.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #5
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:7:"SFD1.00";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt32Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(1.1)
+ [2]=>
+ string(7) "SFD1.00"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int32_intl6.phpt b/ext/intl/tests/symfony_format_type_int32_intl6.phpt
new file mode 100644
index 0000000..fa70879
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int32_intl6.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #6
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
+$unit_test_args = unserialize('a:4:{i:0;O:15:"NumberFormatter":0:{}i:1;d:2147483648;i:2;s:21:"(SFD2,147,483,648.00)";i:3;s:83:"->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt32Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(4) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(2147483648)
+ [2]=>
+ string(21) "(SFD2,147,483,648.00)"
+ [3]=>
+ string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range."
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int32_intl7.phpt b/ext/intl/tests/symfony_format_type_int32_intl7.phpt
new file mode 100644
index 0000000..5bbe426
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int32_intl7.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #7
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
+$unit_test_args = unserialize('a:4:{i:0;O:15:"NumberFormatter":0:{}i:1;d:-2147483649;i:2;s:19:"SFD2,147,483,647.00";i:3;s:83:"->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt32Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(4) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(-2147483649)
+ [2]=>
+ string(19) "SFD2,147,483,647.00"
+ [3]=>
+ string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range."
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int64_intl1.phpt b/ext/intl/tests/symfony_format_type_int64_intl1.phpt
new file mode 100644
index 0000000..01f5820
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int64_intl1.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #1
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:1:"1";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt64Intl
+//$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ int(1)
+ [2]=>
+ string(1) "1"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int64_intl2.phpt b/ext/intl/tests/symfony_format_type_int64_intl2.phpt
new file mode 100644
index 0000000..13d1cda
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int64_intl2.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #2
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:1:"1";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt64Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(1.1)
+ [2]=>
+ string(1) "1"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int64_intl3.phpt b/ext/intl/tests/symfony_format_type_int64_intl3.phpt
new file mode 100644
index 0000000..a7c80b3
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int64_intl3.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #3
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:2147483648;i:2;s:13:"2,147,483,648";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt64Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(2147483648)
+ [2]=>
+ string(13) "2,147,483,648"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int64_intl4.phpt b/ext/intl/tests/symfony_format_type_int64_intl4.phpt
new file mode 100644
index 0000000..f1a0801
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int64_intl4.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #4
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:-2147483649;i:2;s:14:"-2,147,483,649";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt64Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(-2147483649)
+ [2]=>
+ string(14) "-2,147,483,649"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int64_intl5.phpt b/ext/intl/tests/symfony_format_type_int64_intl5.phpt
new file mode 100644
index 0000000..dad8735
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int64_intl5.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #5
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:7:"SFD1.00";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt64Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ int(1)
+ [2]=>
+ string(7) "SFD1.00"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int64_intl6.phpt b/ext/intl/tests/symfony_format_type_int64_intl6.phpt
new file mode 100644
index 0000000..f038cbd
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int64_intl6.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #6
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:7:"SFD1.00";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt64Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(1.1)
+ [2]=>
+ string(7) "SFD1.00"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int64_intl7.phpt b/ext/intl/tests/symfony_format_type_int64_intl7.phpt
new file mode 100644
index 0000000..9c8853c
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int64_intl7.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #7
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:2147483648;i:2;s:19:"SFD2,147,483,648.00";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt64Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(2147483648)
+ [2]=>
+ string(19) "SFD2,147,483,648.00"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/symfony_format_type_int64_intl8.phpt b/ext/intl/tests/symfony_format_type_int64_intl8.phpt
new file mode 100644
index 0000000..5052497
--- /dev/null
+++ b/ext/intl/tests/symfony_format_type_int64_intl8.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #8
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+
+// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl
+$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:-2147483649;i:2;s:21:"(SFD2,147,483,649.00)";}');
+
+var_dump($unit_test_args);
+
+// execute the code from #testFormatTypeInt64Intl
+$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64);
+
+echo "== didn't crash ==".PHP_EOL;
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ object(NumberFormatter)#1 (0) {
+ }
+ [1]=>
+ float(-2147483649)
+ [2]=>
+ string(21) "(SFD2,147,483,649.00)"
+}
+== didn't crash ==
diff --git a/ext/intl/tests/transliterator_clone.phpt b/ext/intl/tests/transliterator_clone.phpt
new file mode 100644
index 0000000..23d569b
--- /dev/null
+++ b/ext/intl/tests/transliterator_clone.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Transliterator clone handler
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$str = "a U+4E07";
+
+$t = Transliterator::create("hex-any");
+echo $t->id, ": ", $t->transliterate($str), "\n";
+
+$u = clone $t;
+echo $u->id, ": ", $u->transliterate($str), "\n";
+
+echo "Done.\n";
+
+--EXPECT--
+hex-any: a 万
+hex-any: a 万
+Done.
diff --git a/ext/intl/tests/transliterator_create_basic.phpt b/ext/intl/tests/transliterator_create_basic.phpt
new file mode 100644
index 0000000..4de032d
--- /dev/null
+++ b/ext/intl/tests/transliterator_create_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Transliterator::create (basic)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$t = Transliterator::create("any-latin");
+echo $t->id,"\n";
+
+$t = transliterator_create("any-latin");
+echo $t->id,"\n";
+
+echo "Done.\n";
+
+--EXPECT--
+any-latin
+any-latin
+Done.
+
diff --git a/ext/intl/tests/transliterator_create_error.phpt b/ext/intl/tests/transliterator_create_error.phpt
new file mode 100644
index 0000000..31aef68
--- /dev/null
+++ b/ext/intl/tests/transliterator_create_error.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Transliterator::create (error)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+ini_set("intl.error_level", E_WARNING);
+Transliterator::create("inexistant id");
+echo intl_get_error_message(), "\n";
+Transliterator::create("bad UTF-8 \x8F");
+echo intl_get_error_message(), "\n";
+
+echo "Done.\n";
+--EXPECTF--
+Warning: Transliterator::create(): transliterator_create: unable to open ICU transliterator with id "inexistant id" in %s on line %d
+transliterator_create: unable to open ICU transliterator with id "inexistant id": U_INVALID_ID
+
+Warning: Transliterator::create(): String conversion of id to UTF-16 failed in %s on line %d
+String conversion of id to UTF-16 failed: U_INVALID_CHAR_FOUND
+Done.
diff --git a/ext/intl/tests/transliterator_create_from_rule_basic.phpt b/ext/intl/tests/transliterator_create_from_rule_basic.phpt
new file mode 100644
index 0000000..eb8d5da
--- /dev/null
+++ b/ext/intl/tests/transliterator_create_from_rule_basic.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Transliterator::createFromRules (basic)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$rules = <<<RULES
+α <> y;
+\`\` } a > “;
+RULES;
+
+$t = Transliterator::createFromRules($rules);
+echo $t->id,"\n";
+
+echo $t->transliterate("``akk ``bkk ``aooy"),"\n";
+
+$u = transliterator_create_from_rules($rules, Transliterator::REVERSE);
+
+echo $u->transliterate("``akk ``bkk ``aooy"), "\n";
+
+echo "Done.\n";
+--EXPECT--
+RulesTransPHP
+“akk ``bkk “aooy
+``akk ``bkk ``aooα
+Done.
diff --git a/ext/intl/tests/transliterator_create_from_rule_error.phpt b/ext/intl/tests/transliterator_create_from_rule_error.phpt
new file mode 100644
index 0000000..cad73ab
--- /dev/null
+++ b/ext/intl/tests/transliterator_create_from_rule_error.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Transliterator::createFromRules (error)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$t = Transliterator::createFromRules();
+echo intl_get_error_message(),"\n";
+
+$t = Transliterator::createFromRules("a","b");
+echo intl_get_error_message(),"\n";
+
+$t = Transliterator::createFromRules("\x8Fss");
+echo intl_get_error_message(),"\n";
+
+$rules = <<<RULES
+\`\` } a > “;
+\`\` } a > b;
+RULES;
+
+$t = Transliterator::createFromRules($rules);
+echo intl_get_error_message(),"\n";
+
+$rules = <<<RULES
+ffff
+RULES;
+
+$t = Transliterator::createFromRules($rules);
+echo intl_get_error_message(),"\n";
+echo "Done.\n";
+
+--EXPECTF--
+Warning: Transliterator::createFromRules() expects at least 1 parameter, 0 given in %s on line %d
+
+Warning: Transliterator::createFromRules(): transliterator_create_from_rules: bad arguments in %s on line %d
+transliterator_create_from_rules: bad arguments: U_ILLEGAL_ARGUMENT_ERROR
+
+Warning: Transliterator::createFromRules() expects parameter 2 to be long, string given in %s on line %d
+
+Warning: Transliterator::createFromRules(): transliterator_create_from_rules: bad arguments in %s on line %d
+transliterator_create_from_rules: bad arguments: U_ILLEGAL_ARGUMENT_ERROR
+
+Warning: Transliterator::createFromRules(): String conversion of rules to UTF-16 failed in %s on line %d
+String conversion of rules to UTF-16 failed: U_INVALID_CHAR_FOUND
+
+Warning: Transliterator::createFromRules(): transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error after "{'``'}a > “;", before or at "{'``'}a > b;") in %s on line %d
+transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error after "{'``'}a > “;", before or at "{'``'}a > b;"): U_RULE_MASK_ERROR
+
+Warning: Transliterator::createFromRules(): transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error at offset 0, before or at "ffff") in %s on line %d
+transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error at offset 0, before or at "ffff"): U_MISSING_OPERATOR
+Done.
diff --git a/ext/intl/tests/transliterator_create_inverse_basic.phpt b/ext/intl/tests/transliterator_create_inverse_basic.phpt
new file mode 100644
index 0000000..3241403
--- /dev/null
+++ b/ext/intl/tests/transliterator_create_inverse_basic.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Transliterator::createInverse (basic)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+ini_set("intl.error_level", E_WARNING);
+
+$tr = Transliterator::create("Katakana-Latin");
+$orstr = "オーシャンビュー";
+$new_str = $tr->transliterate($orstr);
+
+$revtr = $tr->createInverse();
+$recovstr = $revtr->transliterate($new_str);
+
+$revtr2 = transliterator_create_inverse($tr);
+$recovstr2 = $revtr2->transliterate($new_str);
+
+echo $orstr,"\n";
+echo $new_str,"\n";
+echo $recovstr,"\n";
+
+var_dump(($orstr == $recovstr) == $recovstr2);
+
+echo "Done.\n";
+--EXPECT--
+オーシャンビュー
+ōshanbyū
+オーシャンビュー
+bool(true)
+Done.
diff --git a/ext/intl/tests/transliterator_create_inverse_error.phpt b/ext/intl/tests/transliterator_create_inverse_error.phpt
new file mode 100644
index 0000000..92141c9
--- /dev/null
+++ b/ext/intl/tests/transliterator_create_inverse_error.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Transliterator::createInverse (error)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+ini_set("intl.error_level", E_WARNING);
+
+$tr = Transliterator::create("Katakana-Latin");
+$tr->createInverse(array());
+
+$tr = Transliterator::create("Katakana-Latin");
+transliterator_create_inverse("jj");
+
+--EXPECTF--
+Warning: Transliterator::createInverse() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: Transliterator::createInverse(): transliterator_create_inverse: bad arguments in %s on line %d
+
+Catchable fatal error: Argument 1 passed to transliterator_create_inverse() must be an instance of Transliterator, string given in %s on line %d
diff --git a/ext/intl/tests/transliterator_get_error_code_basic.phpt b/ext/intl/tests/transliterator_get_error_code_basic.phpt
new file mode 100644
index 0000000..3d16a8a
--- /dev/null
+++ b/ext/intl/tests/transliterator_get_error_code_basic.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Transliterator::getErrorCode (basic)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$t = Transliterator::create("[\p{Bidi_Mirrored}] Hex");
+var_dump($t->transliterate("\x8F"));
+echo transliterator_get_error_code($t), "\n";
+
+echo $t->getErrorCode(), "\n";
+
+var_dump($t->transliterate(""));
+echo $t->getErrorCode(), "\n";
+
+echo "Done.\n";
+--EXPECTF--
+Warning: Transliterator::transliterate(): String conversion of string to UTF-16 failed in %s on line %d
+bool(false)
+10
+10
+string(0) ""
+0
+Done.
diff --git a/ext/intl/tests/transliterator_get_error_code_error.phpt b/ext/intl/tests/transliterator_get_error_code_error.phpt
new file mode 100644
index 0000000..94daa12
--- /dev/null
+++ b/ext/intl/tests/transliterator_get_error_code_error.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Transliterator::getErrorCode (error)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$t = Transliterator::create("[\p{Bidi_Mirrored}] Hex");
+echo transliterator_get_error_code(), "\n";
+echo $t->getErrorCode(null), "\n";
+echo transliterator_get_error_code(array()), "\n";
+
+--EXPECTF--
+Warning: transliterator_get_error_code() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: transliterator_get_error_code(): transliterator_get_error_code: unable to parse input params in %s on line %d
+
+
+Warning: Transliterator::getErrorCode() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: Transliterator::getErrorCode(): transliterator_get_error_code: unable to parse input params in %s on line %d
+
+
+Catchable fatal error: Argument 1 passed to transliterator_get_error_code() must be an instance of Transliterator, array given in %s on line %d
diff --git a/ext/intl/tests/transliterator_get_error_message_basic.phpt b/ext/intl/tests/transliterator_get_error_message_basic.phpt
new file mode 100644
index 0000000..4e91853
--- /dev/null
+++ b/ext/intl/tests/transliterator_get_error_message_basic.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Transliterator::getErrorMessage (basic)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$t = Transliterator::create("[\p{Bidi_Mirrored}] Hex");
+var_dump($t->transliterate("\x8F"));
+echo transliterator_get_error_message($t), "\n";
+
+echo $t->getErrorMessage(), "\n";
+
+var_dump($t->transliterate(""));
+echo $t->getErrorMessage(), "\n";
+
+echo "Done.\n";
+--EXPECTF--
+Warning: Transliterator::transliterate(): String conversion of string to UTF-16 failed in %s on line %d
+bool(false)
+String conversion of string to UTF-16 failed: U_INVALID_CHAR_FOUND
+String conversion of string to UTF-16 failed: U_INVALID_CHAR_FOUND
+string(0) ""
+U_ZERO_ERROR
+Done.
diff --git a/ext/intl/tests/transliterator_get_error_message_error.phpt b/ext/intl/tests/transliterator_get_error_message_error.phpt
new file mode 100644
index 0000000..4ab2104
--- /dev/null
+++ b/ext/intl/tests/transliterator_get_error_message_error.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Transliterator::getErrorMessage (error)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$t = Transliterator::create("[\p{Bidi_Mirrored}] Hex");
+echo transliterator_get_error_message(), "\n";
+echo $t->getErrorMessage(null), "\n";
+echo transliterator_get_error_message(array()), "\n";
+
+--EXPECTF--
+Warning: transliterator_get_error_message() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: transliterator_get_error_message(): transliterator_get_error_message: unable to parse input params in %s on line %d
+
+
+Warning: Transliterator::getErrorMessage() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: Transliterator::getErrorMessage(): transliterator_get_error_message: unable to parse input params in %s on line %d
+
+
+Catchable fatal error: Argument 1 passed to transliterator_get_error_message() must be an instance of Transliterator, array given in %s on line %d
diff --git a/ext/intl/tests/transliterator_list_ids_basic.phpt b/ext/intl/tests/transliterator_list_ids_basic.phpt
new file mode 100644
index 0000000..af65b58
--- /dev/null
+++ b/ext/intl/tests/transliterator_list_ids_basic.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Transliterator::listIDs (basic)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+ini_set("intl.error_level", E_WARNING);
+var_dump(count(transliterator_list_ids()) > 100);
+var_dump(count(Transliterator::listIDs()) > 100);
+
+echo "Done.\n";
+--EXPECT--
+bool(true)
+bool(true)
+Done.
diff --git a/ext/intl/tests/transliterator_list_ids_error.phpt b/ext/intl/tests/transliterator_list_ids_error.phpt
new file mode 100644
index 0000000..d1066a8
--- /dev/null
+++ b/ext/intl/tests/transliterator_list_ids_error.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Transliterator::listIDs (error)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+ini_set("intl.error_level", E_WARNING);
+var_dump(transliterator_list_ids(array()));
+
+echo "Done.\n";
+
+--EXPECTF--
+Warning: transliterator_list_ids() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: transliterator_list_ids(): transliterator_list_ids: bad arguments in %s on line %d
+bool(false)
+Done.
diff --git a/ext/intl/tests/transliterator_property_id.phpt b/ext/intl/tests/transliterator_property_id.phpt
new file mode 100644
index 0000000..b5337b6
--- /dev/null
+++ b/ext/intl/tests/transliterator_property_id.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Transliterator - "id" property
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+$tr = Transliterator::create("Katakana-Latin");
+echo $tr->id, "\n";
+$revtr = $tr->createInverse();
+echo $revtr->id, "\n";
+var_dump($revtr);
+
+echo "Done.\n";
+--EXPECTF--
+Katakana-Latin
+Latin-Katakana
+object(Transliterator)#%d (%d) {
+ ["id"]=>
+ string(%d) "Latin-Katakana"
+}
+Done.
diff --git a/ext/intl/tests/transliterator_transliterate_basic.phpt b/ext/intl/tests/transliterator_transliterate_basic.phpt
new file mode 100644
index 0000000..f117834
--- /dev/null
+++ b/ext/intl/tests/transliterator_transliterate_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Transliterator::transliterate (basic)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+$t = transliterator_create("Latin; Title");
+$s = "Κοντογιαννάτος, Βασίλης";
+echo $t->transliterate($s),"\n";
+echo transliterator_transliterate($t, $s),"\n";
+echo $t->transliterate($s, 3),"\n";
+echo $t->transliterate($s, 3, 4),"\n";
+
+echo "Done.\n";
+--EXPECT--
+Kontogiannátos, Basílēs
+Kontogiannátos, Basílēs
+ΚονTogiannátos, Basílēs
+ΚονTογιαννάτος, Βασίλης
+Done.
diff --git a/ext/intl/tests/transliterator_transliterate_error.phpt b/ext/intl/tests/transliterator_transliterate_error.phpt
new file mode 100644
index 0000000..cdddcfb
--- /dev/null
+++ b/ext/intl/tests/transliterator_transliterate_error.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Transliterator::transliterate (error)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+ini_set("intl.error_level", E_WARNING);
+
+$tr = Transliterator::create("latin");
+
+//Arguments
+var_dump(transliterator_transliterate());
+var_dump(transliterator_transliterate($tr,array()));
+var_dump(transliterator_transliterate($tr,"str",7));
+var_dump(transliterator_transliterate($tr,"str",7,6));
+var_dump(transliterator_transliterate($tr,"str",2,-1,"extra"));
+
+//Arguments
+var_dump($tr->transliterate());
+var_dump($tr->transliterate(array()));
+
+//bad UTF-8
+transliterator_transliterate($tr, "\x80\x03");
+
+echo "Done.\n";
+--EXPECTF--
+Warning: transliterator_transliterate() expects at least 2 parameters, 0 given in %s on line %d
+
+Warning: transliterator_transliterate(): transliterator_transliterate: bad arguments in %s on line %d
+bool(false)
+
+Warning: transliterator_transliterate() expects parameter 2 to be string, array given in %s on line %d
+
+Warning: transliterator_transliterate(): transliterator_transliterate: bad arguments in %s on line %d
+bool(false)
+
+Warning: transliterator_transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 3) in %s on line %d
+bool(false)
+
+Warning: transliterator_transliterate(): transliterator_transliterate: "start" argument should be non-negative and not bigger than "end" (if defined) in %s on line %d
+bool(false)
+
+Warning: transliterator_transliterate() expects at most 4 parameters, 5 given in %s on line %d
+
+Warning: transliterator_transliterate(): transliterator_transliterate: bad arguments in %s on line %d
+bool(false)
+
+Warning: Transliterator::transliterate() expects at least 1 parameter, 0 given in %s on line %d
+
+Warning: Transliterator::transliterate(): transliterator_transliterate: bad arguments in %s on line %d
+bool(false)
+
+Warning: Transliterator::transliterate() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: Transliterator::transliterate(): transliterator_transliterate: bad arguments in %s on line %d
+bool(false)
+
+Warning: transliterator_transliterate(): String conversion of string to UTF-16 failed in %s on line %d
+Done.
diff --git a/ext/intl/tests/transliterator_transliterate_variant1.phpt b/ext/intl/tests/transliterator_transliterate_variant1.phpt
new file mode 100644
index 0000000..fc77a4e
--- /dev/null
+++ b/ext/intl/tests/transliterator_transliterate_variant1.phpt
@@ -0,0 +1,37 @@
+--TEST--
+transliterator_transliterate (variant 1, non-transliterator 1st arg)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+//exec('pause');
+$str = " o";
+echo transliterator_transliterate("[\p{White_Space}] hex", $str), "\n";
+
+echo transliterator_transliterate("\x8F", $str), "\n";
+echo intl_get_error_message(), "\n";
+
+class A {
+function __toString() { return "inexistant id"; }
+}
+
+echo transliterator_transliterate(new A(), $str), "\n";
+echo intl_get_error_message(), "\n";
+
+echo "Done.\n";
+--EXPECTF--
+\u0020o
+
+Warning: transliterator_transliterate(): String conversion of id to UTF-16 failed in %s on line %d
+
+Warning: transliterator_transliterate(): Could not create transliterator with ID %s
+
+String conversion of id to UTF-16 failed: U_INVALID_CHAR_FOUND
+
+Warning: transliterator_transliterate(): transliterator_create: unable to open ICU transliterator with id "inexistant id" in %s on line %d
+
+Warning: transliterator_transliterate(): Could not create transliterator with ID "inexistant id" (transliterator_create: unable to open ICU transliterator with id "inexistant id": U_INVALID_ID) in %s on line %d
+
+transliterator_create: unable to open ICU transliterator with id "inexistant id": U_INVALID_ID
+Done.
diff --git a/ext/intl/tests/ut_common.inc b/ext/intl/tests/ut_common.inc
new file mode 100644
index 0000000..09be22b
--- /dev/null
+++ b/ext/intl/tests/ut_common.inc
@@ -0,0 +1,416 @@
+<?php
+/*
+ * Run unit test in OO- and in procedural mode.
+ * Then compare the outputs.
+ * It they're equal then show one of them.
+ * Otherwise indicate an error.
+ */
+function ut_run()
+{
+ // Run unit test in OO mode.
+ $GLOBALS['oo-mode'] = true;
+ $oo_result = ut_main();
+
+ // Run unit test in procedural mode.
+ $GLOBALS['oo-mode'] = false;
+ $proc_result = ut_main();
+
+ // Show error if the APIs produce different results.
+ if( $proc_result !== $oo_result )
+ {
+ echo "ERROR: OO- and procedural APIs produce different results!\n";
+ echo "OO API output:\n";
+ echo str_repeat( '=', 78 ) . "\n";
+ echo $oo_result;
+ echo str_repeat( '=', 78 ) . "\n";
+ echo "procedural API output:\n";
+ echo str_repeat( '=', 78 ) . "\n";
+ echo $proc_result;
+ echo str_repeat( '=', 78 ) . "\n";
+ return;
+ }
+
+ // Else, if the results are equal, show one of them.
+ echo $proc_result;
+}
+
+function dump( $val )
+{
+ return var_export( $val, true );
+}
+
+/*
+ * Wrappers around Collator methods to run them in either OO- or procedural mode.
+ */
+
+function ut_coll_create( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Collator::create( $locale ) : collator_create( $locale );
+}
+function ut_coll_compare( $coll, $str1, $str2 )
+{
+ return $GLOBALS['oo-mode'] ? $coll->compare( $str1, $str2 ) : collator_compare( $coll, $str1, $str2 );
+}
+function ut_coll_sort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR )
+{
+ return $GLOBALS['oo-mode'] ? $coll->sort( $arr, $sort_flag ) : collator_sort( $coll, $arr, $sort_flag );
+}
+function ut_coll_sort_with_sort_keys( $coll, &$arr )
+{
+ return $GLOBALS['oo-mode'] ? $coll->sortWithSortKeys( $arr ) : collator_sort_with_sort_keys( $coll, $arr );
+}
+function ut_coll_get_sort_key( $coll, $str )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getSortKey( $str ) : collator_get_sort_key( $coll, $str );
+}
+function ut_coll_asort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR )
+{
+ return $GLOBALS['oo-mode'] ? $coll->asort( $arr, $sort_flag ) : collator_asort( $coll, $arr, $sort_flag );
+}
+function ut_coll_get_locale( $coll, $type )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getLocale( $type ) : collator_get_locale( $coll, $type );
+}
+function ut_coll_get_display_name( $obj_loc, $disp_loc )
+{
+ return $GLOBALS['oo-mode'] ? Collator::getDisplayName( $obj_loc, $disp_loc ) : collator_get_display_name( $obj_loc, $disp_loc );
+}
+function ut_coll_get_available_locales()
+{
+ return $GLOBALS['oo-mode'] ? Collator::getAvailableLocales() : collator_get_available_locales();
+}
+function ut_coll_get_attribute( $coll, $attr )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getAttribute( $attr ) : collator_get_attribute( $coll, $attr );
+}
+function ut_coll_get_strength( $coll )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getStrength() : collator_get_strength( $coll );
+}
+function ut_coll_set_strength( $coll, $strength )
+{
+ return $GLOBALS['oo-mode'] ? $coll->setStrength( $strength ) : collator_set_strength( $coll, $strength );
+}
+function ut_coll_set_attribute( $coll, $attr, $val )
+{
+ return $GLOBALS['oo-mode'] ? $coll->setAttribute( $attr, $val ) : collator_set_attribute( $coll, $attr, $val );
+}
+function ut_coll_get_variable_top( $coll )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getVariableTop() : collator_get_variable_top( $coll );
+}
+function ut_coll_set_variable_top( $coll, $var_top )
+{
+ return $GLOBALS['oo-mode'] ? $coll->setVariableTop( $var_top ) : collator_set_variable_top( $coll, $var_top );
+}
+function ut_coll_restore_variable_top( $coll, $var_top )
+{
+ return $GLOBALS['oo-mode'] ? $coll->restoreVariableTop( $var_top ) : collator_restore_variable_top( $coll, $var_top );
+}
+function ut_coll_get_error_code( $coll )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getErrorCode() : collator_get_error_code( $coll );
+}
+function ut_coll_get_error_message( $coll )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getErrorMessage() : collator_get_error_message( $coll );
+}
+function ut_coll_get_default()
+{
+ return $GLOBALS['oo-mode'] ? Collator::getDefault() : collator_get_default();
+}
+function ut_coll_set_default( $coll )
+{
+ return $GLOBALS['oo-mode'] ? Collator::setDefault( $coll ) : collator_set_default( $coll );
+}
+
+/*
+ * Wrappers around NumberFormatter methods to run them in either OO- or procedural mode.
+ */
+
+// FIXME: incomplete list
+
+function ut_nfmt_create( $locale, $style, $pattern = null )
+{
+ return $GLOBALS['oo-mode'] ? new NumberFormatter( $locale, $style, $pattern ) : numfmt_create( $locale, $style, $pattern );
+}
+function ut_nfmt_format( $fmt, $number, $type = null )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->format( $number, $type ) : numfmt_format( $fmt, $number, $type );
+}
+function ut_nfmt_parse( $fmt, $string, $type = NumberFormatter::TYPE_DOUBLE, &$position = null )
+{
+ if(is_null($position)) {
+ return $GLOBALS['oo-mode'] ? $fmt->parse( $string, $type ) : numfmt_parse( $fmt, $string, $type );
+ } else {
+ return $GLOBALS['oo-mode'] ? $fmt->parse( $string, $type, $position ) : numfmt_parse( $fmt, $string, $type, $position );
+ }
+}
+function ut_nfmt_format_currency( $fmt, $number, $currency )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->formatCurrency( $number, $currency ) : numfmt_format_currency( $fmt, $number, $currency );
+}
+function ut_nfmt_parse_currency( $fmt, $string, &$currency, &$position = null )
+{
+ if(is_null($position)) {
+ return $GLOBALS['oo-mode'] ? $fmt->parseCurrency( $string, $currency ) : numfmt_parse_currency( $fmt, $string, $currency );
+ } else {
+ return $GLOBALS['oo-mode'] ? $fmt->parseCurrency( $string, $currency, $position ) : numfmt_parse_currency( $fmt, $string, $currency, $position );
+ }
+}
+function ut_nfmt_set_attribute( $fmt, $attribute, $value )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setAttribute( $attribute, $value ) : numfmt_set_attribute( $fmt, $attribute, $value );
+}
+function ut_nfmt_set_text_attribute( $fmt, $attribute, $value )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setTextAttribute( $attribute, $value ) : numfmt_set_text_attribute( $fmt, $attribute, $value );
+}
+function ut_nfmt_set_symbol( $fmt, $attribute, $value )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setSymbol( $attribute, $value ) : numfmt_set_symbol( $fmt, $attribute, $value );
+}
+function ut_nfmt_set_pattern( $fmt, $pattern )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : numfmt_set_pattern( $fmt, $pattern );
+}
+function ut_nfmt_get_attribute( $fmt, $attribute )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getAttribute( $attribute ) : numfmt_get_attribute( $fmt, $attribute );
+}
+function ut_nfmt_get_text_attribute( $fmt, $attribute )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getTextAttribute( $attribute ) : numfmt_get_text_attribute( $fmt, $attribute );
+}
+function ut_nfmt_get_symbol( $fmt, $attribute )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getSymbol( $attribute ) : numfmt_get_symbol( $fmt, $attribute );
+}
+function ut_nfmt_get_pattern( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getPattern() : numfmt_get_pattern( $fmt );
+}
+function ut_nfmt_get_locale( $fmt, $type = 0 )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getLocale( $type ) : numfmt_get_locale( $fmt, $type );
+}
+function ut_nfmt_get_error_code( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getErrorCode() : numfmt_get_error_code( $fmt );
+}
+function ut_nfmt_get_error_message( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getErrorMessage() : numfmt_get_error_message( $fmt );
+}
+
+function ut_norm_normalize( $str, $form )
+{
+ return $GLOBALS['oo-mode'] ? Normalizer::normalize( $str, $form ) : normalizer_normalize( $str, $form );
+}
+function ut_norm_is_normalized( $str, $form )
+{
+ return $GLOBALS['oo-mode'] ? Normalizer::isNormalized( $str, $form ) : normalizer_is_normalized( $str, $form );
+}
+
+/*
+ * Wrappers around Collator methods to run them in either OO- or procedural mode.
+ */
+
+function ut_loc_get_default( )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDefault( ) : locale_get_default();
+}
+function ut_loc_set_default( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::setDefault( $locale ) : locale_set_default( $locale );
+}
+function ut_loc_get_primary_language( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getPrimaryLanguage( $locale ) : locale_get_primary_language( $locale );
+}
+function ut_loc_get_script( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getScript( $locale ) : locale_get_script( $locale );
+}
+function ut_loc_get_region( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getRegion( $locale ) : locale_get_region( $locale );
+}
+function ut_loc_get_keywords( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getKeywords( $locale ) : locale_get_keywords( $locale );
+}
+function ut_loc_get_display_name( $locale , $dispLocale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDisplayName( $locale , $dispLocale ) : locale_get_display_name( $locale , $dispLocale );
+}
+function ut_loc_get_display_language( $locale , $dispLocale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDisplayLanguage( $locale , $dispLocale ) : locale_get_display_language( $locale , $dispLocale );
+}
+function ut_loc_get_display_script( $locale , $dispLocale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDisplayScript( $locale , $dispLocale ) : locale_get_display_script( $locale , $dispLocale );
+}
+function ut_loc_get_display_region( $locale, $dispLocale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDisplayRegion( $locale, $dispLocale ) : locale_get_display_region( $locale, $dispLocale );
+}
+function ut_loc_get_display_variant( $locale , $dispLocale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDisplayVariant( $locale , $dispLocale ) : locale_get_display_variant( $locale, $dispLocale );
+}
+function ut_loc_locale_compose( $loc_parts_arr )
+{
+ return $GLOBALS['oo-mode'] ? Locale::composeLocale( $loc_parts_arr ) : locale_compose( $loc_parts_arr );
+}
+function ut_loc_locale_parse( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::parseLocale( $locale ) : locale_parse($locale );
+}
+function ut_loc_locale_get_all_variants( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getAllVariants( $locale ) : locale_get_all_variants( $locale );
+}
+function ut_loc_locale_filter_matches( $lang_tag,$loc_range ,$isCanonical)
+{
+ return $GLOBALS['oo-mode'] ? Locale::filterMatches( $lang_tag,$loc_range ,$isCanonical) : locale_filter_matches( $lang_tag,$loc_range ,$isCanonical);
+}
+function ut_loc_canonicalize( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::canonicalize( $locale ) : locale_canonicalize( $locale );
+}
+function ut_loc_locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc)
+{
+ return $GLOBALS['oo-mode'] ? Locale::lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc ) : locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc );
+}
+function ut_loc_accept_http($http) {
+ return $GLOBALS['oo-mode'] ? Locale::acceptFromHttp($http):locale_accept_from_http($http);
+}
+/* MessageFormatter functions */
+function ut_msgfmt_create( $locale, $pattern)
+{
+ return $GLOBALS['oo-mode'] ? MessageFormatter::create( $locale, $pattern ) : msgfmt_create( $locale, $pattern );
+}
+function ut_msgfmt_format( $fmt, $args )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->format( $args ) : msgfmt_format( $fmt, $args);
+}
+function ut_msgfmt_parse( $fmt, $string)
+{
+ return $GLOBALS['oo-mode'] ? $fmt->parse( $string) : msgfmt_parse( $fmt, $string);
+}
+function ut_msgfmt_format_message( $locale, $pattern, $args )
+{
+ return $GLOBALS['oo-mode'] ? MessageFormatter::formatMessage( $locale, $pattern, $args ) : msgfmt_format_message( $locale, $pattern, $args );
+}
+function ut_msgfmt_parse_message( $locale, $pattern, $string )
+{
+ return $GLOBALS['oo-mode'] ? MessageFormatter::parseMessage( $locale, $pattern, $string ) : msgfmt_parse_message( $locale, $pattern, $string );
+}
+function ut_msgfmt_set_pattern( $fmt, $pattern )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : msgfmt_set_pattern( $fmt, $pattern );
+}
+function ut_msgfmt_get_pattern( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getPattern() : msgfmt_get_pattern( $fmt );
+}
+function ut_msgfmt_get_locale( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getLocale( ) : msgfmt_get_locale( $fmt );
+}
+function ut_msgfmt_get_error_code( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getErrorCode() : msgfmt_get_error_code( $fmt );
+}
+function ut_msgfmt_get_error_message( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getErrorMessage() : msgfmt_get_error_message( $fmt );
+}
+/* IntlDateFormatter functions */
+function ut_datefmt_create( $locale, $datetype, $timetype, $timezone = null, $calendar = null ,$pattern = null)
+{
+ return $GLOBALS['oo-mode'] ? datefmt_create( $locale, $datetype, $timetype, $timezone, $calendar ,$pattern ) : datefmt_create( $locale, $datetype, $timetype, $timezone, $calendar ,$pattern);
+}
+function ut_datefmt_get_datetype( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getDateType( ) : datefmt_get_datetype( $fmt );
+}
+function ut_datefmt_get_timetype( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getTimeType( ) : datefmt_get_timetype( $fmt );
+}
+function ut_datefmt_get_calendar( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getCalendar( ) : datefmt_get_calendar( $fmt );
+}
+function ut_datefmt_set_calendar( $fmt ,$calendar )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setCalendar( $calendar ) : datefmt_set_calendar( $fmt , $calendar );
+}
+function ut_datefmt_get_timezone_id( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getTimeZoneId( ) : datefmt_get_timezone_id( $fmt );
+}
+function ut_datefmt_set_timezone_id( $fmt ,$timezone_id )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setTimeZoneId( $timezone_id ) : datefmt_set_timezone_id( $fmt ,$timezone_id);
+}
+function ut_datefmt_get_pattern( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getPattern() : datefmt_get_pattern( $fmt );
+}
+function ut_datefmt_set_pattern( $fmt , $pattern )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : datefmt_set_pattern( $fmt , $pattern);
+}
+function ut_datefmt_get_locale( $fmt ,$type=ULOC_ACTUAL_LOCALE)
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getLocale($type ) : datefmt_get_locale( $fmt ,$type);
+}
+function ut_datefmt_is_lenient( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->isLenient() : datefmt_is_lenient( $fmt );
+}
+function ut_datefmt_set_lenient( $fmt , $lenient )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setLenient( $lenient ) : datefmt_set_lenient( $fmt , $lenient);
+}
+function ut_datefmt_format( $fmt , $value )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->format( $value ) : datefmt_format( $fmt , $value);
+}
+function ut_datefmt_parse( $fmt , $value , &$parse_pos=0 )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->parse( $value ,$parse_pos ) : datefmt_parse( $fmt , $value,$parse_pos);
+}
+function ut_datefmt_localtime( $fmt , $value , &$parse_pos=0 )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->localtime( $value , $parse_pos ) : datefmt_localtime( $fmt , $value , $parse_pos );
+}
+
+function ut_resourcebundle_create( $locale, $bundle, $fallback=true )
+{
+ return $GLOBALS['oo-mode'] ? new ResourceBundle($locale, $bundle, $fallback): resourcebundle_create($locale, $bundle, $fallback);
+}
+function ut_resourcebundle_count($bundle )
+{
+ return $GLOBALS['oo-mode'] ? $bundle->count():resourcebundle_count($bundle);
+}
+function ut_resourcebundle_locales($bundle )
+{
+ return $GLOBALS['oo-mode'] ? ResourceBundle::getLocales($bundle):resourcebundle_locales($bundle);
+}
+function ut_resourcebundle_get($bundle, $idx )
+{
+ return $GLOBALS['oo-mode'] ? $bundle->get($idx):resourcebundle_get($bundle, $idx);
+}
+function ut_resourcebundle_get_error_code($bundle )
+{
+ return $GLOBALS['oo-mode'] ? $bundle->getErrorCode():resourcebundle_get_error_code($bundle);
+}
+function ut_resourcebundle_get_error_message($bundle )
+{
+ return $GLOBALS['oo-mode'] ? $bundle->getErrorMessage():resourcebundle_get_error_message($bundle);
+}