Annotation of embedaddon/php/ext/standard/tests/array/array_walk_error1.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test array_walk() function : error conditions
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : bool array_walk(array $input, string $funcname [, mixed $userdata])
                      6:  * Description: Apply a user function to every member of an array 
                      7:  * Source code: ext/standard/array.c
                      8: */
                      9: 
                     10: $input = array(1, 2);
                     11: 
                     12: /* Prototype : callback(mixed value, mixed key, mixed user_data)
                     13:  * Parameters : value - value in key/value pair
                     14:  *              key - key in key/value pair
                     15:  *              user_data - extra parameter
                     16:  */
                     17: function callback ($value, $key, $user_data) {
                     18:   echo "\ncallback() invoked \n";
                     19: }
                     20: 
                     21: echo "*** Testing array_walk() : error conditions ***\n";
                     22: 
                     23: echo "-- Testing array_walk() function with zero arguments --\n";
                     24: var_dump( array_walk() );
                     25: 
                     26: echo "-- Testing array_walk() function with one argument --\n";
                     27: var_dump( array_walk($input) );
                     28: 
                     29: echo "-- Testing array_walk() function with non existent callback function  --\n";
                     30: var_dump( array_walk($input, "non_existent") );
                     31: 
                     32: echo "Done";
                     33: ?>
                     34: --EXPECTF--
                     35: *** Testing array_walk() : error conditions ***
                     36: -- Testing array_walk() function with zero arguments --
                     37: 
                     38: Warning: array_walk() expects at least 2 parameters, 0 given in %s on line %d
                     39: NULL
                     40: -- Testing array_walk() function with one argument --
                     41: 
                     42: Warning: array_walk() expects at least 2 parameters, 1 given in %s on line %d
                     43: NULL
                     44: -- Testing array_walk() function with non existent callback function  --
                     45: 
                     46: Warning: array_walk() expects parameter 2 to be a valid callback, function 'non_existent' not found or invalid function name in %s on line %d
                     47: NULL
                     48: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>