Annotation of embedaddon/php/ext/standard/tests/file/fflush_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test fflush() function: usage variations - hard links as resource
3: --SKIPIF--
4: <?php
5: if( substr(PHP_OS, 0, 3) == 'WIN')
6: die("skip Links not valid on Windows");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype: bool fflush ( resource $handle );
11: Description: Flushes the output to a file
12: */
13:
14: /* test fflush() with handle to hard links as resource */
15:
16: $file_path = dirname(__FILE__);
17: require $file_path.'/file.inc';
18:
19: echo "*** Testing fflush(): with hard links to files opened in diff modes ***\n";
20: $file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric");
21: $file_modes = array("w", "wb", "wt", "w+", "w+b","w+t",
22: "a", "ab", "at", "a+","a+b", "a+t");
23:
24: $file_name = "$file_path/fflush_variation3.tmp";
25: $link_name = "$file_path/lnk_fflush_variation3.tmp";
26:
27: $count = 1;
28:
29: foreach( $file_types as $type ) {
30: echo "-- Iteration $count with file containing $type data --\n";
31: foreach( $file_modes as $mode ) {
32:
33: // creating the file
34: $file_handle = fopen($file_name, "w");
35: if($file_handle == false)
36: exit("Error:failed to open file $file_name");
37:
38: // fill the fill with some data if mode is append mode
39: if( substr($mode, 0, 1) == "a" )
40: fill_file($file_handle, $type, 10);
41:
42: // fclose($file_handle);
43:
44: // creating hard link to the file
45: var_dump( link($file_name, $link_name) );
46:
47: // opening the file in different modes
48: $file_handle = fopen($link_name, $mode);
49: if($file_handle == false)
50: exit("Error:failed to open link $link_name");
51:
52: // writing data to the file
53: var_dump( fill_file($file_handle, $type, 50) );
54: var_dump( fflush($file_handle) );
55: fclose($file_handle);
56:
57: // reading data from the file after flushing
58: var_dump( readfile($link_name) );
59:
60: unlink($link_name);
61: unlink($file_name);
62: }
63: $count++;
64: }
65:
66: echo "\n*** Done ***";
67: ?>
68: --EXPECTF--
69: *** Testing fflush(): with hard links to files opened in diff modes ***
70: -- Iteration 1 with file containing empty data --
71: bool(true)
72: bool(true)
73: bool(true)
74: int(0)
75: bool(true)
76: bool(true)
77: bool(true)
78: int(0)
79: bool(true)
80: bool(true)
81: bool(true)
82: int(0)
83: bool(true)
84: bool(true)
85: bool(true)
86: int(0)
87: bool(true)
88: bool(true)
89: bool(true)
90: int(0)
91: bool(true)
92: bool(true)
93: bool(true)
94: int(0)
95: bool(true)
96: bool(true)
97: bool(true)
98: int(0)
99: bool(true)
100: bool(true)
101: bool(true)
102: int(0)
103: bool(true)
104: bool(true)
105: bool(true)
106: int(0)
107: bool(true)
108: bool(true)
109: bool(true)
110: int(0)
111: bool(true)
112: bool(true)
113: bool(true)
114: int(0)
115: bool(true)
116: bool(true)
117: bool(true)
118: int(0)
119: -- Iteration 2 with file containing numeric data --
120: bool(true)
121: bool(true)
122: bool(true)
123: 22222222222222222222222222222222222222222222222222int(50)
124: bool(true)
125: bool(true)
126: bool(true)
127: 22222222222222222222222222222222222222222222222222int(50)
128: bool(true)
129: bool(true)
130: bool(true)
131: 22222222222222222222222222222222222222222222222222int(50)
132: bool(true)
133: bool(true)
134: bool(true)
135: 22222222222222222222222222222222222222222222222222int(50)
136: bool(true)
137: bool(true)
138: bool(true)
139: 22222222222222222222222222222222222222222222222222int(50)
140: bool(true)
141: bool(true)
142: bool(true)
143: 22222222222222222222222222222222222222222222222222int(50)
144: bool(true)
145: bool(true)
146: bool(true)
147: 222222222222222222222222222222222222222222222222222222222222int(60)
148: bool(true)
149: bool(true)
150: bool(true)
151: 222222222222222222222222222222222222222222222222222222222222int(60)
152: bool(true)
153: bool(true)
154: bool(true)
155: 222222222222222222222222222222222222222222222222222222222222int(60)
156: bool(true)
157: bool(true)
158: bool(true)
159: 222222222222222222222222222222222222222222222222222222222222int(60)
160: bool(true)
161: bool(true)
162: bool(true)
163: 222222222222222222222222222222222222222222222222222222222222int(60)
164: bool(true)
165: bool(true)
166: bool(true)
167: 222222222222222222222222222222222222222222222222222222222222int(60)
168: -- Iteration 3 with file containing text data --
169: bool(true)
170: bool(true)
171: bool(true)
172: text text text text text text text text text text int(50)
173: bool(true)
174: bool(true)
175: bool(true)
176: text text text text text text text text text text int(50)
177: bool(true)
178: bool(true)
179: bool(true)
180: text text text text text text text text text text int(50)
181: bool(true)
182: bool(true)
183: bool(true)
184: text text text text text text text text text text int(50)
185: bool(true)
186: bool(true)
187: bool(true)
188: text text text text text text text text text text int(50)
189: bool(true)
190: bool(true)
191: bool(true)
192: text text text text text text text text text text int(50)
193: bool(true)
194: bool(true)
195: bool(true)
196: text text text text text text text text text text text text int(60)
197: bool(true)
198: bool(true)
199: bool(true)
200: text text text text text text text text text text text text int(60)
201: bool(true)
202: bool(true)
203: bool(true)
204: text text text text text text text text text text text text int(60)
205: bool(true)
206: bool(true)
207: bool(true)
208: text text text text text text text text text text text text int(60)
209: bool(true)
210: bool(true)
211: bool(true)
212: text text text text text text text text text text text text int(60)
213: bool(true)
214: bool(true)
215: bool(true)
216: text text text text text text text text text text text text int(60)
217: -- Iteration 4 with file containing text_with_new_line data --
218: bool(true)
219: bool(true)
220: bool(true)
221: line
222: line of text
223: line
224: line of text
225: line
226: line of tint(50)
227: bool(true)
228: bool(true)
229: bool(true)
230: line
231: line of text
232: line
233: line of text
234: line
235: line of tint(50)
236: bool(true)
237: bool(true)
238: bool(true)
239: line
240: line of text
241: line
242: line of text
243: line
244: line of tint(50)
245: bool(true)
246: bool(true)
247: bool(true)
248: line
249: line of text
250: line
251: line of text
252: line
253: line of tint(50)
254: bool(true)
255: bool(true)
256: bool(true)
257: line
258: line of text
259: line
260: line of text
261: line
262: line of tint(50)
263: bool(true)
264: bool(true)
265: bool(true)
266: line
267: line of text
268: line
269: line of text
270: line
271: line of tint(50)
272: bool(true)
273: bool(true)
274: bool(true)
275: line
276: line line
277: line of text
278: line
279: line of text
280: line
281: line of tint(60)
282: bool(true)
283: bool(true)
284: bool(true)
285: line
286: line line
287: line of text
288: line
289: line of text
290: line
291: line of tint(60)
292: bool(true)
293: bool(true)
294: bool(true)
295: line
296: line line
297: line of text
298: line
299: line of text
300: line
301: line of tint(60)
302: bool(true)
303: bool(true)
304: bool(true)
305: line
306: line line
307: line of text
308: line
309: line of text
310: line
311: line of tint(60)
312: bool(true)
313: bool(true)
314: bool(true)
315: line
316: line line
317: line of text
318: line
319: line of text
320: line
321: line of tint(60)
322: bool(true)
323: bool(true)
324: bool(true)
325: line
326: line line
327: line of text
328: line
329: line of text
330: line
331: line of tint(60)
332: -- Iteration 5 with file containing alphanumeric data --
333: bool(true)
334: bool(true)
335: bool(true)
336: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
337: bool(true)
338: bool(true)
339: bool(true)
340: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
341: bool(true)
342: bool(true)
343: bool(true)
344: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
345: bool(true)
346: bool(true)
347: bool(true)
348: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
349: bool(true)
350: bool(true)
351: bool(true)
352: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
353: bool(true)
354: bool(true)
355: bool(true)
356: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
357: bool(true)
358: bool(true)
359: bool(true)
360: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
361: bool(true)
362: bool(true)
363: bool(true)
364: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
365: bool(true)
366: bool(true)
367: bool(true)
368: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
369: bool(true)
370: bool(true)
371: bool(true)
372: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
373: bool(true)
374: bool(true)
375: bool(true)
376: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
377: bool(true)
378: bool(true)
379: bool(true)
380: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
381:
382: *** Done ***
383:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>