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

1.1     ! misho       1: --TEST--
        !             2: Test fseek(), ftell() & rewind() functions : error conditions - fseek() 
        !             3: --FILE--
        !             4: <?php
        !             5: 
        !             6: /* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
        !             7:    Description: Seeks on a file pointer
        !             8: 
        !             9:    Prototype: bool rewind ( resource $handle );
        !            10:    Description: Rewind the position of a file pointer
        !            11: 
        !            12:    Prototype: int ftell ( resource $handle );
        !            13:    Description: Tells file pointer read/write position
        !            14: */
        !            15: 
        !            16: echo "*** Testing fseek() : error conditions ***\n";
        !            17: // zero argument
        !            18: echo "-- Testing fseek() with zero argument --\n";
        !            19: var_dump( fseek() );
        !            20: 
        !            21: // unexpected no. of args
        !            22: echo "-- Testing fseek() with unexpected number of arguments --\n";
        !            23: $fp = fopen(__FILE__, "r");
        !            24: var_dump( fseek($fp) );
        !            25: var_dump( fseek($fp, 10, $fp,10) );
        !            26: 
        !            27: // test invalid arguments : non-resources
        !            28: echo "-- Testing fseek() with invalid arguments --\n";
        !            29: $invalid_args = array (
        !            30:   "string",
        !            31:   10,
        !            32:   10.5,
        !            33:   true,
        !            34:   array(1,2,3),
        !            35:   new stdclass
        !            36: );
        !            37: /* loop to test fseek() with different invalid type of args */
        !            38: for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
        !            39:   echo "-- Iteration $loop_counter --\n";
        !            40:   var_dump( fseek($invalid_args[$loop_counter - 1], 10) );
        !            41: }
        !            42: 
        !            43: // fseek() on a file handle which is already closed
        !            44: echo "-- Testing fseek() with closed/unset file handle --";
        !            45: fclose($fp);
        !            46: var_dump(fseek($fp,10));
        !            47: 
        !            48: // fseek() on a file handle which is unset
        !            49: $file_handle = fopen(__FILE__, "r");
        !            50: unset($file_handle); //unset file handle
        !            51: var_dump( fseek(@$file_handle,10));
        !            52: 
        !            53: echo "Done\n";
        !            54: ?>
        !            55: --EXPECTF--
        !            56: *** Testing fseek() : error conditions ***
        !            57: -- Testing fseek() with zero argument --
        !            58: 
        !            59: Warning: fseek() expects at least 2 parameters, 0 given in %s on line %d
        !            60: bool(false)
        !            61: -- Testing fseek() with unexpected number of arguments --
        !            62: 
        !            63: Warning: fseek() expects at least 2 parameters, 1 given in %s on line %d
        !            64: bool(false)
        !            65: 
        !            66: Warning: fseek() expects at most 3 parameters, 4 given in %s on line %d
        !            67: bool(false)
        !            68: -- Testing fseek() with invalid arguments --
        !            69: -- Iteration 1 --
        !            70: 
        !            71: Warning: fseek() expects parameter 1 to be resource, string given in %s on line %d
        !            72: bool(false)
        !            73: -- Iteration 2 --
        !            74: 
        !            75: Warning: fseek() expects parameter 1 to be resource, integer given in %s on line %d
        !            76: bool(false)
        !            77: -- Iteration 3 --
        !            78: 
        !            79: Warning: fseek() expects parameter 1 to be resource, double given in %s on line %d
        !            80: bool(false)
        !            81: -- Iteration 4 --
        !            82: 
        !            83: Warning: fseek() expects parameter 1 to be resource, boolean given in %s on line %d
        !            84: bool(false)
        !            85: -- Iteration 5 --
        !            86: 
        !            87: Warning: fseek() expects parameter 1 to be resource, array given in %s on line %d
        !            88: bool(false)
        !            89: -- Iteration 6 --
        !            90: 
        !            91: Warning: fseek() expects parameter 1 to be resource, object given in %s on line %d
        !            92: bool(false)
        !            93: -- Testing fseek() with closed/unset file handle --
        !            94: Warning: fseek(): %d is not a valid stream resource in %s on line %d
        !            95: bool(false)
        !            96: 
        !            97: Warning: fseek() expects parameter 1 to be resource, null given in %s on line %d
        !            98: bool(false)
        !            99: Done

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