diff options
author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 19:39:21 -0400 |
---|---|---|
committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 19:39:21 -0400 |
commit | 6821b67124604da690c5e9276d5370d679c63ac8 (patch) | |
tree | befb4ca2520eb577950cef6cb76d10b914cbf67a /ext/intl/tests/collator_create.phpt | |
parent | cd0b49c72aee33b3e44a9c589fcd93b9e1c7a64f (diff) | |
download | php-6821b67124604da690c5e9276d5370d679c63ac8.tar.gz |
Imported Upstream version 5.3.0RC1upstream/5.3.0_RC1upstream/5.3.0RC1
Diffstat (limited to 'ext/intl/tests/collator_create.phpt')
-rwxr-xr-x | ext/intl/tests/collator_create.phpt | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/ext/intl/tests/collator_create.phpt b/ext/intl/tests/collator_create.phpt new file mode 100755 index 000000000..49dc49492 --- /dev/null +++ b/ext/intl/tests/collator_create.phpt @@ -0,0 +1,81 @@ +--TEST-- +create() +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) 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 |