1--TEST--
2create() icu >= 53.1
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
6--FILE--
7<?php
8
9/*
10 * Try creating collator with different locales
11 * with Procedural and Object methods.
12 */
13
14function ut_main()
15{
16    $res_str = '';
17
18    $locales = array(
19        'EN-US-ODESSA',
20        'UK_UA_ODESSA',
21        'uk-ua_CALIFORNIA@currency=;currency=GRN',
22        '',
23        'root',
24        'uk@currency=EURO',
25	'12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799'
26    );
27
28    foreach( $locales as $locale )
29    {
30        // Create Collator with the current locale.
31        $coll = ut_coll_create( $locale );
32        if( !is_object($coll) )
33        {
34            $res_str .= "Error creating collator with '$locale' locale: " .
35                 intl_get_error_message() . "\n";
36            continue;
37        }
38
39        // Get the requested, valid and actual locales.
40        $vloc = ut_coll_get_locale( $coll, Locale::VALID_LOCALE );
41        $aloc = ut_coll_get_locale( $coll, Locale::ACTUAL_LOCALE );
42
43        // Show them.
44        $res_str .= "Locale: '$locale'\n" .
45            "  ULOC_REQUESTED_LOCALE = '$locale'\n" .
46            "  ULOC_VALID_LOCALE     = '$vloc'\n" .
47            "  ULOC_ACTUAL_LOCALE    = '$aloc'\n";
48    }
49
50    return $res_str;
51}
52
53include_once( 'ut_common.inc' );
54ut_run();
55
56?>
57--EXPECTF--
58Locale: 'EN-US-ODESSA'
59  ULOC_REQUESTED_LOCALE = 'EN-US-ODESSA'
60  ULOC_VALID_LOCALE     = 'en_US'
61  ULOC_ACTUAL_LOCALE    = 'root'
62Locale: 'UK_UA_ODESSA'
63  ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA'
64  ULOC_VALID_LOCALE     = 'uk'
65  ULOC_ACTUAL_LOCALE    = 'uk'
66Error creating collator with 'uk-ua_CALIFORNIA@currency=;currency=GRN' locale: collator_create: unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR
67Locale: ''
68  ULOC_REQUESTED_LOCALE = ''
69  ULOC_VALID_LOCALE     = '%s'
70  ULOC_ACTUAL_LOCALE    = '%s'
71Locale: 'root'
72  ULOC_REQUESTED_LOCALE = 'root'
73  ULOC_VALID_LOCALE     = 'root'
74  ULOC_ACTUAL_LOCALE    = 'root'
75Locale: 'uk@currency=EURO'
76  ULOC_REQUESTED_LOCALE = 'uk@currency=EURO'
77  ULOC_VALID_LOCALE     = 'uk'
78  ULOC_ACTUAL_LOCALE    = 'uk'
79Error creating collator with '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than %d characters: U_ILLEGAL_ARGUMENT_ERROR
80