1--TEST--
2locale_compose_locale()
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5--FILE--
6<?php
7
8/*
9 * Try parsing different Locales
10 * with Procedural and Object methods.
11 */
12
13function ut_main()
14{
15	$loc_parts_arr1 = array(
16		Locale::LANG_TAG =>'sl' ,
17		Locale::SCRIPT_TAG =>'Latn' ,
18		Locale::REGION_TAG =>'IT'
19	);
20	$loc_parts_arr2 = array(
21		Locale::LANG_TAG =>'de' ,
22		Locale::REGION_TAG =>'DE'
23	);
24	$loc_parts_arr3 = array(
25		Locale::LANG_TAG =>'hi'
26	);
27	$loc_parts_arr4 = array(
28		Locale::LANG_TAG =>'zh' ,
29		Locale::SCRIPT_TAG =>'Hans' ,
30		Locale::REGION_TAG =>'CN'
31	);
32	$loc_parts_arr5 = array(
33		Locale::LANG_TAG =>'es' ,
34		Locale::SCRIPT_TAG =>'Hans' ,
35		Locale::REGION_TAG =>'CN'
36	);
37	$loc_parts_arr6 = array(
38		Locale::LANG_TAG =>'en' ,
39		Locale::SCRIPT_TAG =>'Hans' ,
40		Locale::REGION_TAG =>'CN',
41		Locale::VARIANT_TAG.'14' =>'rozaj' ,
42		'variant1'=>'nedis'
43	);
44	$loc_parts_arr7 = array(
45		Locale::LANG_TAG =>'en' ,
46		Locale::SCRIPT_TAG =>'Hans' ,
47		Locale::REGION_TAG =>'CN',
48		'variant14'=>'rozaj' ,
49		'variant1'=>'nedis' ,
50		'extlang0'=>'lng' ,
51		'extlang1'=>'ing'
52	);
53	$loc_parts_arr8 = array(
54		Locale::LANG_TAG =>'en' ,
55		Locale::SCRIPT_TAG =>'Hans' ,
56		Locale::REGION_TAG =>'CN',
57		'variant14'=>'rozaj' ,
58		'variant1'=>'nedis' ,
59		'extlang0'=>'lng' ,
60		'extlang1'=>'ing',
61		'private7'=>'prv1' ,
62		'private9'=>'prv2'
63	);
64	$loc_parts_arr9 = array(
65		Locale::REGION_TAG =>'DE'
66	);
67	$loc_parts_arr10 = array(
68		Locale::LANG_TAG => 45,
69		Locale::REGION_TAG => false,
70		Locale::SCRIPT_TAG => 15
71	);
72	$loc_parts_arr11 = array(
73		Locale::LANG_TAG =>'de'  ,
74		Locale::REGION_TAG =>'DE',
75		'private0' => 13,
76		'variant1' => array(),
77		'extlang2' => false
78	);
79        $loc_parts_arr12 = array(
80                Locale::LANG_TAG =>'en' ,
81                Locale::SCRIPT_TAG =>'Hans' ,
82                Locale::REGION_TAG =>'CN',
83                Locale::VARIANT_TAG => array('nedis', 'rozaj'),
84		Locale::PRIVATE_TAG => array('prv1', 'prv2'),
85		Locale::EXTLANG_TAG => array('lng', 'ing')
86        );
87
88
89	$loc_parts_arr = array(
90		'loc1' => $loc_parts_arr1	,
91		'loc2' => $loc_parts_arr2	,
92		'loc3' => $loc_parts_arr3	,
93		'loc4' => $loc_parts_arr4	,
94		'loc5' => $loc_parts_arr5	,
95		'loc6' => $loc_parts_arr6	,
96		'loc7' => $loc_parts_arr7	,
97		'loc8' => $loc_parts_arr8	,
98		'loc9' => $loc_parts_arr9	,
99		'loc10' => $loc_parts_arr10	,
100		'loc11' => $loc_parts_arr11	,
101		'loc12' => $loc_parts_arr12
102	);
103
104    error_reporting( E_ERROR );
105
106    $cnt  = 0;
107    $res_str = '';
108	foreach($loc_parts_arr as $key => $value ){
109		$res_str .= "\n------------";
110		$res_str .= "\nInput Array name is : loc".(++$cnt) ;
111/*
112		foreach($value as $valKey => $valValue ){
113			$res_str .=  $valKey ."->".$valValue."  " ;
114		}
115*/
116
117		$locale = ut_loc_locale_compose( $value);
118		$res_str .= "\n\nComposed Locale: ";
119		if( $locale){
120			$res_str .= "$locale";
121		}else{
122			$res_str .= "No values found from Locale compose due to the following error:\n";
123			$res_str .= intl_get_error_message() ;
124		}
125	}
126
127	$res_str .= "\n------------";
128	$res_str .= "\n";
129    return $res_str;
130
131}
132
133include_once( 'ut_common.inc' );
134ut_run();
135
136?>
137--EXPECT--
138------------
139Input Array name is : loc1
140
141Composed Locale: sl_Latn_IT
142------------
143Input Array name is : loc2
144
145Composed Locale: de_DE
146------------
147Input Array name is : loc3
148
149Composed Locale: hi
150------------
151Input Array name is : loc4
152
153Composed Locale: zh_Hans_CN
154------------
155Input Array name is : loc5
156
157Composed Locale: es_Hans_CN
158------------
159Input Array name is : loc6
160
161Composed Locale: en_Hans_CN_nedis_rozaj
162------------
163Input Array name is : loc7
164
165Composed Locale: en_lng_ing_Hans_CN_nedis_rozaj
166------------
167Input Array name is : loc8
168
169Composed Locale: en_lng_ing_Hans_CN_nedis_rozaj_x_prv1_prv2
170------------
171Input Array name is : loc9
172
173Composed Locale: No values found from Locale compose due to the following error:
174locale_compose: parameter array does not contain 'language' tag.: U_ILLEGAL_ARGUMENT_ERROR
175------------
176Input Array name is : loc10
177
178Composed Locale: No values found from Locale compose due to the following error:
179locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR
180------------
181Input Array name is : loc11
182
183Composed Locale: No values found from Locale compose due to the following error:
184locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR
185------------
186Input Array name is : loc12
187
188Composed Locale: en_lng_ing_Hans_CN_nedis_rozaj_x_prv1_prv2
189------------
190