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

1.1       misho       1: --TEST--
                      2: Test arsort() function : error conditions 
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : bool arsort(array &array_arg [, int sort_flags])
                      6:  * Description: Sort an array 
                      7:  * Source code: ext/standard/array.c
                      8: */
                      9: 
                     10: /*
                     11: * Testing arsort() function with all possible error conditions 
                     12: */
                     13: 
                     14: echo "*** Testing arsort() : error conditions ***\n";
                     15: 
                     16: // Zero arguments
                     17: echo "\n-- Testing arsort() function with Zero arguments --\n";
                     18: var_dump( arsort() );
                     19: 
                     20: //Test arsort with more than the expected number of arguments
                     21: echo "\n-- Testing arsort() function with more than expected no. of arguments --\n";
                     22: $array_arg = array(1, 2);
                     23: $flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING, "SORT_NUMERIC" => SORT_NUMERIC);
                     24: $extra_arg = 10;
                     25: 
                     26: // loop through $flag_value array and setting all possible flag values
                     27: foreach($flags as $key => $flag){
                     28:   echo "\nSort flag = $key\n";
                     29:   var_dump( arsort($array_arg,$flag, $extra_arg) );
                     30: 
                     31:   // dump the input array to ensure that it wasn't changed
                     32:   var_dump($array_arg);
                     33: }
                     34: 
                     35: echo "Done";
                     36: ?>
                     37: --EXPECTF--
                     38: *** Testing arsort() : error conditions ***
                     39: 
                     40: -- Testing arsort() function with Zero arguments --
                     41: 
                     42: Warning: arsort() expects at least 1 parameter, 0 given in %sarsort_error.php on line %d
                     43: bool(false)
                     44: 
                     45: -- Testing arsort() function with more than expected no. of arguments --
                     46: 
                     47: Sort flag = SORT_REGULAR
                     48: 
                     49: Warning: arsort() expects at most 2 parameters, 3 given in %sarsort_error.php on line %d
                     50: bool(false)
                     51: array(2) {
                     52:   [0]=>
                     53:   int(1)
                     54:   [1]=>
                     55:   int(2)
                     56: }
                     57: 
                     58: Sort flag = SORT_STRING
                     59: 
                     60: Warning: arsort() expects at most 2 parameters, 3 given in %sarsort_error.php on line %d
                     61: bool(false)
                     62: array(2) {
                     63:   [0]=>
                     64:   int(1)
                     65:   [1]=>
                     66:   int(2)
                     67: }
                     68: 
                     69: Sort flag = SORT_NUMERIC
                     70: 
                     71: Warning: arsort() expects at most 2 parameters, 3 given in %sarsort_error.php on line %d
                     72: bool(false)
                     73: array(2) {
                     74:   [0]=>
                     75:   int(1)
                     76:   [1]=>
                     77:   int(2)
                     78: }
                     79: Done

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