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

1.1       misho       1: --TEST--
                      2: Test array_intersect_uassoc() function : error conditions 
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : array array_intersect_uassoc(array arr1, array arr2 [, array ...], callback key_compare_func)
                      6:  * Description: Computes the intersection of arrays with additional index check, compares indexes by a callback function
                      7:  * Source code: ext/standard/array.c
                      8:  */
                      9: 
                     10: echo "*** Testing array_intersect_uassoc() : error conditions ***\n";
                     11: 
                     12: // Initialise function arguments 
                     13: $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
                     14: $array2 = array("a" => "green", "yellow", "red");
                     15: $array3 = array("a"=>"green", "brown");
                     16: $extra_arg = 10;
                     17: 
                     18: //Callback function
                     19: function key_compare_func($a, $b) {
                     20:     if ($a === $b) {
                     21:         return 0;
                     22:     }
                     23:     return ($a > $b) ? 1 : -1;
                     24: }
                     25: 
                     26: //Test array_intersect_uassoc with one more than the expected number of arguments
                     27: echo "\n-- Testing array_intersect_uassoc() function with more than expected no. of arguments --\n";
                     28: var_dump( array_intersect_uassoc($array1, $array2, 'key_compare_func',$extra_arg) );
                     29: 
                     30: // Testing array_intersect_uassoc with one less than the expected number of arguments
                     31: echo "\n-- Testing array_intersect_uassoc() function with less than expected no. of arguments --\n";
                     32: var_dump( array_intersect_uassoc($array1, $array2) );
                     33: var_dump( array_intersect_uassoc($array1, $array2, $array3) );
                     34: 
                     35: // Testing array_intersect_uassoc with no arguments
                     36: echo "\n-- Testing array_intersect_uassoc() function with no arguments --\n";
                     37: var_dump( array_intersect_uassoc() );
                     38: ?>
                     39: ===DONE===
                     40: --EXPECTF--
                     41: *** Testing array_intersect_uassoc() : error conditions ***
                     42: 
                     43: -- Testing array_intersect_uassoc() function with more than expected no. of arguments --
                     44: 
                     45: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                     46: NULL
                     47: 
                     48: -- Testing array_intersect_uassoc() function with less than expected no. of arguments --
                     49: 
                     50: Warning: array_intersect_uassoc(): at least 3 parameters are required, 2 given in %s on line %d
                     51: NULL
                     52: 
                     53: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, second array member is not a valid method in %s on line %d
                     54: NULL
                     55: 
                     56: -- Testing array_intersect_uassoc() function with no arguments --
                     57: 
                     58: Warning: array_intersect_uassoc(): at least 3 parameters are required, 0 given in %s on line %d
                     59: NULL
                     60: ===DONE===

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