xref: /PHP-8.2/ext/standard/tests/file/bug37158.phpt (revision f8d79582)
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
16$file = __DIR__ . '/footest.txt';
17$x = str_repeat(1, 8192);
18$fp = fopen($file, 'w');
19for ($i = 0; $i < 5; $i++) {
20    fwrite($fp, $x);
21}
22fclose($fp);
23
24$fp = fopen($file, 'r');
25$outsidecontents = fread($fp, 20000);
26fclose($fp);
27var_dump('size of contents 1 = ' . strlen($outsidecontents));
28$outsidecontents = file_get_contents($file);
29var_dump('size of contents 2 = ' . strlen($outsidecontents));
30
31unlink($file);
32
33echo "Done\n";
34?>
35--EXPECT--
36string(26) "size of contents 1 = 20000"
37string(26) "size of contents 2 = 40960"
38Done
39