~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/standard/tests/file/stat_variation1-win32.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
Test stat() functions: usage variations - effects of rename()
 
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 rename() on stats of dir/file */
 
18
 
 
19
$file_path = dirname(__FILE__);
 
20
require "$file_path/file.inc";
 
21
 
 
22
 
 
23
/* create temp file and directory */
 
24
mkdir("$file_path/stat_variation1/");  // temp dir
 
25
 
 
26
$file_handle = fopen("$file_path/stat_variation1.tmp", "w");  // temp file
 
27
fclose($file_handle);
 
28
 
 
29
 
 
30
echo "*** Testing stat(): on file and directory ater renaming them ***\n";
 
31
 
 
32
// renaming a file
 
33
echo "-- Testing stat() for files after being renamed --\n";
 
34
$old_filename = "$file_path/stat_variation1.tmp";
 
35
$new_filename = "$file_path/stat_variation1a.tmp";
 
36
$old_stat = stat($old_filename);
 
37
clearstatcache();
 
38
sleep(2);
 
39
var_dump( rename($old_filename, $new_filename) );
 
40
$new_stat = stat($new_filename);
 
41
 
 
42
// compare the self stat 
 
43
var_dump( compare_self_stat($old_stat) );
 
44
var_dump( compare_self_stat($new_stat) );
 
45
 
 
46
// compare the two stats 
 
47
var_dump( compare_stats($old_stat, $old_stat, $all_stat_keys) );
 
48
// clear the cache
 
49
clearstatcache();
 
50
 
 
51
// renaming a directory
 
52
echo "-- Testing stat() for directory after being renamed --\n";
 
53
$old_dirname = "$file_path/stat_variation1";
 
54
$new_dirname = "$file_path/stat_variation1a";
 
55
$old_stat = stat($old_dirname);
 
56
clearstatcache();
 
57
sleep(2);
 
58
var_dump( rename($old_dirname, $new_dirname) );
 
59
$new_stat = stat($new_dirname);
 
60
 
 
61
// compare self stats
 
62
var_dump( compare_self_stat($old_stat) );
 
63
var_dump( compare_self_stat($new_stat) );
 
64
 
 
65
// compare the two stats
 
66
var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
 
67
// clear the cache
 
68
clearstatcache();
 
69
 
 
70
 
 
71
echo "\n*** Done ***";
 
72
?>
 
73
 
 
74
--CLEAN--
 
75
<?php
 
76
$file_path = dirname(__FILE__);
 
77
unlink("$file_path/stat_variation1a.tmp");
 
78
rmdir("$file_path/stat_variation1a");
 
79
?>
 
80
--EXPECTF--
 
81
*** Testing stat(): on file and directory ater renaming them ***
 
82
-- Testing stat() for files after being renamed --
 
83
bool(true)
 
84
bool(true)
 
85
bool(true)
 
86
bool(true)
 
87
-- Testing stat() for directory after being renamed --
 
88
bool(true)
 
89
bool(true)
 
90
bool(true)
 
91
bool(true)
 
92
 
 
93
*** Done ***
 
94