Skip to content

Commit ebd922d

Browse files
committed
ext/standard/tests/file/stream_copy_to_stream.phpt: add test with interleaved read/write/copy calls
1 parent 2231163 commit ebd922d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

ext/standard/tests/file/stream_copy_to_stream.phpt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,31 @@ if (WIN) {
123123
}
124124
unlink($new_file);
125125

126+
/* interleaved read/write/copy calls */
127+
128+
$src = fopen($initial_file, 'r');
129+
130+
$dest = fopen($new_file, 'w');
131+
132+
var_dump(fread($src, 10));
133+
var_dump(fwrite($dest, "foo"));
134+
var_dump(stream_copy_to_stream($src, $dest, 10));
135+
var_dump(ftell($src));
136+
var_dump(ftell($dest));
137+
var_dump(fread($src, 10));
138+
var_dump(fwrite($dest, "bar"));
139+
var_dump(stream_copy_to_stream($src, $dest, 10));
140+
var_dump(ftell($src));
141+
var_dump(ftell($dest));
142+
fclose($src); fclose($dest);
143+
144+
if (WIN) {
145+
var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
146+
} else {
147+
var_dump(file_get_contents($new_file));
148+
}
149+
unlink($new_file);
150+
126151
echo "Done\n";
127152
?>
128153
--EXPECTF--
@@ -179,4 +204,16 @@ I'll break these chains
179204
That hold me down
180205
I'll tear you down into my private hell
181206
"
207+
string(10) "Another da"
208+
int(3)
209+
int(10)
210+
int(20)
211+
int(13)
212+
string(10) " pains of "
213+
int(3)
214+
int(10)
215+
int(40)
216+
int(26)
217+
string(26) "fooy
218+
When thebarlife won't"
182219
Done

0 commit comments

Comments
 (0)