1--TEST--
2Test lstat() and stat() functions: usage variations - link names stored in array/object
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip.. lstat() not available on 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/* test for stats of link when their names are stored in object and array */
19
20$file_path = dirname(__FILE__);
21require "$file_path/file.inc";
22
23$fp = fopen("$file_path/lstat_stat_variation20.tmp", "w");  // temp file
24fclose($fp);
25
26// temp link
27symlink("$file_path/lstat_stat_variation20.tmp", "$file_path/lstat_stat_variation20_link.tmp");
28
29echo "*** Testing lstat() with linkname stored inside an object/array ***\n";
30class names {
31  public $var_name;
32  public function __construct($name) {
33    $this->var_name = $name;
34  }
35}
36
37// link name stored in an object
38$link_object = new names("$file_path/lstat_stat_variation20_link.tmp");
39
40// link name stored in side an array
41// with default numeric key
42$link_array = array("$file_path/lstat_stat_variation20_link.tmp");
43
44// with string key index
45$link_array_with_key = array("linkname" => "$file_path/lstat_stat_variation20_link.tmp");
46
47echo "\n-- Testing lstat() on link name stored inside an object --\n";
48var_dump( lstat($link_object->var_name) );
49
50echo "\n-- Testing stat() on link name stored inside an array --\n";
51var_dump( stat($link_array[0]) ); // with default numeric index
52var_dump( stat($link_array_with_key["linkname"]) ); // with string key
53var_dump( stat($link_array_with_key['linkname']) );
54
55echo "\n--- Done ---";
56?>
57
58--CLEAN--
59<?php
60$file_path = dirname(__FILE__);
61unlink("$file_path/lstat_stat_variation20_link.tmp");
62unlink("$file_path/lstat_stat_variation20.tmp");
63?>
64--EXPECTF--
65*** Testing lstat() with linkname stored inside an object/array ***
66
67-- Testing lstat() on link name stored inside an object --
68array(26) {
69  [0]=>
70  int(%d)
71  [1]=>
72  int(%d)
73  [2]=>
74  int(%d)
75  [3]=>
76  int(%d)
77  [4]=>
78  int(%d)
79  [5]=>
80  int(%d)
81  [6]=>
82  int(%d)
83  [7]=>
84  int(%d)
85  [8]=>
86  int(%d)
87  [9]=>
88  int(%d)
89  [10]=>
90  int(%d)
91  [11]=>
92  int(%d)
93  [12]=>
94  int(%d)
95  ["dev"]=>
96  int(%d)
97  ["ino"]=>
98  int(%d)
99  ["mode"]=>
100  int(%d)
101  ["nlink"]=>
102  int(%d)
103  ["uid"]=>
104  int(%d)
105  ["gid"]=>
106  int(%d)
107  ["rdev"]=>
108  int(%d)
109  ["size"]=>
110  int(%d)
111  ["atime"]=>
112  int(%d)
113  ["mtime"]=>
114  int(%d)
115  ["ctime"]=>
116  int(%d)
117  ["blksize"]=>
118  int(%d)
119  ["blocks"]=>
120  int(%d)
121}
122
123-- Testing stat() on link name stored inside an array --
124array(26) {
125  [0]=>
126  int(%d)
127  [1]=>
128  int(%d)
129  [2]=>
130  int(%d)
131  [3]=>
132  int(%d)
133  [4]=>
134  int(%d)
135  [5]=>
136  int(%d)
137  [6]=>
138  int(%d)
139  [7]=>
140  int(%d)
141  [8]=>
142  int(%d)
143  [9]=>
144  int(%d)
145  [10]=>
146  int(%d)
147  [11]=>
148  int(%d)
149  [12]=>
150  int(%d)
151  ["dev"]=>
152  int(%d)
153  ["ino"]=>
154  int(%d)
155  ["mode"]=>
156  int(%d)
157  ["nlink"]=>
158  int(%d)
159  ["uid"]=>
160  int(%d)
161  ["gid"]=>
162  int(%d)
163  ["rdev"]=>
164  int(%d)
165  ["size"]=>
166  int(%d)
167  ["atime"]=>
168  int(%d)
169  ["mtime"]=>
170  int(%d)
171  ["ctime"]=>
172  int(%d)
173  ["blksize"]=>
174  int(%d)
175  ["blocks"]=>
176  int(%d)
177}
178array(26) {
179  [0]=>
180  int(%d)
181  [1]=>
182  int(%d)
183  [2]=>
184  int(%d)
185  [3]=>
186  int(%d)
187  [4]=>
188  int(%d)
189  [5]=>
190  int(%d)
191  [6]=>
192  int(%d)
193  [7]=>
194  int(%d)
195  [8]=>
196  int(%d)
197  [9]=>
198  int(%d)
199  [10]=>
200  int(%d)
201  [11]=>
202  int(%d)
203  [12]=>
204  int(%d)
205  ["dev"]=>
206  int(%d)
207  ["ino"]=>
208  int(%d)
209  ["mode"]=>
210  int(%d)
211  ["nlink"]=>
212  int(%d)
213  ["uid"]=>
214  int(%d)
215  ["gid"]=>
216  int(%d)
217  ["rdev"]=>
218  int(%d)
219  ["size"]=>
220  int(%d)
221  ["atime"]=>
222  int(%d)
223  ["mtime"]=>
224  int(%d)
225  ["ctime"]=>
226  int(%d)
227  ["blksize"]=>
228  int(%d)
229  ["blocks"]=>
230  int(%d)
231}
232array(26) {
233  [0]=>
234  int(%d)
235  [1]=>
236  int(%d)
237  [2]=>
238  int(%d)
239  [3]=>
240  int(%d)
241  [4]=>
242  int(%d)
243  [5]=>
244  int(%d)
245  [6]=>
246  int(%d)
247  [7]=>
248  int(%d)
249  [8]=>
250  int(%d)
251  [9]=>
252  int(%d)
253  [10]=>
254  int(%d)
255  [11]=>
256  int(%d)
257  [12]=>
258  int(%d)
259  ["dev"]=>
260  int(%d)
261  ["ino"]=>
262  int(%d)
263  ["mode"]=>
264  int(%d)
265  ["nlink"]=>
266  int(%d)
267  ["uid"]=>
268  int(%d)
269  ["gid"]=>
270  int(%d)
271  ["rdev"]=>
272  int(%d)
273  ["size"]=>
274  int(%d)
275  ["atime"]=>
276  int(%d)
277  ["mtime"]=>
278  int(%d)
279  ["ctime"]=>
280  int(%d)
281  ["blksize"]=>
282  int(%d)
283  ["blocks"]=>
284  int(%d)
285}
286
287--- Done ---
288