From: Antony Dovgal Date: Fri, 13 Jul 2007 16:39:55 +0000 (+0000) Subject: split one more huge test into several smaller ones X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~126 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38283545ee742de5b07290abb687df5b358bfad1;p=php split one more huge test into several smaller ones --- diff --git a/ext/standard/tests/array/array_keys.phpt b/ext/standard/tests/array/array_keys.phpt deleted file mode 100644 index c499de25e1..0000000000 --- a/ext/standard/tests/array/array_keys.phpt +++ /dev/null @@ -1,826 +0,0 @@ ---TEST-- -Test array_keys() function ---SKIPIF-- - ---FILE-- - 1, "b" => 2, 2.0 => 2.0, -23.45 => "asdasd", - array(1,2,3)); -var_dump(array_keys($basic_arr)); - -echo "\n*** Testing array_keys() on various arrays ***"; -$arrays = array( - array(), - array(0), - array( array() ), - array("Hello" => "World"), - array("" => ""), - array(1,2,3, "d" => array(4,6, "d")), - array("a" => 1, "b" => 2, "c" =>3, "d" => array()), - array(0 => 0, 1 => 1, 2 => 2, 3 => 3), - array(0.001=>3.000, 1.002=>2, 1.999=>3, "a"=>3, 3=>5, "5"=>3.000), - array(TRUE => TRUE, FALSE => FALSE, NULL => NULL, "\x000", "\000"), - array("a" => "abcd", "a" => "", "ab" => -6, "cd" => -0.5 ), - array(0 => array(), 1=> array(0), 2 => array(1), ""=> array(),""=>"" ) -); - -$i = 0; -/* loop through to test array_keys() with different arrays */ -foreach ($arrays as $array) { - echo "\n-- Iteration $i --\n"; - var_dump(array_keys($array)); - $i++; -} - -echo "\n*** Testing array_keys() on all the types other than arrays ***"; -$types_arr = array( - TRUE => TRUE, - FALSE => FALSE, - 1 => 1, - 0 => 0, - -1 => -1, - "1" => "1", - "0" => "0", - "-1" => "-1", - NULL, - array(), - "php" => "php", - "" => "" -); -$values = array(TRUE, FALSE, 1, 0, -1, "1", "0", "-1", NULL, array(), "php", ""); -foreach ($values as $value){ - echo "\n-- Loose type checking --\n"; - var_dump(array_keys($types_arr, $value)); - echo "\n-- strict type checking --\n"; - var_dump(array_keys($types_arr, $value, TRUE)); -} - -echo "\n*** Testing array_keys() with resource type ***\n"; -$resource1 = fopen( __FILE__, "r"); -$resource2 = opendir( "." ); - -/* creating an array with resource types as elements */ -$arr_resource = array($resource1, $resource2); - -var_dump(array_keys($arr_resource, $resource1)); // loose type checking -var_dump(array_keys($arr_resource, $resource1, TRUE)); // strict type checking -var_dump(array_keys($arr_resource, $resource2)); // loose type checking -var_dump(array_keys($arr_resource, $resource2, TRUE)); // strict type checking - -echo "\n*** Testing array_keys() on range of values ***\n"; -$arr_range = array( - 2147483647 => 1, - 2147483648 => 2, - -2147483647 => 3, - -2147483648 => 4, - -2147483649 => 5, - -0 => 6, - 0 => 7 -); -var_dump(array_keys($arr_range)); - -echo "\n*** Testing array_keys() on an array created on the fly ***\n"; -var_dump(array_keys(array("a" => 1, "b" => 2, "c" => 3))); -var_dump(array_keys(array())); // null array - -echo "\n*** Testing error conditions ***"; -var_dump(array_keys(100)); -var_dump(array_keys("string")); -var_dump(array_keys(new stdclass)); // object -var_dump(array_keys()); // Zero arguments -var_dump(array_keys(array(), "", TRUE, 100)); // args > expected -var_dump(array_keys(array(1,2,3, array() => array()))); // (W)illegal offset - -/* Closing the resource handles */ -fclose( $resource1 ); -closedir( $resource2 ); - -echo "Done\n"; -?> ---EXPECTF-- -*** Testing array_keys() on basic array operation *** -array(5) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - [2]=> - int(2) - [3]=> - int(-23) - [4]=> - int(3) -} - -*** Testing array_keys() on various arrays *** --- Iteration 0 -- -array(0) { -} - --- Iteration 1 -- -array(1) { - [0]=> - int(0) -} - --- Iteration 2 -- -array(1) { - [0]=> - int(0) -} - --- Iteration 3 -- -array(1) { - [0]=> - string(5) "Hello" -} - --- Iteration 4 -- -array(1) { - [0]=> - string(0) "" -} - --- Iteration 5 -- -array(4) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - string(1) "d" -} - --- Iteration 6 -- -array(4) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - [2]=> - string(1) "c" - [3]=> - string(1) "d" -} - --- Iteration 7 -- -array(4) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - int(3) -} - --- Iteration 8 -- -array(5) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - string(1) "a" - [3]=> - int(3) - [4]=> - int(5) -} - --- Iteration 9 -- -array(5) { - [0]=> - int(1) - [1]=> - int(0) - [2]=> - string(0) "" - [3]=> - int(2) - [4]=> - int(3) -} - --- Iteration 10 -- -array(3) { - [0]=> - string(1) "a" - [1]=> - string(2) "ab" - [2]=> - string(2) "cd" -} - --- Iteration 11 -- -array(4) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - string(0) "" -} - -*** Testing array_keys() on all the types other than arrays *** --- Loose type checking -- -array(3) { - [0]=> - int(1) - [1]=> - int(-1) - [2]=> - string(3) "php" -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(4) { - [0]=> - int(0) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - string(0) "" -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(1) { - [0]=> - int(1) -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(4) { - [0]=> - int(0) - [1]=> - int(2) - [2]=> - string(3) "php" - [3]=> - string(0) "" -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(1) { - [0]=> - int(-1) -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(1) { - [0]=> - int(1) -} - --- strict type checking -- -array(1) { - [0]=> - int(1) -} - --- Loose type checking -- -array(1) { - [0]=> - int(0) -} - --- strict type checking -- -array(1) { - [0]=> - int(0) -} - --- Loose type checking -- -array(1) { - [0]=> - int(-1) -} - --- strict type checking -- -array(1) { - [0]=> - int(-1) -} - --- Loose type checking -- -array(3) { - [0]=> - int(2) - [1]=> - int(3) - [2]=> - string(0) "" -} - --- strict type checking -- -array(1) { - [0]=> - int(2) -} - --- Loose type checking -- -array(2) { - [0]=> - int(2) - [1]=> - int(3) -} - --- strict type checking -- -array(1) { - [0]=> - int(3) -} - --- Loose type checking -- -array(1) { - [0]=> - string(3) "php" -} - --- strict type checking -- -array(1) { - [0]=> - string(3) "php" -} - --- Loose type checking -- -array(2) { - [0]=> - int(2) - [1]=> - string(0) "" -} - --- strict type checking -- -array(1) { - [0]=> - string(0) "" -} - -*** Testing array_keys() with resource type *** -array(1) { - [0]=> - int(0) -} -array(1) { - [0]=> - int(0) -} -array(1) { - [0]=> - int(1) -} -array(1) { - [0]=> - int(1) -} - -*** Testing array_keys() on range of values *** -array(4) { - [0]=> - int(2147483647) - [1]=> - int(-2147483648) - [2]=> - int(-2147483647) - [3]=> - int(0) -} - -*** Testing array_keys() on an array created on the fly *** -array(3) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - [2]=> - string(1) "c" -} -array(0) { -} - -*** Testing error conditions *** -Warning: array_keys() expects parameter 1 to be array, integer given in %s on line %d -NULL - -Warning: array_keys() expects parameter 1 to be array, string given in %s on line %d -NULL - -Warning: array_keys() expects parameter 1 to be array, object given in %s on line %d -NULL - -Warning: array_keys() expects at least 1 parameter, 0 given in %s on line %d -NULL - -Warning: array_keys() expects at most 3 parameters, 4 given in %s on line %d -NULL - -Warning: Illegal offset type in %s on line %d -array(3) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) -} -Done ---UEXPECTF-- -*** Testing array_keys() on basic array operation *** -array(5) { - [0]=> - unicode(1) "a" - [1]=> - unicode(1) "b" - [2]=> - int(2) - [3]=> - int(-23) - [4]=> - int(3) -} - -*** Testing array_keys() on various arrays *** --- Iteration 0 -- -array(0) { -} - --- Iteration 1 -- -array(1) { - [0]=> - int(0) -} - --- Iteration 2 -- -array(1) { - [0]=> - int(0) -} - --- Iteration 3 -- -array(1) { - [0]=> - unicode(5) "Hello" -} - --- Iteration 4 -- -array(1) { - [0]=> - unicode(0) "" -} - --- Iteration 5 -- -array(4) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - unicode(1) "d" -} - --- Iteration 6 -- -array(4) { - [0]=> - unicode(1) "a" - [1]=> - unicode(1) "b" - [2]=> - unicode(1) "c" - [3]=> - unicode(1) "d" -} - --- Iteration 7 -- -array(4) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - int(3) -} - --- Iteration 8 -- -array(5) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - unicode(1) "a" - [3]=> - int(3) - [4]=> - int(5) -} - --- Iteration 9 -- -array(5) { - [0]=> - int(1) - [1]=> - int(0) - [2]=> - unicode(0) "" - [3]=> - int(2) - [4]=> - int(3) -} - --- Iteration 10 -- -array(3) { - [0]=> - unicode(1) "a" - [1]=> - unicode(2) "ab" - [2]=> - unicode(2) "cd" -} - --- Iteration 11 -- -array(4) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - unicode(0) "" -} - -*** Testing array_keys() on all the types other than arrays *** --- Loose type checking -- -array(3) { - [0]=> - int(1) - [1]=> - int(-1) - [2]=> - unicode(3) "php" -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(4) { - [0]=> - int(0) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - unicode(0) "" -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(1) { - [0]=> - int(1) -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(4) { - [0]=> - int(0) - [1]=> - int(2) - [2]=> - unicode(3) "php" - [3]=> - unicode(0) "" -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(1) { - [0]=> - int(-1) -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(1) { - [0]=> - int(1) -} - --- strict type checking -- -array(1) { - [0]=> - int(1) -} - --- Loose type checking -- -array(2) { - [0]=> - int(0) - [1]=> - int(2) -} - --- strict type checking -- -array(1) { - [0]=> - int(0) -} - --- Loose type checking -- -array(1) { - [0]=> - int(-1) -} - --- strict type checking -- -array(1) { - [0]=> - int(-1) -} - --- Loose type checking -- -array(4) { - [0]=> - int(0) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - unicode(0) "" -} - --- strict type checking -- -array(1) { - [0]=> - int(2) -} - --- Loose type checking -- -array(2) { - [0]=> - int(2) - [1]=> - int(3) -} - --- strict type checking -- -array(1) { - [0]=> - int(3) -} - --- Loose type checking -- -array(1) { - [0]=> - unicode(3) "php" -} - --- strict type checking -- -array(1) { - [0]=> - unicode(3) "php" -} - --- Loose type checking -- -array(2) { - [0]=> - int(2) - [1]=> - unicode(0) "" -} - --- strict type checking -- -array(1) { - [0]=> - unicode(0) "" -} - -*** Testing array_keys() with resource type *** -array(1) { - [0]=> - int(0) -} -array(1) { - [0]=> - int(0) -} -array(1) { - [0]=> - int(1) -} -array(1) { - [0]=> - int(1) -} - -*** Testing array_keys() on range of values *** -array(4) { - [0]=> - int(2147483647) - [1]=> - int(-2147483648) - [2]=> - int(-2147483647) - [3]=> - int(0) -} - -*** Testing array_keys() on an array created on the fly *** -array(3) { - [0]=> - unicode(1) "a" - [1]=> - unicode(1) "b" - [2]=> - unicode(1) "c" -} -array(0) { -} - -*** Testing error conditions *** -Warning: array_keys() expects parameter 1 to be array, integer given in %s on line %d -NULL - -Warning: array_keys() expects parameter 1 to be array, Unicode string given in %s on line %d -NULL - -Warning: array_keys() expects parameter 1 to be array, object given in %s on line %d -NULL - -Warning: array_keys() expects at least 1 parameter, 0 given in %s on line %d -NULL - -Warning: array_keys() expects at most 3 parameters, 4 given in %s on line %d -NULL - -Warning: Illegal offset type in %s on line %d -array(3) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) -} -Done diff --git a/ext/standard/tests/array/array_keys_64bit.phpt b/ext/standard/tests/array/array_keys_64bit.phpt deleted file mode 100644 index 3ffba0b4a0..0000000000 --- a/ext/standard/tests/array/array_keys_64bit.phpt +++ /dev/null @@ -1,472 +0,0 @@ ---TEST-- -Test array_keys() function ---SKIPIF-- - ---INI-- -precision=14 ---FILE-- - 1, "b" => 2, 2.0 => 2.0, -23.45 => "asdasd", - array(1,2,3)); -var_dump(array_keys($basic_arr)); - -echo "\n*** Testing array_keys() on various arrays ***"; -$arrays = array( - array(), - array(0), - array( array() ), - array("Hello" => "World"), - array("" => ""), - array(1,2,3, "d" => array(4,6, "d")), - array("a" => 1, "b" => 2, "c" =>3, "d" => array()), - array(0 => 0, 1 => 1, 2 => 2, 3 => 3), - array(0.001=>3.000, 1.002=>2, 1.999=>3, "a"=>3, 3=>5, "5"=>3.000), - array(TRUE => TRUE, FALSE => FALSE, NULL => NULL, "\x000", "\000"), - array("a" => "abcd", "a" => "", "ab" => -6, "cd" => -0.5 ), - array(0 => array(), 1=> array(0), 2 => array(1), ""=> array(),""=>"" ) -); - -$i = 0; -/* loop through to test array_keys() with different arrays */ -foreach ($arrays as $array) { - echo "\n-- Iteration $i --\n"; - var_dump(array_keys($array)); - $i++; -} - -echo "\n*** Testing array_keys() on all the types other than arrays ***"; -$types_arr = array( - TRUE => TRUE, - FALSE => FALSE, - 1 => 1, - 0 => 0, - -1 => -1, - "1" => "1", - "0" => "0", - "-1" => "-1", - NULL, - array(), - "php" => "php", - "" => "" -); -$values = array(TRUE, FALSE, 1, 0, -1, "1", "0", "-1", NULL, array(), "php", ""); -foreach ($values as $value){ - echo "\n-- Loose type checking --\n"; - var_dump(array_keys($types_arr, $value)); - echo "\n-- strict type checking --\n"; - var_dump(array_keys($types_arr, $value, TRUE)); -} - -echo "\n*** Testing array_keys() with resource type ***\n"; -$resource1 = fopen( __FILE__, "r"); -$resource2 = opendir( "." ); - -/* creating an array with resource types as elements */ -$arr_resource = array($resource1, $resource2); - -var_dump(array_keys($arr_resource, $resource1)); // loose type checking -var_dump(array_keys($arr_resource, $resource1, TRUE)); // strict type checking -var_dump(array_keys($arr_resource, $resource2)); // loose type checking -var_dump(array_keys($arr_resource, $resource2, TRUE)); // strict type checking - -echo "\n*** Testing array_keys() on range of values ***\n"; -$arr_range = array( - 2147483647 => 1, - 2147483648 => 2, - -2147483647 => 3, - -2147483648 => 4, - -2147483649 => 5, - -0 => 6, - 0 => 7 -); -var_dump(array_keys($arr_range)); - -echo "\n*** Testing array_keys() on an array created on the fly ***\n"; -var_dump(array_keys(array("a" => 1, "b" => 2, "c" => 3))); -var_dump(array_keys(array())); // null array - -echo "\n*** Testing error conditions ***"; -var_dump(array_keys(100)); -var_dump(array_keys("string")); -var_dump(array_keys(new stdclass)); // object -var_dump(array_keys()); // Zero arguments -var_dump(array_keys(array(), "", TRUE, 100)); // args > expected -var_dump(array_keys(array(1,2,3, array() => array()))); // (W)illegal offset - -echo "Done\n"; - ---CLEAN-- -/* Closing the resource handles */ -fclose( $resource1 ); -closedir( $resource2 ); -?> ---EXPECTF-- -*** Testing array_keys() on basic array operation *** -array(5) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - [2]=> - int(2) - [3]=> - int(-23) - [4]=> - int(3) -} - -*** Testing array_keys() on various arrays *** --- Iteration 0 -- -array(0) { -} - --- Iteration 1 -- -array(1) { - [0]=> - int(0) -} - --- Iteration 2 -- -array(1) { - [0]=> - int(0) -} - --- Iteration 3 -- -array(1) { - [0]=> - string(5) "Hello" -} - --- Iteration 4 -- -array(1) { - [0]=> - string(0) "" -} - --- Iteration 5 -- -array(4) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - string(1) "d" -} - --- Iteration 6 -- -array(4) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - [2]=> - string(1) "c" - [3]=> - string(1) "d" -} - --- Iteration 7 -- -array(4) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - int(3) -} - --- Iteration 8 -- -array(5) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - string(1) "a" - [3]=> - int(3) - [4]=> - int(5) -} - --- Iteration 9 -- -array(5) { - [0]=> - int(1) - [1]=> - int(0) - [2]=> - string(0) "" - [3]=> - int(2) - [4]=> - int(3) -} - --- Iteration 10 -- -array(3) { - [0]=> - string(1) "a" - [1]=> - string(2) "ab" - [2]=> - string(2) "cd" -} - --- Iteration 11 -- -array(4) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [3]=> - string(0) "" -} - -*** Testing array_keys() on all the types other than arrays *** --- Loose type checking -- -array(3) { - [0]=> - int(1) - [1]=> - int(-1) - [2]=> - string(3) "php" -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(4) { - [0]=> - int(0) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - string(0) "" -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(1) { - [0]=> - int(1) -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(4) { - [0]=> - int(0) - [1]=> - int(2) - [2]=> - string(3) "php" - [3]=> - string(0) "" -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(1) { - [0]=> - int(-1) -} - --- strict type checking -- -array(0) { -} - --- Loose type checking -- -array(1) { - [0]=> - int(1) -} - --- strict type checking -- -array(1) { - [0]=> - int(1) -} - --- Loose type checking -- -array(1) { - [0]=> - int(0) -} - --- strict type checking -- -array(1) { - [0]=> - int(0) -} - --- Loose type checking -- -array(1) { - [0]=> - int(-1) -} - --- strict type checking -- -array(1) { - [0]=> - int(-1) -} - --- Loose type checking -- -array(3) { - [0]=> - int(2) - [1]=> - int(3) - [2]=> - string(0) "" -} - --- strict type checking -- -array(1) { - [0]=> - int(2) -} - --- Loose type checking -- -array(2) { - [0]=> - int(2) - [1]=> - int(3) -} - --- strict type checking -- -array(1) { - [0]=> - int(3) -} - --- Loose type checking -- -array(1) { - [0]=> - string(3) "php" -} - --- strict type checking -- -array(1) { - [0]=> - string(3) "php" -} - --- Loose type checking -- -array(2) { - [0]=> - int(2) - [1]=> - string(0) "" -} - --- strict type checking -- -array(1) { - [0]=> - string(0) "" -} - -*** Testing array_keys() with resource type *** -array(1) { - [0]=> - int(0) -} -array(1) { - [0]=> - int(0) -} -array(1) { - [0]=> - int(1) -} -array(1) { - [0]=> - int(1) -} - -*** Testing array_keys() on range of values *** -array(6) { - [0]=> - int(2147483647) - [1]=> - int(2147483648) - [2]=> - int(-2147483647) - [3]=> - int(-2147483648) - [4]=> - int(-2147483649) - [5]=> - int(0) -} - -*** Testing array_keys() on an array created on the fly *** -array(3) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - [2]=> - string(1) "c" -} -array(0) { -} - -*** Testing error conditions *** -Warning: array_keys(): The first argument should be an array in %s on line %d -NULL - -Warning: array_keys(): The first argument should be an array in %s on line %d -NULL - -Warning: array_keys(): The first argument should be an array in %s on line %d -NULL - -Warning: Wrong parameter count for array_keys() in %s on line %d -NULL - -Warning: Wrong parameter count for array_keys() in %s on line %d -NULL - -Warning: Illegal offset type in %s on line %d -array(3) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) -} -Done diff --git a/ext/standard/tests/array/array_keys_basic.phpt b/ext/standard/tests/array/array_keys_basic.phpt new file mode 100644 index 0000000000..a770bda657 --- /dev/null +++ b/ext/standard/tests/array/array_keys_basic.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test array_keys() function (basic) +--FILE-- + 1, "b" => 2, 2.0 => 2.0, -23.45 => "asdasd", + array(1,2,3)); +var_dump(array_keys($basic_arr)); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing array_keys() on basic array operation *** +array(5) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + int(2) + [3]=> + int(-23) + [4]=> + int(3) +} +Done +--UEXPECTF-- +*** Testing array_keys() on basic array operation *** +array(5) { + [0]=> + unicode(1) "a" + [1]=> + unicode(1) "b" + [2]=> + int(2) + [3]=> + int(-23) + [4]=> + int(3) +} +Done diff --git a/ext/standard/tests/array/array_keys_error.phpt b/ext/standard/tests/array/array_keys_error.phpt new file mode 100644 index 0000000000..4522fe0098 --- /dev/null +++ b/ext/standard/tests/array/array_keys_error.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test array_keys() function (error conditions) +--FILE-- + expected +var_dump(array_keys(array(1,2,3, array() => array()))); // (W)illegal offset + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing error conditions *** +Warning: array_keys() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_keys() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_keys() expects parameter 1 to be array, object given in %s on line %d +NULL + +Warning: array_keys() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: array_keys() expects at most 3 parameters, 4 given in %s on line %d +NULL + +Warning: Illegal offset type in %s on line %d +array(3) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) +} +Done +--UEXPECTF-- +*** Testing error conditions *** +Warning: array_keys() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_keys() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_keys() expects parameter 1 to be array, object given in %s on line %d +NULL + +Warning: array_keys() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: array_keys() expects at most 3 parameters, 4 given in %s on line %d +NULL + +Warning: Illegal offset type in %s on line %d +array(3) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) +} +Done diff --git a/ext/standard/tests/array/array_keys_variation_001.phpt b/ext/standard/tests/array/array_keys_variation_001.phpt new file mode 100644 index 0000000000..91b5744bc4 --- /dev/null +++ b/ext/standard/tests/array/array_keys_variation_001.phpt @@ -0,0 +1,263 @@ +--TEST-- +Test array_keys() function (variation - 1) +--FILE-- + "World"), + array("" => ""), + array(1,2,3, "d" => array(4,6, "d")), + array("a" => 1, "b" => 2, "c" =>3, "d" => array()), + array(0 => 0, 1 => 1, 2 => 2, 3 => 3), + array(0.001=>3.000, 1.002=>2, 1.999=>3, "a"=>3, 3=>5, "5"=>3.000), + array(TRUE => TRUE, FALSE => FALSE, NULL => NULL, "\x000", "\000"), + array("a" => "abcd", "a" => "", "ab" => -6, "cd" => -0.5 ), + array(0 => array(), 1=> array(0), 2 => array(1), ""=> array(),""=>"" ) +); + +$i = 0; +/* loop through to test array_keys() with different arrays */ +foreach ($arrays as $array) { + echo "\n-- Iteration $i --\n"; + var_dump(array_keys($array)); + $i++; +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing array_keys() on various arrays *** +-- Iteration 0 -- +array(0) { +} + +-- Iteration 1 -- +array(1) { + [0]=> + int(0) +} + +-- Iteration 2 -- +array(1) { + [0]=> + int(0) +} + +-- Iteration 3 -- +array(1) { + [0]=> + string(5) "Hello" +} + +-- Iteration 4 -- +array(1) { + [0]=> + string(0) "" +} + +-- Iteration 5 -- +array(4) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + string(1) "d" +} + +-- Iteration 6 -- +array(4) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "c" + [3]=> + string(1) "d" +} + +-- Iteration 7 -- +array(4) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + int(3) +} + +-- Iteration 8 -- +array(5) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + string(1) "a" + [3]=> + int(3) + [4]=> + int(5) +} + +-- Iteration 9 -- +array(5) { + [0]=> + int(1) + [1]=> + int(0) + [2]=> + string(0) "" + [3]=> + int(2) + [4]=> + int(3) +} + +-- Iteration 10 -- +array(3) { + [0]=> + string(1) "a" + [1]=> + string(2) "ab" + [2]=> + string(2) "cd" +} + +-- Iteration 11 -- +array(4) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + string(0) "" +} +Done +--UEXPECTF-- +*** Testing array_keys() on various arrays *** +-- Iteration 0 -- +array(0) { +} + +-- Iteration 1 -- +array(1) { + [0]=> + int(0) +} + +-- Iteration 2 -- +array(1) { + [0]=> + int(0) +} + +-- Iteration 3 -- +array(1) { + [0]=> + unicode(5) "Hello" +} + +-- Iteration 4 -- +array(1) { + [0]=> + unicode(0) "" +} + +-- Iteration 5 -- +array(4) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + unicode(1) "d" +} + +-- Iteration 6 -- +array(4) { + [0]=> + unicode(1) "a" + [1]=> + unicode(1) "b" + [2]=> + unicode(1) "c" + [3]=> + unicode(1) "d" +} + +-- Iteration 7 -- +array(4) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + int(3) +} + +-- Iteration 8 -- +array(5) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + unicode(1) "a" + [3]=> + int(3) + [4]=> + int(5) +} + +-- Iteration 9 -- +array(5) { + [0]=> + int(1) + [1]=> + int(0) + [2]=> + unicode(0) "" + [3]=> + int(2) + [4]=> + int(3) +} + +-- Iteration 10 -- +array(3) { + [0]=> + unicode(1) "a" + [1]=> + unicode(2) "ab" + [2]=> + unicode(2) "cd" +} + +-- Iteration 11 -- +array(4) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + unicode(0) "" +} +Done diff --git a/ext/standard/tests/array/array_keys_variation_002.phpt b/ext/standard/tests/array/array_keys_variation_002.phpt new file mode 100644 index 0000000000..0aa01f69c9 --- /dev/null +++ b/ext/standard/tests/array/array_keys_variation_002.phpt @@ -0,0 +1,77 @@ +--TEST-- +Test array_keys() function (variation - 2) +--SKIPIF-- + +--FILE-- + 1, + 2147483648 => 2, + -2147483647 => 3, + -2147483648 => 4, + -2147483649 => 5, + -0 => 6, + 0 => 7 +); +var_dump(array_keys($arr_range)); + +echo "\n*** Testing array_keys() on an array created on the fly ***\n"; +var_dump(array_keys(array("a" => 1, "b" => 2, "c" => 3))); +var_dump(array_keys(array())); // null array + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing array_keys() on range of values *** +array(4) { + [0]=> + int(2147483647) + [1]=> + int(-2147483648) + [2]=> + int(-2147483647) + [3]=> + int(0) +} + +*** Testing array_keys() on an array created on the fly *** +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "c" +} +array(0) { +} +Done +--UEXPECTF-- +*** Testing array_keys() on range of values *** +array(4) { + [0]=> + int(2147483647) + [1]=> + int(-2147483648) + [2]=> + int(-2147483647) + [3]=> + int(0) +} + +*** Testing array_keys() on an array created on the fly *** +array(3) { + [0]=> + unicode(1) "a" + [1]=> + unicode(1) "b" + [2]=> + unicode(1) "c" +} +array(0) { +} +Done diff --git a/ext/standard/tests/array/array_keys_variation_003.phpt b/ext/standard/tests/array/array_keys_variation_003.phpt new file mode 100644 index 0000000000..c0f219b058 --- /dev/null +++ b/ext/standard/tests/array/array_keys_variation_003.phpt @@ -0,0 +1,177 @@ +--TEST-- +Test array_keys() function (variation - 3) +--FILE-- + TRUE, + FALSE => FALSE, + 1 => 1, + 0 => 0, + -1 => -1, + "1" => "1", + "0" => "0", + "-1" => "-1", + NULL, + array(), + "php" => "php", + "" => "" +); +$values = array(TRUE, FALSE, 1, 0, -1, "1", "0", "-1", NULL, array(), "php", ""); +foreach ($values as $value){ + var_dump(array_keys($types_arr, $value)); +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing array_keys() on all the types other than arrays *** +array(3) { + [0]=> + int(1) + [1]=> + int(-1) + [2]=> + string(3) "php" +} +array(4) { + [0]=> + int(0) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + string(0) "" +} +array(1) { + [0]=> + int(1) +} +array(4) { + [0]=> + int(0) + [1]=> + int(2) + [2]=> + string(3) "php" + [3]=> + string(0) "" +} +array(1) { + [0]=> + int(-1) +} +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(-1) +} +array(3) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + string(0) "" +} +array(2) { + [0]=> + int(2) + [1]=> + int(3) +} +array(1) { + [0]=> + string(3) "php" +} +array(2) { + [0]=> + int(2) + [1]=> + string(0) "" +} +Done +--UEXPECTF-- +*** Testing array_keys() on all the types other than arrays *** +array(3) { + [0]=> + int(1) + [1]=> + int(-1) + [2]=> + unicode(3) "php" +} +array(4) { + [0]=> + int(0) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + unicode(0) "" +} +array(1) { + [0]=> + int(1) +} +array(4) { + [0]=> + int(0) + [1]=> + int(2) + [2]=> + unicode(3) "php" + [3]=> + unicode(0) "" +} +array(1) { + [0]=> + int(-1) +} +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(-1) +} +array(3) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + unicode(0) "" +} +array(2) { + [0]=> + int(2) + [1]=> + int(3) +} +array(1) { + [0]=> + unicode(3) "php" +} +array(2) { + [0]=> + int(2) + [1]=> + unicode(0) "" +} +Done diff --git a/ext/standard/tests/array/array_keys_variation_004.phpt b/ext/standard/tests/array/array_keys_variation_004.phpt new file mode 100644 index 0000000000..49ca95adbd --- /dev/null +++ b/ext/standard/tests/array/array_keys_variation_004.phpt @@ -0,0 +1,109 @@ +--TEST-- +Test array_keys() function (variation - 4) +--FILE-- + TRUE, + FALSE => FALSE, + 1 => 1, + 0 => 0, + -1 => -1, + "1" => "1", + "0" => "0", + "-1" => "-1", + NULL, + array(), + "php" => "php", + "" => "" +); +$values = array(TRUE, FALSE, 1, 0, -1, "1", "0", "-1", NULL, array(), "php", ""); +foreach ($values as $value){ + var_dump(array_keys($types_arr, $value, TRUE)); +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing array_keys() on all the types other than arrays *** +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(-1) +} +array(1) { + [0]=> + int(2) +} +array(1) { + [0]=> + int(3) +} +array(1) { + [0]=> + string(3) "php" +} +array(1) { + [0]=> + string(0) "" +} +Done +--UEXPECTF-- +*** Testing array_keys() on all the types other than arrays *** +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(-1) +} +array(1) { + [0]=> + int(2) +} +array(1) { + [0]=> + int(3) +} +array(1) { + [0]=> + unicode(3) "php" +} +array(1) { + [0]=> + unicode(0) "" +} +Done diff --git a/ext/standard/tests/array/array_keys_variation_005.phpt b/ext/standard/tests/array/array_keys_variation_005.phpt new file mode 100644 index 0000000000..9a912d68ed --- /dev/null +++ b/ext/standard/tests/array/array_keys_variation_005.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test array_keys() function (variation - 5) +--FILE-- + +--EXPECTF-- +*** Testing array_keys() with resource type *** +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +}