Annotation of embedaddon/php/ext/standard/tests/file/stat_variation8-win32.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test stat() functions: usage variations - effects of truncate()
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) != 'WIN') {
6: die('skip.. only for Windows');
7: }
8: ?>
9: --FILE--
10: <?php
11:
12: /*
13: * Prototype: array stat ( string $filename );
14: * Description: Gives information about a file
15: */
16:
17: /* test the effects of truncate() on stats of file */
18:
19:
20: $file_path = dirname(__FILE__);
21: require "$file_path/file.inc";
22:
23:
24: /* create temp file and directory */
25:
26: $filename = "$file_path/stat_variation8.tmp";
27: $file_handle = fopen($filename, "w"); // temp file
28: fclose($file_handle);
29:
30:
31: echo "\n*** Testing stat(): on file by truncating it to given size ***\n";
32:
33: // create temp file
34: $file_handle = fopen($filename, "w");
35: fclose($file_handle);
36:
37: clearstatcache(true, $filename);
38: $old_stat = stat($filename);
39: // clear the cache
40: sleep(2);
41:
42: // opening file in r/w mode
43: $file_handle = fopen($filename, "r+");
44: var_dump( ftruncate($file_handle, 512) ); // truncate it
45: fclose($file_handle);
46:
47: clearstatcache(true, $filename);
48: $new_stat = stat($filename);
49:
50: // compare self stats
51: var_dump( compare_self_stat($old_stat) );
52: var_dump( compare_self_stat($new_stat) );
53:
54: // compare the stat
55: $affected_members = array(7, 9, 'size', 'mtime');
56: var_dump( compare_stats($old_stat, $new_stat, $affected_members, '!=') );
57:
58: // clear the stat
59: clearstatcache(true, $filename); // clear previous size value in cache
60:
61: echo "\n*** Done ***";
62: ?>
63:
64: --CLEAN--
65: <?php
66: $file_path = dirname(__FILE__);
67: unlink("$file_path/stat_variation8.tmp");
68: ?>
69: --EXPECTF--
70: *** Testing stat(): on file by truncating it to given size ***
71: bool(true)
72: bool(true)
73: bool(true)
74: bool(true)
75:
76: *** Done ***
77:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>