Annotation of embedaddon/php/ext/standard/tests/file/flock_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test flock() function: Basic functionality
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 flock() fun with file and dir ***\n";
12: $file_path = dirname(__FILE__);
13:
14: $file_handle = fopen("$file_path/lock.tmp", "w");
15: var_dump(flock($file_handle, LOCK_SH|LOCK_NB));
16: var_dump(flock($file_handle, LOCK_UN));
17: var_dump(flock($file_handle, LOCK_EX));
18: var_dump(flock($file_handle, LOCK_UN));
19: fclose($file_handle);
20: unlink("$file_path/lock.tmp");
21:
22: mkdir("$file_path/dir");
23: $dir_handle = opendir("$file_path/dir");
24: var_dump(flock($dir_handle, LOCK_SH|LOCK_NB));
25: var_dump(flock($dir_handle, LOCK_UN));
26: var_dump(flock($dir_handle, LOCK_EX));
27: var_dump(flock($dir_handle, LOCK_UN));
28: closedir($dir_handle);
29: rmdir("$file_path/dir");
30:
31: echo "\n*** Done ***\n";
32: ?>
33: --EXPECTF--
34: *** Testing flock() fun with file and dir ***
35: bool(true)
36: bool(true)
37: bool(true)
38: bool(true)
39: bool(false)
40: bool(false)
41: bool(false)
42: bool(false)
43:
44: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>