jmessa Tue Feb 12 17:45:48 2008 UTC Modified files: /php-src/ext/standard/tests/array array_change_key_case_variation4.phpt array_change_key_case_variation7.phpt array_change_key_case_variation8.phpt array_change_key_case_variation3.phpt array_change_key_case_variation1.phpt array_change_key_case_variation2.phpt array_change_key_case_variation5.phpt array_change_key_case_variation6.phpt Log: - committing array_change_key_case variation tests
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_change_key_case_variation4.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/array_change_key_case_variation4.phpt diff -u /dev/null php-src/ext/standard/tests/array/array_change_key_case_variation4.phpt:1.2 --- /dev/null Tue Feb 12 17:45:48 2008 +++ php-src/ext/standard/tests/array/array_change_key_case_variation4.phpt Tue Feb 12 17:45:47 2008 @@ -0,0 +1,251 @@ +--TEST-- +Test array_change_key_case() function : usage variations - different int values for $case +--FILE-- +<?php +/* Prototype : array array_change_key_case(array $input [, int $case]) + * Description: Retuns an array with all string keys lowercased [or uppercased] + * Source code: ext/standard/array.c + */ + +/* + * Pass different integer values as $case argument to array_change_key_case() to test behaviour + */ + +echo "*** Testing array_change_key_case() : usage variations ***\n"; + +$input = array('One' => 'un', 'TWO' => 'deux', 'three' => 'trois'); +for ($i = -5; $i <=5; $i += 1){ + echo "\n-- \$sort argument is $i --\n"; + $temp = $input; + var_dump(array_change_key_case($temp, $i)); +} + +echo "Done"; +?> + +--EXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- $sort argument is -5 -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} + +-- $sort argument is -4 -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} + +-- $sort argument is -3 -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} + +-- $sort argument is -2 -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} + +-- $sort argument is -1 -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} + +-- $sort argument is 0 -- +array(3) { + ["one"]=> + string(2) "un" + ["two"]=> + string(4) "deux" + ["three"]=> + string(5) "trois" +} + +-- $sort argument is 1 -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} + +-- $sort argument is 2 -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} + +-- $sort argument is 3 -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} + +-- $sort argument is 4 -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} + +-- $sort argument is 5 -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} +Done +--UEXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- $sort argument is -5 -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} + +-- $sort argument is -4 -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} + +-- $sort argument is -3 -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} + +-- $sort argument is -2 -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} + +-- $sort argument is -1 -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} + +-- $sort argument is 0 -- +array(3) { + [u"one"]=> + unicode(2) "un" + [u"two"]=> + unicode(4) "deux" + [u"three"]=> + unicode(5) "trois" +} + +-- $sort argument is 1 -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} + +-- $sort argument is 2 -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} + +-- $sort argument is 3 -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} + +-- $sort argument is 4 -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} + +-- $sort argument is 5 -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_change_key_case_variation7.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/array_change_key_case_variation7.phpt diff -u /dev/null php-src/ext/standard/tests/array/array_change_key_case_variation7.phpt:1.2 --- /dev/null Tue Feb 12 17:45:48 2008 +++ php-src/ext/standard/tests/array/array_change_key_case_variation7.phpt Tue Feb 12 17:45:47 2008 @@ -0,0 +1,143 @@ +--TEST-- +Test array_change_key_case() function : usage variations - referenced variables +--FILE-- +<?php +/* Prototype : array array_change_key_case(array $input [, int $case]) + * Description: Retuns an array with all string keys lowercased [or uppercased] + * Source code: ext/standard/array.c + */ + +/* + * Test array_change_key_case() when: + * 1. Passed a referenced variable + * 2. Passed an argument by reference + */ + +echo "*** Testing array_change_key_case() : usage variations ***\n"; + +$input = array('one' => 1, 'two' => 2, 'ABC' => 'xyz'); + +echo "\n-- \$input argument is a reference to array --\n"; +$new_input = &$input; +echo "Result:\n"; +var_dump(array_change_key_case($new_input, CASE_UPPER)); +echo "Original:\n"; +var_dump($input); +echo "Referenced:\n"; +var_dump($new_input); + +echo "\n-- \$input is an array passed by reference --\n"; +echo "Result:\n"; +var_dump(array_change_key_case(&$input, CASE_UPPER)); +echo "Original:\n"; +var_dump($input); + +echo "Done"; +?> + +--EXPECTF-- +Strict Standards: Call-time pass-by-reference has been deprecated in %s on line %d +*** Testing array_change_key_case() : usage variations *** + +-- $input argument is a reference to array -- +Result: +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["ABC"]=> + string(3) "xyz" +} +Original: +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["ABC"]=> + string(3) "xyz" +} +Referenced: +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["ABC"]=> + string(3) "xyz" +} + +-- $input is an array passed by reference -- +Result: +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["ABC"]=> + string(3) "xyz" +} +Original: +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["ABC"]=> + string(3) "xyz" +} +Done +--UEXPECTF-- +Strict Standards: Call-time pass-by-reference has been deprecated in %s on line %d +*** Testing array_change_key_case() : usage variations *** + +-- $input argument is a reference to array -- +Result: +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"ABC"]=> + unicode(3) "xyz" +} +Original: +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"ABC"]=> + unicode(3) "xyz" +} +Referenced: +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"ABC"]=> + unicode(3) "xyz" +} + +-- $input is an array passed by reference -- +Result: +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"ABC"]=> + unicode(3) "xyz" +} +Original: +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"ABC"]=> + unicode(3) "xyz" +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_change_key_case_variation8.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/array_change_key_case_variation8.phpt diff -u /dev/null php-src/ext/standard/tests/array/array_change_key_case_variation8.phpt:1.2 --- /dev/null Tue Feb 12 17:45:48 2008 +++ php-src/ext/standard/tests/array/array_change_key_case_variation8.phpt Tue Feb 12 17:45:47 2008 @@ -0,0 +1,223 @@ +--TEST-- +Test array_change_key_case() function : usage variations - Different strings as keys +--FILE-- +<?php +/* Prototype : array array_change_key_case(array $input [, int $case]) + * Description: Retuns an array with all string keys lowercased [or uppercased] + * Source code: ext/standard/array.c + */ + +/* + * Test how array_change_key_case() behaves with different strings + */ + +echo "*** Testing array_change_key_case() : usage variations ***\n"; + +$inputs = array ( + // group of escape sequences + array(null => 1, NULL => 2, "\a" => 3, "\cx" => 4, "\e" => 5, "\f" => 6, "\n" => 7, "\t" => 8, "\xhh" => 9, "\ddd" => 10, "\v" => 11), + + // array contains combination of capital/small letters + 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) +); + +foreach($inputs as $input) { + echo "\n-- \$case = default --\n"; + var_dump(array_change_key_case($input)); + echo "-- \$case = upper --\n"; + var_dump(array_change_key_case($input, CASE_UPPER)); +} + +echo "Done"; +?> + +--EXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- $case = default -- +array(10) { + [""]=> + int(2) + ["\a"]=> + int(3) + ["\cx"]=> + int(4) + ["\e"]=> + int(5) + [""]=> + int(6) + [" +"]=> + int(7) + [" "]=> + int(8) + ["\xhh"]=> + int(9) + ["\ddd"]=> + int(10) + [""]=> + int(11) +} +-- $case = upper -- +array(10) { + [""]=> + int(2) + ["\A"]=> + int(3) + ["\CX"]=> + int(4) + ["\E"]=> + int(5) + [""]=> + int(6) + [" +"]=> + int(7) + [" "]=> + int(8) + ["\XHH"]=> + int(9) + ["\DDD"]=> + int(10) + [""]=> + int(11) +} + +-- $case = default -- +array(9) { + ["lemon"]=> + int(1) + ["orange"]=> + int(11) + ["banana"]=> + int(12) + ["apple"]=> + int(4) + ["test"]=> + int(5) + ["tttt"]=> + int(6) + ["ttt"]=> + int(7) + ["ww"]=> + int(8) + ["x"]=> + int(10) +} +-- $case = upper -- +array(9) { + ["LEMON"]=> + int(1) + ["ORANGE"]=> + int(11) + ["BANANA"]=> + int(12) + ["APPLE"]=> + int(4) + ["TEST"]=> + int(5) + ["TTTT"]=> + int(6) + ["TTT"]=> + int(7) + ["WW"]=> + int(8) + ["X"]=> + int(10) +} +Done +--UEXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- $case = default -- +array(10) { + [u""]=> + int(2) + [u"\a"]=> + int(3) + [u"\cx"]=> + int(4) + [u"\e"]=> + int(5) + [u""]=> + int(6) + [u" +"]=> + int(7) + [u" "]=> + int(8) + [u"\xhh"]=> + int(9) + [u"\ddd"]=> + int(10) + [u""]=> + int(11) +} +-- $case = upper -- +array(10) { + [u""]=> + int(2) + [u"\A"]=> + int(3) + [u"\CX"]=> + int(4) + [u"\E"]=> + int(5) + [u""]=> + int(6) + [u" +"]=> + int(7) + [u" "]=> + int(8) + [u"\XHH"]=> + int(9) + [u"\DDD"]=> + int(10) + [u""]=> + int(11) +} + +-- $case = default -- +array(9) { + [u"lemon"]=> + int(1) + [u"orange"]=> + int(11) + [u"banana"]=> + int(12) + [u"apple"]=> + int(4) + [u"test"]=> + int(5) + [u"tttt"]=> + int(6) + [u"ttt"]=> + int(7) + [u"ww"]=> + int(8) + [u"x"]=> + int(10) +} +-- $case = upper -- +array(9) { + [u"LEMON"]=> + int(1) + [u"ORANGE"]=> + int(11) + [u"BANANA"]=> + int(12) + [u"APPLE"]=> + int(4) + [u"TEST"]=> + int(5) + [u"TTTT"]=> + int(6) + [u"TTT"]=> + int(7) + [u"WW"]=> + int(8) + [u"X"]=> + int(10) +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_change_key_case_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/array_change_key_case_variation3.phpt diff -u /dev/null php-src/ext/standard/tests/array/array_change_key_case_variation3.phpt:1.2 --- /dev/null Tue Feb 12 17:45:48 2008 +++ php-src/ext/standard/tests/array/array_change_key_case_variation3.phpt Tue Feb 12 17:45:47 2008 @@ -0,0 +1,292 @@ +--TEST-- +Test array_change_key_case() function : usage variations - different data types as keys +--FILE-- +<?php +/* Prototype : array array_change_key_case(array $input [, int $case]) + * Description: Retuns an array with all string keys lowercased [or uppercased] + * Source code: ext/standard/array.c + */ + +/* + * Pass arrays with different data types as keys to array_change_key_case() + * to test conversion + */ + +echo "*** Testing array_change_key_case() : usage variations ***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// arrays of different data types to be passed to $input argument +$inputs = array( + + // int data +/*1*/ 'int' => array( + 0 => 'zero', + 1 => 'one', + 12345 => 'positive', + -2345 => 'negative', + ), + + // float data +/*2*/ 'float' => array( + 10.5 => 'positive', + -10.5 => 'negative', + .5 => 'half', + ), + + 'extreme floats' => array( + 12.3456789000e6 => 'large', + 12.3456789000E-10 => 'small', + ), + + // null data +/*3*/ 'null uppercase' => array( + NULL => 'null 1', + ), + 'null lowercase' => array( + null => 'null 2', + ), + + // boolean data +/*4*/ 'bool lowercase' => array( + true => 'lowert', + false => 'lowerf', + ), + 'bool uppercase' => array( + TRUE => 'uppert', + FALSE => 'upperf', + ), + + // empty data +/*5*/ 'empty double quotes' => array( + "" => 'emptyd', + ), + 'empty single quotes' => array( + '' => 'emptys', + ), + + // string data +/*6*/ 'string' => array( + "stringd" => 'stringd', + 'strings' => 'strings', + $heredoc => 'stringh', + ), + + // undefined data +/*8*/ 'undefined' => array( + @$undefined_var => 'undefined', + ), + + // unset data +/*9*/ 'unset' => array( + @$unset_var => 'unset', + ), +); + +// loop through each sub-array of $inputs to check the behavior of array_change_key_case() +$iterator = 1; +foreach($inputs as $key => $input) { + echo "\n-- Iteration $iterator : $key data --\n"; + var_dump( array_change_key_case($input, CASE_UPPER) ); + $iterator++; +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- Iteration 1 : int data -- +array(4) { + [0]=> + string(4) "zero" + [1]=> + string(3) "one" + [12345]=> + string(8) "positive" + [-2345]=> + string(8) "negative" +} + +-- Iteration 2 : float data -- +array(3) { + [10]=> + string(8) "positive" + [-10]=> + string(8) "negative" + [0]=> + string(4) "half" +} + +-- Iteration 3 : extreme floats data -- +array(2) { + [12345678]=> + string(5) "large" + [0]=> + string(5) "small" +} + +-- Iteration 4 : null uppercase data -- +array(1) { + [""]=> + string(6) "null 1" +} + +-- Iteration 5 : null lowercase data -- +array(1) { + [""]=> + string(6) "null 2" +} + +-- Iteration 6 : bool lowercase data -- +array(2) { + [1]=> + string(6) "lowert" + [0]=> + string(6) "lowerf" +} + +-- Iteration 7 : bool uppercase data -- +array(2) { + [1]=> + string(6) "uppert" + [0]=> + string(6) "upperf" +} + +-- Iteration 8 : empty double quotes data -- +array(1) { + [""]=> + string(6) "emptyd" +} + +-- Iteration 9 : empty single quotes data -- +array(1) { + [""]=> + string(6) "emptys" +} + +-- Iteration 10 : string data -- +array(3) { + ["STRINGD"]=> + string(7) "stringd" + ["STRINGS"]=> + string(7) "strings" + ["HELLO WORLD"]=> + string(7) "stringh" +} + +-- Iteration 11 : undefined data -- +array(1) { + [""]=> + string(9) "undefined" +} + +-- Iteration 12 : unset data -- +array(1) { + [""]=> + string(5) "unset" +} +Done +--UEXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- Iteration 1 : int data -- +array(4) { + [0]=> + unicode(4) "zero" + [1]=> + unicode(3) "one" + [12345]=> + unicode(8) "positive" + [-2345]=> + unicode(8) "negative" +} + +-- Iteration 2 : float data -- +array(3) { + [10]=> + unicode(8) "positive" + [-10]=> + unicode(8) "negative" + [0]=> + unicode(4) "half" +} + +-- Iteration 3 : extreme floats data -- +array(2) { + [12345678]=> + unicode(5) "large" + [0]=> + unicode(5) "small" +} + +-- Iteration 4 : null uppercase data -- +array(1) { + [u""]=> + unicode(6) "null 1" +} + +-- Iteration 5 : null lowercase data -- +array(1) { + [u""]=> + unicode(6) "null 2" +} + +-- Iteration 6 : bool lowercase data -- +array(2) { + [1]=> + unicode(6) "lowert" + [0]=> + unicode(6) "lowerf" +} + +-- Iteration 7 : bool uppercase data -- +array(2) { + [1]=> + unicode(6) "uppert" + [0]=> + unicode(6) "upperf" +} + +-- Iteration 8 : empty double quotes data -- +array(1) { + [u""]=> + unicode(6) "emptyd" +} + +-- Iteration 9 : empty single quotes data -- +array(1) { + [u""]=> + unicode(6) "emptys" +} + +-- Iteration 10 : string data -- +array(3) { + [u"STRINGD"]=> + unicode(7) "stringd" + [u"STRINGS"]=> + unicode(7) "strings" + [u"HELLO WORLD"]=> + unicode(7) "stringh" +} + +-- Iteration 11 : undefined data -- +array(1) { + [u""]=> + unicode(9) "undefined" +} + +-- Iteration 12 : unset data -- +array(1) { + [u""]=> + unicode(5) "unset" +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_change_key_case_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/array_change_key_case_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/array/array_change_key_case_variation1.phpt:1.2 --- /dev/null Tue Feb 12 17:45:48 2008 +++ php-src/ext/standard/tests/array/array_change_key_case_variation1.phpt Tue Feb 12 17:45:47 2008 @@ -0,0 +1,351 @@ +--TEST-- +Test array_change_key_case() function : usage variations - Pass different data types as $input arg +--FILE-- +<?php +/* Prototype : array array_change_key_case(array $input [, int $case]) + * Description: Retuns an array with all string keys lowercased [or uppercased] + * Source code: ext/standard/array.c + */ + +/* + * Pass different data types as $input argument to test behaviour of array_change_key_case() + */ + +echo "*** Testing array_change_key_case() : usage variations ***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $input argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "string", + 'string', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of array_change_key_case() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( array_change_key_case($input) ); + $iterator++; +}; + +fclose($fp); + +echo "Done"; +?> + +--EXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- Iteration 1 -- + +Warning: array_change_key_case() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: array_change_key_case() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: array_change_key_case() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: array_change_key_case() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: array_change_key_case() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: array_change_key_case() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: array_change_key_case() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: array_change_key_case() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: array_change_key_case() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: array_change_key_case() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: array_change_key_case() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: array_change_key_case() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: array_change_key_case() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: array_change_key_case() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: array_change_key_case() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: array_change_key_case() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: array_change_key_case() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 18 -- +array(0) { +} + +-- Iteration 19 -- + +Warning: array_change_key_case() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: array_change_key_case() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: array_change_key_case() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: array_change_key_case() expects parameter 1 to be array, object given in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: array_change_key_case() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: array_change_key_case() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 25 -- + +Warning: array_change_key_case() expects parameter 1 to be array, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- Iteration 1 -- + +Warning: array_change_key_case() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: array_change_key_case() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: array_change_key_case() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: array_change_key_case() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: array_change_key_case() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: array_change_key_case() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: array_change_key_case() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: array_change_key_case() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: array_change_key_case() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: array_change_key_case() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: array_change_key_case() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: array_change_key_case() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: array_change_key_case() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: array_change_key_case() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: array_change_key_case() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: array_change_key_case() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: array_change_key_case() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 18 -- +array(0) { +} + +-- Iteration 19 -- + +Warning: array_change_key_case() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: array_change_key_case() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: array_change_key_case() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: array_change_key_case() expects parameter 1 to be array, object given in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: array_change_key_case() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: array_change_key_case() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 25 -- + +Warning: array_change_key_case() expects parameter 1 to be array, resource given in %s on line %d +NULL +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_change_key_case_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/array_change_key_case_variation2.phpt diff -u /dev/null php-src/ext/standard/tests/array/array_change_key_case_variation2.phpt:1.2 --- /dev/null Tue Feb 12 17:45:48 2008 +++ php-src/ext/standard/tests/array/array_change_key_case_variation2.phpt Tue Feb 12 17:45:47 2008 @@ -0,0 +1,491 @@ +--TEST-- +Test array_change_key_case() function : usage variations - Pass different data types as $case arg +--FILE-- +<?php +/* Prototype : array array_change_key_case(array $input [, int $case]) + * Description: Retuns an array with all string keys lowercased [or uppercased] + * Source code: ext/standard/array.c + */ + +/* + * Pass different data types as $case argument to array_change_key_case() to test behaviour + * Where possible, CASE_UPPER has been entered as a string value + */ + +echo "*** Testing array_change_key_case() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$array = array ('one' => 1, 'TWO' => 2, 'Three' => 3); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// heredoc string +$heredoc = <<<EOT +CASE_UPPER +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $case argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "CASE_UPPER", + 'CASE_UPPER', + $heredoc, + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, +); + +// loop through each element of $inputs to check the behavior of array_change_key_case() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( array_change_key_case($array, $input) ); + $iterator++; +}; + +echo "Done"; +?> + +--EXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- Iteration 1 -- +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) +} + +-- Iteration 2 -- +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["THREE"]=> + int(3) +} + +-- Iteration 3 -- +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["THREE"]=> + int(3) +} + +-- Iteration 4 -- +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["THREE"]=> + int(3) +} + +-- Iteration 5 -- +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["THREE"]=> + int(3) +} + +-- Iteration 6 -- +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["THREE"]=> + int(3) +} + +-- Iteration 7 -- +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["THREE"]=> + int(3) +} + +-- Iteration 8 -- +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) +} + +-- Iteration 9 -- +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) +} + +-- Iteration 10 -- +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) +} + +-- Iteration 11 -- +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) +} + +-- Iteration 12 -- +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["THREE"]=> + int(3) +} + +-- Iteration 13 -- +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) +} + +-- Iteration 14 -- +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["THREE"]=> + int(3) +} + +-- Iteration 15 -- +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) +} + +-- Iteration 16 -- + +Warning: array_change_key_case() expects parameter 2 to be long, string given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: array_change_key_case() expects parameter 2 to be long, string given in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: array_change_key_case() expects parameter 2 to be long, array given in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: array_change_key_case() expects parameter 2 to be long, string given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: array_change_key_case() expects parameter 2 to be long, string given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: array_change_key_case() expects parameter 2 to be long, string given in %s on line %d +NULL + +-- Iteration 22 -- +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) +} + +-- Iteration 23 -- +array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) +} +Done +--UEXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- Iteration 1 -- +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) +} + +-- Iteration 2 -- +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"THREE"]=> + int(3) +} + +-- Iteration 3 -- +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"THREE"]=> + int(3) +} + +-- Iteration 4 -- +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"THREE"]=> + int(3) +} + +-- Iteration 5 -- +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"THREE"]=> + int(3) +} + +-- Iteration 6 -- +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"THREE"]=> + int(3) +} + +-- Iteration 7 -- +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"THREE"]=> + int(3) +} + +-- Iteration 8 -- +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) +} + +-- Iteration 9 -- +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) +} + +-- Iteration 10 -- +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) +} + +-- Iteration 11 -- +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) +} + +-- Iteration 12 -- +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"THREE"]=> + int(3) +} + +-- Iteration 13 -- +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) +} + +-- Iteration 14 -- +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"THREE"]=> + int(3) +} + +-- Iteration 15 -- +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) +} + +-- Iteration 16 -- + +Warning: array_change_key_case() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: array_change_key_case() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: array_change_key_case() expects parameter 2 to be long, array given in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: array_change_key_case() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: array_change_key_case() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: array_change_key_case() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL + +-- Iteration 22 -- +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) +} + +-- Iteration 23 -- +array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_change_key_case_variation5.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/array_change_key_case_variation5.phpt diff -u /dev/null php-src/ext/standard/tests/array/array_change_key_case_variation5.phpt:1.2 --- /dev/null Tue Feb 12 17:45:48 2008 +++ php-src/ext/standard/tests/array/array_change_key_case_variation5.phpt Tue Feb 12 17:45:47 2008 @@ -0,0 +1,64 @@ +--TEST-- +Test array_change_key_case() function : usage variations - position of internal pointer +--FILE-- +<?php +/* Prototype : array array_change_key_case(array $input [, int $case]) + * Description: Retuns an array with all string keys lowercased [or uppercased] + * Source code: ext/standard/array.c + */ + +/* + * Check the position of the internal array pointer after calling the function + */ + +echo "*** Testing array_change_key_case() : usage variations ***\n"; + +$input = array ('one' => 'un', 'two' => 'deux', 'three' => 'trois'); + +echo "\n-- Call array_change_key_case() --\n"; +var_dump($result = array_change_key_case($input, CASE_UPPER)); + +echo "-- Position of Internal Pointer in Result: --\n"; +echo key($result) . " => " . current($result) . "\n"; +echo "\n-- Position of Internal Pointer in Original Array: --\n"; +echo key($input) . " => " . current ($input) . "\n"; + +echo "Done"; +?> + +--EXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- Call array_change_key_case() -- +array(3) { + ["ONE"]=> + string(2) "un" + ["TWO"]=> + string(4) "deux" + ["THREE"]=> + string(5) "trois" +} +-- Position of Internal Pointer in Result: -- +ONE => un + +-- Position of Internal Pointer in Original Array: -- +one => un +Done +--UEXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- Call array_change_key_case() -- +array(3) { + [u"ONE"]=> + unicode(2) "un" + [u"TWO"]=> + unicode(4) "deux" + [u"THREE"]=> + unicode(5) "trois" +} +-- Position of Internal Pointer in Result: -- +ONE => un + +-- Position of Internal Pointer in Original Array: -- +one => un +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_change_key_case_variation6.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/array_change_key_case_variation6.phpt diff -u /dev/null php-src/ext/standard/tests/array/array_change_key_case_variation6.phpt:1.2 --- /dev/null Tue Feb 12 17:45:48 2008 +++ php-src/ext/standard/tests/array/array_change_key_case_variation6.phpt Tue Feb 12 17:45:47 2008 @@ -0,0 +1,116 @@ +--TEST-- +Test array_change_key_case() function : usage variations - multidimensional arrays +--FILE-- +<?php +/* Prototype : array array_change_key_case(array $input [, int $case]) + * Description: Retuns an array with all string keys lowercased [or uppercased] + * Source code: ext/standard/array.c + */ + +/* + * Test how array_change_key_case() converts keys in multi-dimensional arrays + */ + +echo "*** Testing array_change_key_case() : usage variations ***\n"; + +$input = array('English' => array('one' => 1, 'two' => 2, 'three' => 3), + 'French' => array('un' => 1, 'deux' => 2, 'trois' => 3), + 'German' => array('eins' => 1, 'zwei' => 2, 'drei' => 3)); + +echo "\n-- Pass a two-dimensional array as \$input argument --\n"; +var_dump(array_change_key_case($input, CASE_UPPER)); + +echo "\n-- Pass a sub-arry as \$input argument --\n"; +var_dump(array_change_key_case($input['English'], CASE_UPPER)); + +echo "Done"; +?> + +--EXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- Pass a two-dimensional array as $input argument -- +array(3) { + ["ENGLISH"]=> + array(3) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) + } + ["FRENCH"]=> + array(3) { + ["un"]=> + int(1) + ["deux"]=> + int(2) + ["trois"]=> + int(3) + } + ["GERMAN"]=> + array(3) { + ["eins"]=> + int(1) + ["zwei"]=> + int(2) + ["drei"]=> + int(3) + } +} + +-- Pass a sub-arry as $input argument -- +array(3) { + ["ONE"]=> + int(1) + ["TWO"]=> + int(2) + ["THREE"]=> + int(3) +} +Done +--UEXPECTF-- +*** Testing array_change_key_case() : usage variations *** + +-- Pass a two-dimensional array as $input argument -- +array(3) { + [u"ENGLISH"]=> + array(3) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) + } + [u"FRENCH"]=> + array(3) { + [u"un"]=> + int(1) + [u"deux"]=> + int(2) + [u"trois"]=> + int(3) + } + [u"GERMAN"]=> + array(3) { + [u"eins"]=> + int(1) + [u"zwei"]=> + int(2) + [u"drei"]=> + int(3) + } +} + +-- Pass a sub-arry as $input argument -- +array(3) { + [u"ONE"]=> + int(1) + [u"TWO"]=> + int(2) + [u"THREE"]=> + int(3) +} +Done \ No newline at end of file
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php