handle seeks in countwrapper

This commit is contained in:
Robin Appelman 2024-12-05 15:32:45 +01:00
commit a0b84d362c
2 changed files with 29 additions and 0 deletions

View file

@ -46,4 +46,22 @@ class CountWrapperTest extends WrapperTest {
fclose($wrapped);
$this->assertSame(6, $count);
}
public function testReadCountSeek() {
$count = 0;
$source = fopen('php://temp', 'r+');
fwrite($source, 'foobar');
rewind($source);
$wrapped = CountWrapper::wrap($source, function ($readCount) use (&$count) {
$count = $readCount;
});
stream_get_contents($wrapped);
fseek($wrapped, 3);
stream_get_contents($wrapped);
fclose($wrapped);
$this->assertSame(6, $count);
}
}