Annotation of embedaddon/php/ext/standard/tests/file/fgetc_error.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test fgetc() function : error conditions
        !             3: --FILE--
        !             4: <?php
        !             5: /*
        !             6:  Prototype: string fgetc ( resource $handle );
        !             7:  Description: Gets character from file pointer
        !             8: */
        !             9: 
        !            10: echo "*** Testing error conditions ***\n";
        !            11: // zero argument
        !            12: echo "-- Testing fgetc() with zero argument --\n";
        !            13: var_dump( fgetc() );
        !            14: 
        !            15: // more than expected no. of args
        !            16: echo "-- Testing fgetc() with more than expected number of arguments --\n";
        !            17: $fp = fopen(__FILE__, "r");
        !            18: var_dump( fgetc($fp, $fp) );
        !            19: fclose($fp);
        !            20: 
        !            21: // test invalid arguments : non-resources
        !            22: echo "-- Testing fgetc() with invalid arguments --\n";
        !            23: $invalid_args = array (
        !            24:   "string",
        !            25:   10,
        !            26:   10.5,
        !            27:   true,
        !            28:   array(1,2,3),
        !            29:   new stdclass,
        !            30: );
        !            31: /* loop to test fgetc() with different invalid type of args */
        !            32: for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
        !            33:   echo "-- Iteration $loop_counter --\n";
        !            34:   var_dump( fgetc($invalid_args[$loop_counter - 1]) );
        !            35: }
        !            36: 
        !            37: echo "Done\n";
        !            38: --EXPECTF--
        !            39: *** Testing error conditions ***
        !            40: -- Testing fgetc() with zero argument --
        !            41: 
        !            42: Warning: fgetc() expects exactly 1 parameter, 0 given in %s on line %d
        !            43: bool(false)
        !            44: -- Testing fgetc() with more than expected number of arguments --
        !            45: 
        !            46: Warning: fgetc() expects exactly 1 parameter, 2 given in %s on line %d
        !            47: bool(false)
        !            48: -- Testing fgetc() with invalid arguments --
        !            49: -- Iteration 1 --
        !            50: 
        !            51: Warning: fgetc() expects parameter 1 to be resource, string given in %s on line %d
        !            52: bool(false)
        !            53: -- Iteration 2 --
        !            54: 
        !            55: Warning: fgetc() expects parameter 1 to be resource, integer given in %s on line %d
        !            56: bool(false)
        !            57: -- Iteration 3 --
        !            58: 
        !            59: Warning: fgetc() expects parameter 1 to be resource, double given in %s on line %d
        !            60: bool(false)
        !            61: -- Iteration 4 --
        !            62: 
        !            63: Warning: fgetc() expects parameter 1 to be resource, boolean given in %s on line %d
        !            64: bool(false)
        !            65: -- Iteration 5 --
        !            66: 
        !            67: Warning: fgetc() expects parameter 1 to be resource, array given in %s on line %d
        !            68: bool(false)
        !            69: -- Iteration 6 --
        !            70: 
        !            71: Warning: fgetc() expects parameter 1 to be resource, object given in %s on line %d
        !            72: bool(false)
        !            73: Done

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