Annotation of embedaddon/php/ext/standard/tests/array/krsort_error.phpt, revision 1.1

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

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