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

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

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