Annotation of embedaddon/php/ext/standard/tests/file/fpassthru_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test fpassthru() function: Basic functionality
3: --FILE--
4: <?php
5: /*
6: Prototype: int fpassthru ( resource $handle );
7: Description: Reads to EOF on the given file pointer from the current position
8: and writes the results to the output buffer.
9: */
10:
11: $file_name = dirname(__FILE__)."/passthru.tmp";
12: $write_handle = fopen($file_name, "w");
13:
14: $string = "Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^
15: Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^\n";
16: if(substr(PHP_OS, 0, 3) == "WIN") {
17: $string = str_replace("\r",'', $string);
18: }
19: fwrite($write_handle, $string);
20: fclose($write_handle);
21:
22: $read_handle = fopen($file_name, "r");
23:
24: echo "*** Test basic functionality of fpassthru() function ***\n";
25: echo "\n-- Before seek operation --\n";
26: var_dump( fpassthru($read_handle) );
27:
28: echo "\n-- After seeking position to 0 --\n";
29: fseek($read_handle, 0);
30: var_dump( fpassthru($read_handle) );
31:
32: echo "\n-- After seeking position to 3 --\n";
33: fseek($read_handle, 3);
34: var_dump( fpassthru($read_handle) );
35:
36: echo "\n-- After seeking position to 13 --\n";
37: fseek($read_handle, 13);
38: var_dump( fpassthru($read_handle) );
39:
40: echo "\n-- After seeking position to 14 --\n";
41: fseek($read_handle, 14);
42: var_dump( fpassthru($read_handle) );
43:
44: echo "\n-- After seeking position to 23 --\n";
45: fseek($read_handle, 23);
46: var_dump( fpassthru($read_handle) );
47:
48: echo "\n-- After seeking position to 34 --\n";
49: fseek($read_handle, 34);
50: var_dump( fpassthru($read_handle) );
51:
52: echo "\n-- After seeking position to 1000 --\n";
53: fseek($read_handle, 1000);
54: var_dump( fpassthru($read_handle) );
55:
56: fclose($read_handle);
57:
58: echo "*** Done ***\n";
59:
60: ?>
61: --CLEAN--
62: <?php
63: unlink(dirname(__FILE__)."/passthru.tmp");
64: ?>
65: --EXPECTF--
66: *** Test basic functionality of fpassthru() function ***
67:
68: -- Before seek operation --
69: Hello, world
70: , abcdefg adsdsfdf
71: 8u2394723947 $%$%#$%#$%#^#%^
72: Hello, world
73: , abcdefg adsdsfdf
74: 8u2394723947 $%$%#$%#$%#^#%^
75: int(133)
76:
77: -- After seeking position to 0 --
78: Hello, world
79: , abcdefg adsdsfdf
80: 8u2394723947 $%$%#$%#$%#^#%^
81: Hello, world
82: , abcdefg adsdsfdf
83: 8u2394723947 $%$%#$%#$%#^#%^
84: int(133)
85:
86: -- After seeking position to 3 --
87: lo, world
88: , abcdefg adsdsfdf
89: 8u2394723947 $%$%#$%#$%#^#%^
90: Hello, world
91: , abcdefg adsdsfdf
92: 8u2394723947 $%$%#$%#$%#^#%^
93: int(130)
94:
95: -- After seeking position to 13 --
96: , abcdefg adsdsfdf
97: 8u2394723947 $%$%#$%#$%#^#%^
98: Hello, world
99: , abcdefg adsdsfdf
100: 8u2394723947 $%$%#$%#$%#^#%^
101: int(120)
102:
103: -- After seeking position to 14 --
104: abcdefg adsdsfdf
105: 8u2394723947 $%$%#$%#$%#^#%^
106: Hello, world
107: , abcdefg adsdsfdf
108: 8u2394723947 $%$%#$%#$%#^#%^
109: int(119)
110:
111: -- After seeking position to 23 --
112: adsdsfdf
113: 8u2394723947 $%$%#$%#$%#^#%^
114: Hello, world
115: , abcdefg adsdsfdf
116: 8u2394723947 $%$%#$%#$%#^#%^
117: int(110)
118:
119: -- After seeking position to 34 --
120: 2394723947 $%$%#$%#$%#^#%^
121: Hello, world
122: , abcdefg adsdsfdf
123: 8u2394723947 $%$%#$%#$%#^#%^
124: int(99)
125:
126: -- After seeking position to 1000 --
127: int(0)
128: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>