1--TEST--
2Test array_change_key_case() function : usage variations - Different strings as keys
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6  die("skip Output tested contains chars that are not shown the same on windows concole (ESC and co)");
7}
8--FILE--
9<?php
10/* Prototype  : array array_change_key_case(array $input [, int $case])
11 * Description: Retuns an array with all string keys lowercased [or uppercased]
12 * Source code: ext/standard/array.c
13 */
14
15/*
16 * Test how array_change_key_case() behaves with different strings
17 */
18
19echo "*** Testing array_change_key_case() : usage variations ***\n";
20
21$inputs = array (
22	// group of escape sequences
23	array(null => 1, NULL => 2, "\a" => 3, "\cx" => 4, "\e" => 5, "\f" => 6, "\n" => 7, "\t" => 8, "\xhh" => 9, "\ddd" => 10, "\v" => 11),
24
25	// array contains combination of capital/small letters
26	array("lemoN" => 1, "Orange" => 2, "banana" => 3, "apple" => 4, "Test" => 5, "TTTT" => 6, "ttt" => 7, "ww" => 8, "x" => 9, "X" => 10, "oraNGe" => 11, "BANANA" => 12)
27);
28
29foreach($inputs as $input) {
30	echo "\n-- \$case = default --\n";
31	var_dump(array_change_key_case($input));
32	echo "-- \$case = upper --\n";
33	var_dump(array_change_key_case($input, CASE_UPPER));
34}
35
36echo "Done";
37?>
38
39--EXPECTF--
40*** Testing array_change_key_case() : usage variations ***
41
42-- $case = default --
43array(10) {
44  [""]=>
45  int(2)
46  ["\a"]=>
47  int(3)
48  ["\cx"]=>
49  int(4)
50  [""]=>
51  int(5)
52  [""]=>
53  int(6)
54  ["
55"]=>
56  int(7)
57  ["	"]=>
58  int(8)
59  ["\xhh"]=>
60  int(9)
61  ["\ddd"]=>
62  int(10)
63  [""]=>
64  int(11)
65}
66-- $case = upper --
67array(10) {
68  [""]=>
69  int(2)
70  ["\A"]=>
71  int(3)
72  ["\CX"]=>
73  int(4)
74  [""]=>
75  int(5)
76  [""]=>
77  int(6)
78  ["
79"]=>
80  int(7)
81  ["	"]=>
82  int(8)
83  ["\XHH"]=>
84  int(9)
85  ["\DDD"]=>
86  int(10)
87  [""]=>
88  int(11)
89}
90
91-- $case = default --
92array(9) {
93  ["lemon"]=>
94  int(1)
95  ["orange"]=>
96  int(11)
97  ["banana"]=>
98  int(12)
99  ["apple"]=>
100  int(4)
101  ["test"]=>
102  int(5)
103  ["tttt"]=>
104  int(6)
105  ["ttt"]=>
106  int(7)
107  ["ww"]=>
108  int(8)
109  ["x"]=>
110  int(10)
111}
112-- $case = upper --
113array(9) {
114  ["LEMON"]=>
115  int(1)
116  ["ORANGE"]=>
117  int(11)
118  ["BANANA"]=>
119  int(12)
120  ["APPLE"]=>
121  int(4)
122  ["TEST"]=>
123  int(5)
124  ["TTTT"]=>
125  int(6)
126  ["TTT"]=>
127  int(7)
128  ["WW"]=>
129  int(8)
130  ["X"]=>
131  int(10)
132}
133Done
134