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