xref: /PHP-5.5/ext/standard/tests/file/bug38086.phpt (revision 5bf4d724)
1--TEST--
2Bug #38086 (stream_copy_to_stream() returns 0 when maxlen is bigger than the actual length)
3--FILE--
4<?php
5define('WIN', substr(PHP_OS, 0, 3) == 'WIN');
6
7$initial_file = dirname(__FILE__).'/bug38086.txt';
8$new_file = dirname(__FILE__).'/bug38086_1.txt';
9
10$src = fopen($initial_file, 'r');
11stream_filter_append($src, "string.rot13", STREAM_FILTER_READ);
12
13$dest = fopen($new_file, 'w');
14var_dump(stream_copy_to_stream($src, $dest));
15fclose($src); fclose($dest);
16
17if (WIN) {
18  var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
19} else {
20  var_dump(file_get_contents($new_file));
21}
22unlink($new_file);
23
24$src = fopen($initial_file, 'r');
25stream_filter_append($src, "string.rot13", STREAM_FILTER_READ);
26
27$dest = fopen($new_file, 'w');
28var_dump(stream_copy_to_stream($src, $dest, 10000));
29fclose($src); fclose($dest);
30
31if (WIN) {
32  var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
33} else {
34  var_dump(file_get_contents($new_file));
35}
36unlink($new_file);
37
38echo "Done\n";
39?>
40--EXPECTF--
41int(%d)
42string(134) "Nabgure qnl
43Jura gur cnvaf bs yvsr jba'g one zl jnl
44V'yy oernx gurfr punvaf
45Gung ubyq zr qbja
46V'yy grne lbh qbja vagb zl cevingr uryy
47"
48int(%d)
49string(134) "Nabgure qnl
50Jura gur cnvaf bs yvsr jba'g one zl jnl
51V'yy oernx gurfr punvaf
52Gung ubyq zr qbja
53V'yy grne lbh qbja vagb zl cevingr uryy
54"
55Done
56