xref: /PHP-7.2/ext/standard/tests/file/bug37158.phpt (revision 17ccbeec)
1--TEST--
2Bug #37158 (if userspace stream is present, fread() reads in 8192 max, otherwise it works)
3--FILE--
4<?php
5
6class VariableStream {
7
8   function stream_open($path, $mode, $options, &$opened_path)
9   {
10       return true;
11   }
12}
13
14stream_wrapper_register("var", "VariableStream");
15
16error_reporting(E_ALL | E_STRICT);
17$file = dirname(__FILE__) . '/footest.txt';
18$x = str_repeat(1, 8192);
19$fp = fopen($file, 'w');
20for ($i = 0; $i < 5; $i++) {
21	fwrite($fp, $x);
22}
23fclose($fp);
24
25$fp = fopen($file, 'r');
26$outsidecontents = fread($fp, 20000);
27fclose($fp);
28var_dump('size of contents 1 = ' . strlen($outsidecontents));
29$outsidecontents = file_get_contents($file);
30var_dump('size of contents 2 = ' . strlen($outsidecontents));
31
32unlink($file);
33
34echo "Done\n";
35?>
36--EXPECT--
37string(26) "size of contents 1 = 20000"
38string(26) "size of contents 2 = 40960"
39Done
40