Annotation of embedaddon/php/ext/standard/tests/file/fflush_variation1-win32.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test fflush() function: usage variations - files in different modes
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: /* Prototype: bool fflush ( resource $handle );
12: Description: Flushes the output to a file
13: */
14:
15: /* test fflush() with handle to the files opened in different modes */
16:
17: $file_path = dirname(__FILE__);
18: require $file_path.'/file.inc';
19:
20: echo "*** Testing fflush(): with various types of files ***\n";
21: $file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric");
22: $file_modes = array("w", "wb", "wt", "w+", "w+b", "w+t",
23: "a", "ab", "at", "a+","a+b", "a+t",
24: "x", "xb", "xt", "x+", "x+b", "x+t");
25:
26: $file_name = "$file_path/fflush_variation1.tmp";
27:
28: $count = 1;
29:
30: foreach( $file_types as $type ) {
31: echo "-- Iteration $count with file containing $type Data--\n";
32: foreach( $file_modes as $mode ) {
33: echo "-- File opened in $mode mode --\n";
34:
35: // creating the file except for x mode
36: if( substr($mode, 0, 1) != "x" ) {
37: $file_handle = fopen($file_name, "w");
38: if($file_handle == false)
39: exit("Error:failed to open file $file_name");
40:
41: // filling the file some data if mode is append mode
42: if( substr($mode, 0, 1) == "a")
43: fill_file($file_handle, $type, 10);
44: fclose($file_handle);
45: }
46:
47: // opening the file in different modes
48: $file_handle = fopen($file_name, $mode);
49: if($file_handle == false)
50: exit("Error:failed to open file $file_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 the contents of the file after flushing
58: var_dump( readfile($file_name) );
59: unlink($file_name);
60: }
61: $count++;
62: }
63:
64: echo "\n*** Done ***";
65: ?>
66: --EXPECTF--
67: *** Testing fflush(): with various types of files ***
68: -- Iteration 1 with file containing empty Data--
69: -- File opened in w mode --
70: bool(true)
71: bool(true)
72: int(0)
73: -- File opened in wb mode --
74: bool(true)
75: bool(true)
76: int(0)
77: -- File opened in wt mode --
78: bool(true)
79: bool(true)
80: int(0)
81: -- File opened in w+ mode --
82: bool(true)
83: bool(true)
84: int(0)
85: -- File opened in w+b mode --
86: bool(true)
87: bool(true)
88: int(0)
89: -- File opened in w+t mode --
90: bool(true)
91: bool(true)
92: int(0)
93: -- File opened in a mode --
94: bool(true)
95: bool(true)
96: int(0)
97: -- File opened in ab mode --
98: bool(true)
99: bool(true)
100: int(0)
101: -- File opened in at mode --
102: bool(true)
103: bool(true)
104: int(0)
105: -- File opened in a+ mode --
106: bool(true)
107: bool(true)
108: int(0)
109: -- File opened in a+b mode --
110: bool(true)
111: bool(true)
112: int(0)
113: -- File opened in a+t mode --
114: bool(true)
115: bool(true)
116: int(0)
117: -- File opened in x mode --
118: bool(true)
119: bool(true)
120: int(0)
121: -- File opened in xb mode --
122: bool(true)
123: bool(true)
124: int(0)
125: -- File opened in xt mode --
126: bool(true)
127: bool(true)
128: int(0)
129: -- File opened in x+ mode --
130: bool(true)
131: bool(true)
132: int(0)
133: -- File opened in x+b mode --
134: bool(true)
135: bool(true)
136: int(0)
137: -- File opened in x+t mode --
138: bool(true)
139: bool(true)
140: int(0)
141: -- Iteration 2 with file containing numeric Data--
142: -- File opened in w mode --
143: bool(true)
144: bool(true)
145: 22222222222222222222222222222222222222222222222222int(50)
146: -- File opened in wb mode --
147: bool(true)
148: bool(true)
149: 22222222222222222222222222222222222222222222222222int(50)
150: -- File opened in wt mode --
151: bool(true)
152: bool(true)
153: 22222222222222222222222222222222222222222222222222int(50)
154: -- File opened in w+ mode --
155: bool(true)
156: bool(true)
157: 22222222222222222222222222222222222222222222222222int(50)
158: -- File opened in w+b mode --
159: bool(true)
160: bool(true)
161: 22222222222222222222222222222222222222222222222222int(50)
162: -- File opened in w+t mode --
163: bool(true)
164: bool(true)
165: 22222222222222222222222222222222222222222222222222int(50)
166: -- File opened in a mode --
167: bool(true)
168: bool(true)
169: 222222222222222222222222222222222222222222222222222222222222int(60)
170: -- File opened in ab mode --
171: bool(true)
172: bool(true)
173: 222222222222222222222222222222222222222222222222222222222222int(60)
174: -- File opened in at mode --
175: bool(true)
176: bool(true)
177: 222222222222222222222222222222222222222222222222222222222222int(60)
178: -- File opened in a+ mode --
179: bool(true)
180: bool(true)
181: 222222222222222222222222222222222222222222222222222222222222int(60)
182: -- File opened in a+b mode --
183: bool(true)
184: bool(true)
185: 222222222222222222222222222222222222222222222222222222222222int(60)
186: -- File opened in a+t mode --
187: bool(true)
188: bool(true)
189: 222222222222222222222222222222222222222222222222222222222222int(60)
190: -- File opened in x mode --
191: bool(true)
192: bool(true)
193: 22222222222222222222222222222222222222222222222222int(50)
194: -- File opened in xb mode --
195: bool(true)
196: bool(true)
197: 22222222222222222222222222222222222222222222222222int(50)
198: -- File opened in xt mode --
199: bool(true)
200: bool(true)
201: 22222222222222222222222222222222222222222222222222int(50)
202: -- File opened in x+ mode --
203: bool(true)
204: bool(true)
205: 22222222222222222222222222222222222222222222222222int(50)
206: -- File opened in x+b mode --
207: bool(true)
208: bool(true)
209: 22222222222222222222222222222222222222222222222222int(50)
210: -- File opened in x+t mode --
211: bool(true)
212: bool(true)
213: 22222222222222222222222222222222222222222222222222int(50)
214: -- Iteration 3 with file containing text Data--
215: -- File opened in w mode --
216: bool(true)
217: bool(true)
218: text text text text text text text text text text int(50)
219: -- File opened in wb mode --
220: bool(true)
221: bool(true)
222: text text text text text text text text text text int(50)
223: -- File opened in wt mode --
224: bool(true)
225: bool(true)
226: text text text text text text text text text text int(50)
227: -- File opened in w+ mode --
228: bool(true)
229: bool(true)
230: text text text text text text text text text text int(50)
231: -- File opened in w+b mode --
232: bool(true)
233: bool(true)
234: text text text text text text text text text text int(50)
235: -- File opened in w+t mode --
236: bool(true)
237: bool(true)
238: text text text text text text text text text text int(50)
239: -- File opened in a mode --
240: bool(true)
241: bool(true)
242: text text text text text text text text text text text text int(60)
243: -- File opened in ab mode --
244: bool(true)
245: bool(true)
246: text text text text text text text text text text text text int(60)
247: -- File opened in at mode --
248: bool(true)
249: bool(true)
250: text text text text text text text text text text text text int(60)
251: -- File opened in a+ mode --
252: bool(true)
253: bool(true)
254: text text text text text text text text text text text text int(60)
255: -- File opened in a+b mode --
256: bool(true)
257: bool(true)
258: text text text text text text text text text text text text int(60)
259: -- File opened in a+t mode --
260: bool(true)
261: bool(true)
262: text text text text text text text text text text text text int(60)
263: -- File opened in x mode --
264: bool(true)
265: bool(true)
266: text text text text text text text text text text int(50)
267: -- File opened in xb mode --
268: bool(true)
269: bool(true)
270: text text text text text text text text text text int(50)
271: -- File opened in xt mode --
272: bool(true)
273: bool(true)
274: text text text text text text text text text text int(50)
275: -- File opened in x+ mode --
276: bool(true)
277: bool(true)
278: text text text text text text text text text text int(50)
279: -- File opened in x+b mode --
280: bool(true)
281: bool(true)
282: text text text text text text text text text text int(50)
283: -- File opened in x+t mode --
284: bool(true)
285: bool(true)
286: text text text text text text text text text text int(50)
287: -- Iteration 4 with file containing text_with_new_line Data--
288: -- File opened in w mode --
289: bool(true)
290: bool(true)
291: line
292: line of text
293: line
294: line of text
295: line
296: line of tint(50)
297: -- File opened in wb mode --
298: bool(true)
299: bool(true)
300: line
301: line of text
302: line
303: line of text
304: line
305: line of tint(50)
306: -- File opened in wt mode --
307: bool(true)
308: bool(true)
309: line
310: line of text
311: line
312: line of text
313: line
314: line of tint(55)
315: -- File opened in w+ mode --
316: bool(true)
317: bool(true)
318: line
319: line of text
320: line
321: line of text
322: line
323: line of tint(50)
324: -- File opened in w+b mode --
325: bool(true)
326: bool(true)
327: line
328: line of text
329: line
330: line of text
331: line
332: line of tint(50)
333: -- File opened in w+t mode --
334: bool(true)
335: bool(true)
336: line
337: line of text
338: line
339: line of text
340: line
341: line of tint(55)
342: -- File opened in a mode --
343: bool(true)
344: bool(true)
345: line
346: line line
347: line of text
348: line
349: line of text
350: line
351: line of tint(60)
352: -- File opened in ab mode --
353: bool(true)
354: bool(true)
355: line
356: line line
357: line of text
358: line
359: line of text
360: line
361: line of tint(60)
362: -- File opened in at mode --
363: bool(true)
364: bool(true)
365: line
366: line line
367: line of text
368: line
369: line of text
370: line
371: line of tint(65)
372: -- File opened in a+ mode --
373: bool(true)
374: bool(true)
375: line
376: line line
377: line of text
378: line
379: line of text
380: line
381: line of tint(60)
382: -- File opened in a+b mode --
383: bool(true)
384: bool(true)
385: line
386: line line
387: line of text
388: line
389: line of text
390: line
391: line of tint(60)
392: -- File opened in a+t mode --
393: bool(true)
394: bool(true)
395: line
396: line line
397: line of text
398: line
399: line of text
400: line
401: line of tint(65)
402: -- File opened in x mode --
403: bool(true)
404: bool(true)
405: line
406: line of text
407: line
408: line of text
409: line
410: line of tint(50)
411: -- File opened in xb mode --
412: bool(true)
413: bool(true)
414: line
415: line of text
416: line
417: line of text
418: line
419: line of tint(50)
420: -- File opened in xt mode --
421: bool(true)
422: bool(true)
423: line
424: line of text
425: line
426: line of text
427: line
428: line of tint(55)
429: -- File opened in x+ mode --
430: bool(true)
431: bool(true)
432: line
433: line of text
434: line
435: line of text
436: line
437: line of tint(50)
438: -- File opened in x+b mode --
439: bool(true)
440: bool(true)
441: line
442: line of text
443: line
444: line of text
445: line
446: line of tint(50)
447: -- File opened in x+t mode --
448: bool(true)
449: bool(true)
450: line
451: line of text
452: line
453: line of text
454: line
455: line of tint(55)
456: -- Iteration 5 with file containing alphanumeric Data--
457: -- File opened in w mode --
458: bool(true)
459: bool(true)
460: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
461: -- File opened in wb mode --
462: bool(true)
463: bool(true)
464: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
465: -- File opened in wt mode --
466: bool(true)
467: bool(true)
468: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
469: -- File opened in w+ mode --
470: bool(true)
471: bool(true)
472: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
473: -- File opened in w+b mode --
474: bool(true)
475: bool(true)
476: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
477: -- File opened in w+t mode --
478: bool(true)
479: bool(true)
480: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
481: -- File opened in a mode --
482: bool(true)
483: bool(true)
484: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
485: -- File opened in ab mode --
486: bool(true)
487: bool(true)
488: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
489: -- File opened in at mode --
490: bool(true)
491: bool(true)
492: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
493: -- File opened in a+ mode --
494: bool(true)
495: bool(true)
496: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
497: -- File opened in a+b mode --
498: bool(true)
499: bool(true)
500: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
501: -- File opened in a+t mode --
502: bool(true)
503: bool(true)
504: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
505: -- File opened in x mode --
506: bool(true)
507: bool(true)
508: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
509: -- File opened in xb mode --
510: bool(true)
511: bool(true)
512: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
513: -- File opened in xt mode --
514: bool(true)
515: bool(true)
516: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
517: -- File opened in x+ mode --
518: bool(true)
519: bool(true)
520: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
521: -- File opened in x+b mode --
522: bool(true)
523: bool(true)
524: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
525: -- File opened in x+t mode --
526: bool(true)
527: bool(true)
528: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
529:
530: *** Done ***
531:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>