Annotation of embedaddon/php/ext/standard/tests/file/lstat_stat_variation4.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test lstat() and stat() functions: usage variations - effects of touch() on file
3: --SKIPIF--
4: <?php
5: if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
6: if (substr(PHP_OS, 0, 3) == 'WIN') {
7: die('skip.. Not valid for Windows');
8: }
9: ?>
10: --FILE--
11: <?php
12: /* Prototype: array lstat ( string $filename );
13: Description: Gives information about a file or symbolic link
14:
15: Prototype: array stat ( string $filename );
16: Description: Gives information about a file
17: */
18:
19: /* test the effects of touch() on stats of file */
20:
21: $file_path = dirname(__FILE__);
22: require "$file_path/file.inc";
23:
24:
25: /* create temp file */
26:
27: $file_name = "$file_path/lstat_stat_variation4.tmp";
28: $fp = fopen($file_name, "w"); // temp file
29: fclose($fp);
30:
31: // touch a file check stat, there should be difference in atime
32: echo "*** Testing stat() for file after using touch() on the file ***\n";
33: $old_stat = stat($file_name);
34: // clear the cache
35: clearstatcache();
36: sleep(2);
37: var_dump( touch($file_name) );
38: $new_stat = stat($file_name);
39:
40: // compare self stats
41: var_dump( compare_self_stat($old_stat) );
42: var_dump( compare_self_stat($new_stat) );
43:
44: // compare the stat
45: $affected_members = array(8, 'atime');
46: var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") );
47: // clear the cache
48: clearstatcache();
49:
50: echo "\n--- Done ---";
51: ?>
52:
53: --CLEAN--
54: <?php
55: $file_path = dirname(__FILE__);
56: unlink("$file_path/lstat_stat_variation4.tmp");
57: ?>
58: --EXPECTF--
59: *** Testing stat() for file after using touch() on the file ***
60: bool(true)
61: bool(true)
62: bool(true)
63: bool(true)
64:
65: --- Done ---
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>