1--TEST--
2collator_get_sort_key() icu >= 56.1
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5<?php if (version_compare(INTL_ICU_VERSION, '56.1') < 0) die('skip for ICU >= 56.1'); ?>
6<?php if (version_compare(INTL_ICU_VERSION, '62.1') >=  0) die('skip for ICU < 62.1'); ?>
7--FILE--
8<?php
9
10/*
11 * Get sort keys using various locales
12 */
13function sort_arrays( $locale, $data )
14{
15    $res_str = '';
16
17    $coll = ut_coll_create( $locale );
18
19	foreach($data as $value) {
20		$res_val = ut_coll_get_sort_key( $coll, $value );
21		$res_str .= "source: ".$value."\n".
22					"key: ".bin2hex($res_val)."\n";
23	}
24
25    return $res_str;
26}
27
28
29function ut_main()
30{
31    $res_str = '';
32
33    // Regular strings keys
34    $test_params = array(
35		'abc', 'abd', 'aaa',
36		'аа', 'а', 'z',
37		'', null , '3',
38        'y'  , 'i'  , 'k'
39    );
40
41    $res_str .= sort_arrays( 'en_US', $test_params );
42
43    // Sort a non-ASCII array using ru_RU locale.
44    $test_params = array(
45		'абг', 'абв', 'жжж', 'эюя'
46    );
47
48    $res_str .= sort_arrays( 'ru_RU', $test_params );
49
50    // Sort an array using Lithuanian locale.
51    $res_str .= sort_arrays( 'lt_LT', $test_params );
52
53    return $res_str . "\n";
54}
55
56include_once( 'ut_common.inc' );
57ut_run();
58?>
59--EXPECT--
60source: abc
61key: 292b2d01070107
62source: abd
63key: 292b2f01070107
64source: aaa
65key: 29292901070107
66source: аа
67key: 60060601060106
68source: а
69key: 600601050105
70source: z
71key: 5b01050105
72source:
73key: 0101
74source:
75key: 0101
76source: 3
77key: 1801050105
78source: y
79key: 5901050105
80source: i
81key: 3901050105
82source: k
83key: 3d01050105
84source: абг
85key: 26060c1001070107
86source: абв
87key: 26060c0e01070107
88source: жжж
89key: 262c2c2c01070107
90source: эюя
91key: 26eef0f401070107
92source: абг
93key: 60060c1001070107
94source: абв
95key: 60060c0e01070107
96source: жжж
97key: 602c2c2c01070107
98source: эюя
99key: 60eef0f401070107
100