-
Notifications
You must be signed in to change notification settings - Fork 104
Description
Firstly, thanks to the creators and maintainers of this project, it's a really useful tool.
I had a scenario where I wanted to mock a streamed input (in the real application, it will open php://input), so tried to open the same file twice, once for writing (in the test) and once for reading (in the tested code).
Any data written before the first read shows up fine on the read handle, but subsequent writes are not reflected. Rewinding the read handle works as expected, i.e. the whole contents of the file are visible on subsequent reads.
I suspect this is related to #129; testing before and after the patch in #220 shows that previously even the first read came back empty.
Simple reproduction script:
require 'vendor/autoload.php';
$root = org\bovigo\vfs\vfsStream::setup();
$file = org\bovigo\vfs\vfsStream::newFile('test')->at($root);
$w = fopen($file->url(), 'w');
$r = fopen($file->url(), 'r');
fwrite($w, "hello\n");
echo fgets($r); # echoes "hello" as expected
fwrite($w, "hello again\n");
echo fgets($r); # does not echo anything :(
rewind($r);
echo fgets($r); # echoes "hello"
echo fgets($r); # echoes "hello again"For comparison, if I change the fopen calls to reference a real file, the "hello again" gets echoed as I expected.