1--TEST--
2Test stat() function: basic functionality
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) != 'WIN') {
6    die('skip.. valid only for Windows');
7}
8?>
9--FILE--
10<?php
11$file_path = __DIR__;
12require("$file_path/file.inc");
13
14echo "*** Testing stat() : basic functionality ***\n";
15
16/* creating temp directory and file */
17
18// creating dir
19$dirname = "$file_path/stat_basic_私はガラスを食べられます";
20mkdir($dirname);
21// stat of the dir created
22$dir_stat = stat($dirname);
23clearstatcache();
24sleep(1);
25
26// creating file
27$filename = "$dirname/stat_basic_私はガラスを食べられます.tmp";
28$file_handle = fopen($filename, "w");
29fclose($file_handle);
30// stat of the file created
31$file_stat = stat($filename);
32sleep(1);
33
34// now new stat of the dir after file is created
35$new_dir_stat = stat($dirname);
36clearstatcache();
37
38// stat contains 13 different values stored twice, can be accessed using
39// numeric and named keys, compare them to see they are same
40echo "*** Testing stat(): validating the values stored in stat ***\n";
41// Initial stat values
42var_dump( compare_self_stat($file_stat) ); //expect true
43var_dump( compare_self_stat($dir_stat) );  //expect true
44
45// New stat values taken after creation of file
46var_dump( compare_self_stat($new_dir_stat) );  // expect true
47
48// compare the two stat values, initial stat and stat recorded after
49// creating file, also dump the value of stats
50echo "*** Testing stat(): comparing stats (recorded before and after file creation) ***\n";
51echo "-- comparing difference in dir stats before and after creating file in it --\n";
52$affected_elements = array( 9, 'mtime' );
53var_dump( compare_stats($dir_stat, $new_dir_stat, $affected_elements, '!=', true) ); // expect true
54
55echo "*** Testing stat(): for the return value ***\n";
56var_dump( is_array( stat($filename) ) );
57
58echo "\n---Done---";
59?>
60--CLEAN--
61<?php
62$file_path = __DIR__;
63unlink("$file_path/stat_basic_私はガラスを食べられます/stat_basic_私はガラスを食べられます.tmp");
64rmdir("$file_path/stat_basic_私はガラスを食べられます");
65?>
66--EXPECTF--
67*** Testing stat() : basic functionality ***
68*** Testing stat(): validating the values stored in stat ***
69bool(true)
70bool(true)
71bool(true)
72*** Testing stat(): comparing stats (recorded before and after file creation) ***
73-- comparing difference in dir stats before and after creating file in it --
74array(26) {
75  [0]=>
76  int(%i)
77  [1]=>
78  int(%d)
79  [2]=>
80  int(%d)
81  [3]=>
82  int(%d)
83  [4]=>
84  int(0)
85  [5]=>
86  int(0)
87  [6]=>
88  int(%d)
89  [7]=>
90  int(%d)
91  [8]=>
92  int(%d)
93  [9]=>
94  int(%d)
95  [10]=>
96  int(%d)
97  [11]=>
98  int(-1)
99  [12]=>
100  int(-1)
101  ["dev"]=>
102  int(%i)
103  ["ino"]=>
104  int(%d)
105  ["mode"]=>
106  int(%d)
107  ["nlink"]=>
108  int(%d)
109  ["uid"]=>
110  int(0)
111  ["gid"]=>
112  int(0)
113  ["rdev"]=>
114  int(%d)
115  ["size"]=>
116  int(%d)
117  ["atime"]=>
118  int(%d)
119  ["mtime"]=>
120  int(%d)
121  ["ctime"]=>
122  int(%d)
123  ["blksize"]=>
124  int(-1)
125  ["blocks"]=>
126  int(-1)
127}
128array(26) {
129  [0]=>
130  int(%i)
131  [1]=>
132  int(%d)
133  [2]=>
134  int(%d)
135  [3]=>
136  int(%d)
137  [4]=>
138  int(%d)
139  [5]=>
140  int(%d)
141  [6]=>
142  int(%d)
143  [7]=>
144  int(%d)
145  [8]=>
146  int(%d)
147  [9]=>
148  int(%d)
149  [10]=>
150  int(%d)
151  [11]=>
152  int(-1)
153  [12]=>
154  int(-1)
155  ["dev"]=>
156  int(%i)
157  ["ino"]=>
158  int(%d)
159  ["mode"]=>
160  int(%d)
161  ["nlink"]=>
162  int(%d)
163  ["uid"]=>
164  int(%d)
165  ["gid"]=>
166  int(%d)
167  ["rdev"]=>
168  int(%d)
169  ["size"]=>
170  int(%d)
171  ["atime"]=>
172  int(%d)
173  ["mtime"]=>
174  int(%d)
175  ["ctime"]=>
176  int(%d)
177  ["blksize"]=>
178  int(-1)
179  ["blocks"]=>
180  int(-1)
181}
182bool(true)
183*** Testing stat(): for the return value ***
184bool(true)
185
186---Done---
187