summaryrefslogtreecommitdiff
path: root/ext/standard/tests/file/flock.phpt
blob: 2330270113536f2ac006cbc6a4f38253c0ff77df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--TEST--
flock() tests
--FILE--
<?php

$file = dirname(__FILE__)."/flock.dat";

var_dump(flock());
var_dump(flock("", "", $var));

$fp = fopen($file, "w");
fclose($fp);

var_dump(flock($fp, LOCK_SH|LOCK_NB));

$fp = fopen($file, "w");

var_dump(flock($fp, LOCK_SH|LOCK_NB));
var_dump(flock($fp, LOCK_UN));
var_dump(flock($fp, LOCK_EX));
var_dump(flock($fp, LOCK_UN));

$would = array(1,2,3);
var_dump(flock($fp, LOCK_SH|LOCK_NB, $would));
var_dump($would);
var_dump(flock($fp, LOCK_UN, $would));
var_dump($would);
var_dump(flock($fp, LOCK_EX, $would));
var_dump($would);
var_dump(flock($fp, LOCK_UN, $would));
var_dump($would);

var_dump(flock($fp, -1));
var_dump(flock($fp, 0));

echo "Done\n";
?>
--CLEAN--
<?php
$file = dirname(__FILE__)."/flock.dat";
unlink($file);
?>
--EXPECTF--
Warning: flock() expects at least 2 parameters, 0 given in %s on line %d
NULL

Warning: flock() expects parameter 1 to be resource, string given in %s on line %d
NULL

Warning: flock(): supplied resource is not a valid stream resource in %s on line %d
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
int(0)
bool(true)
int(0)
bool(true)
int(0)
bool(true)
int(0)
bool(true)

Warning: flock(): Illegal operation argument in %s on line %d
bool(false)
Done