Skip to content

Commit 712f4f0

Browse files
authored
1 parent 0f9f308 commit 712f4f0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/UploadedFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function getStream(): StreamInterface
161161
}
162162

163163
if ($this->stream === null) {
164-
$this->stream = new Stream($this->file);
164+
$this->stream = new Stream($this->file, 'r+');
165165
}
166166

167167
return $this->stream;

tests/UploadedFileTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,13 @@ public function testMoveToThrowExceptionForTargetPathIsNotExist(): void
251251
$this->expectException(RuntimeException::class);
252252
$uploadedFile->moveTo('path/to/not-exist');
253253
}
254+
255+
public function testGetStreamContentIfUploadedFileNotStream()
256+
{
257+
file_put_contents($this->tmpFile, $content = 'Content');
258+
$uploadedFile = new UploadedFile($this->tmpFile, 1024, UPLOAD_ERR_OK);
259+
$this->assertInstanceOf(StreamInterface::class, $uploadedFile->getStream());
260+
$this->assertInstanceOf(Stream::class, $uploadedFile->getStream());
261+
$this->assertSame($content, (string) $uploadedFile->getStream());
262+
}
254263
}

0 commit comments

Comments
 (0)