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

1.1     ! misho       1: --TEST--
        !             2: Test flock() function: Error conditions
        !             3: --FILE--
        !             4: <?php
        !             5: /* 
        !             6: Prototype: bool flock(resource $handle, int $operation [, int &$wouldblock]);
        !             7: Description: PHP supports a portable way of locking complete files 
        !             8:   in an advisory way
        !             9: */
        !            10: 
        !            11: echo "*** Testing error conditions ***\n";
        !            12: 
        !            13: $file = dirname(__FILE__)."/flock.tmp";
        !            14: $fp = fopen($file, "w");
        !            15: 
        !            16: /* array of operatons */
        !            17: $operations = array(
        !            18:   0,
        !            19:   LOCK_NB,
        !            20:   FALSE,
        !            21:   NULL,
        !            22:   array(1,2,3),
        !            23:   array(),
        !            24:   "string",
        !            25:   "",
        !            26:   "\0" 
        !            27: );
        !            28: 
        !            29: $i = 0;
        !            30: foreach($operations as $operation) {
        !            31:   echo "\n--- Iteration $i ---";
        !            32:   var_dump(flock($fp, $operation));
        !            33:   $i++;
        !            34: }
        !            35: 
        !            36: 
        !            37: /* Invalid arguments */
        !            38: $fp = fopen($file, "w");
        !            39: fclose($fp);
        !            40: var_dump(flock($fp, LOCK_SH|LOCK_NB));
        !            41: 
        !            42: var_dump(flock("", "", $var));
        !            43: 
        !            44: /* No.of args leass than expected */
        !            45: var_dump(flock());
        !            46: var_dump(flock($fp));
        !            47: 
        !            48: /* No.of args greater than expected */
        !            49: var_dump(flock($fp, "", $var, ""));
        !            50: 
        !            51: echo "\n*** Done ***\n";
        !            52: ?>
        !            53: --CLEAN--
        !            54: <?php
        !            55: $file = dirname(__FILE__)."/flock.tmp";
        !            56: unlink($file);
        !            57: ?>
        !            58: --EXPECTF--    
        !            59: *** Testing error conditions ***
        !            60: 
        !            61: --- Iteration 0 ---
        !            62: Warning: flock(): Illegal operation argument in %s on line %d
        !            63: bool(false)
        !            64: 
        !            65: --- Iteration 1 ---
        !            66: Warning: flock(): Illegal operation argument in %s on line %d
        !            67: bool(false)
        !            68: 
        !            69: --- Iteration 2 ---
        !            70: Warning: flock(): Illegal operation argument in %s on line %d
        !            71: bool(false)
        !            72: 
        !            73: --- Iteration 3 ---
        !            74: Warning: flock(): Illegal operation argument in %s on line %d
        !            75: bool(false)
        !            76: 
        !            77: --- Iteration 4 ---
        !            78: Warning: flock() expects parameter 2 to be long, array given in %s on line %d
        !            79: NULL
        !            80: 
        !            81: --- Iteration 5 ---
        !            82: Warning: flock() expects parameter 2 to be long, array given in %s on line %d
        !            83: NULL
        !            84: 
        !            85: --- Iteration 6 ---
        !            86: Warning: flock() expects parameter 2 to be long, string given in %s on line %d
        !            87: NULL
        !            88: 
        !            89: --- Iteration 7 ---
        !            90: Warning: flock() expects parameter 2 to be long, string given in %s on line %d
        !            91: NULL
        !            92: 
        !            93: --- Iteration 8 ---
        !            94: Warning: flock() expects parameter 2 to be long, string given in %s on line %d
        !            95: NULL
        !            96: 
        !            97: Warning: flock(): %d is not a valid stream resource in %s on line %d
        !            98: bool(false)
        !            99: 
        !           100: Warning: flock() expects parameter 1 to be resource, string given in %s on line %d
        !           101: NULL
        !           102: 
        !           103: Warning: flock() expects at least 2 parameters, 0 given in %s on line %d
        !           104: NULL
        !           105: 
        !           106: Warning: flock() expects at least 2 parameters, 1 given in %s on line %d
        !           107: NULL
        !           108: 
        !           109: Warning: flock() expects at most 3 parameters, 4 given in %s on line %d
        !           110: NULL
        !           111: 
        !           112: *** Done ***

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