Annotation of embedaddon/php/ext/standard/tests/file/lstat_stat_variation9.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test lstat() and stat() functions: usage variations - deleting file/subdir
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) == 'WIN') {
6: die('skip.. Not valid for Windows');
7: }
8: ?>
9: --FILE--
10: <?php
11: /* Prototype: array lstat ( string $filename );
12: Description: Gives information about a file or symbolic link
13:
14: Prototype: array stat ( string $filename );
15: Description: Gives information about a file
16: */
17:
18: $file_path = dirname(__FILE__);
19: require "$file_path/file.inc";
20:
21: /* test the effects on stats by deleting file/subdir from a dir
22: */
23:
24: echo "*** Testing stat() for comparing stats after the deletion of subdir and file ***\n";
25:
26: /* first create the dir/subdir and files, record the stat */
27: @rmdir("$file_path/lstat_stat_variation9/"); // ensure that dir doesn't exists
28: mkdir("$file_path/lstat_stat_variation9/"); // temp dir
29:
30: // creating and deleting subdir and files in the dir
31: $dirname = "$file_path/lstat_stat_variation9";
32: @rmdir("$dirname/lstat_stat_variation9_subdir"); // ensure that dir doesn't exists
33: mkdir("$dirname/lstat_stat_variation9_subdir");
34: $file_handle = fopen("$dirname/lstat_stat_variation9a.tmp", "w");
35: fclose($file_handle);
36:
37: $old_stat = stat($dirname);
38:
39: /* now delete the surdir and file and record the stat */
40: unlink("$dirname/lstat_stat_variation9a.tmp");
41: rmdir("$dirname/lstat_stat_variation9_subdir");
42:
43: // comparing stats after the deletion of subdir and file
44: $new_stat = stat($dirname);
45: // compare self stats
46: var_dump( compare_self_stat($old_stat) );
47: var_dump( compare_self_stat($new_stat) );
48:
49: // compare the stats
50: $affected_members = array(3, 'nlink');
51: var_dump(compare_stats($old_stat, $new_stat, $affected_members, ">"));
52:
53: echo "\n--- Done ---";
54: ?>
55:
56: --CLEAN--
57: <?php
58: $file_path = dirname(__FILE__);
59: $dirname = "$file_path/lstat_stat_variation9";
60: rmdir($dirname);
61: ?>
62: --EXPECTF--
63: *** Testing stat() for comparing stats after the deletion of subdir and file ***
64: bool(true)
65: bool(true)
66: bool(true)
67:
68: --- Done ---
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>