Skip to content

Commit a8a01b2

Browse files
committed
Implemented stream_stat
1 parent 70a2b13 commit a8a01b2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/VCR/Util/StreamProcessor.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ public function stream_seek(int $offset, int $whence = SEEK_SET): bool
274274
*/
275275
public function stream_stat()
276276
{
277+
if (false === $this->resource) {
278+
return false;
279+
}
280+
281+
if (!$this->shouldProcess(stream_get_meta_data($this->resource)['uri'])) {
282+
return fstat($this->resource);
283+
}
284+
277285
return false;
278286
}
279287

tests/VCR/VCRTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ public function testShouldDispatchBeforeAfterHttpRequestAndBeforeRecordWhenCasse
191191
VCR::turnOff();
192192
}
193193

194+
public function testFinfoWorksCorrectly(): void
195+
{
196+
$fileinfo = new \finfo(FILEINFO_MIME_TYPE);
197+
198+
$this->assertEquals(
199+
'text/plain',
200+
$fileinfo->file(__DIR__.'/../../.gitignore')
201+
);
202+
}
203+
194204
private function recordAllEvents()
195205
{
196206
$allEventsToListen = [

0 commit comments

Comments
 (0)