Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Enjoyzz authored Jul 21, 2022
1 parent 0f9f308 commit 712f4f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function getStream(): StreamInterface
}

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

return $this->stream;
Expand Down
9 changes: 9 additions & 0 deletions tests/UploadedFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,13 @@ public function testMoveToThrowExceptionForTargetPathIsNotExist(): void
$this->expectException(RuntimeException::class);
$uploadedFile->moveTo('path/to/not-exist');
}

public function testGetStreamContentIfUploadedFileNotStream()
{
file_put_contents($this->tmpFile, $content = 'Content');
$uploadedFile = new UploadedFile($this->tmpFile, 1024, UPLOAD_ERR_OK);
$this->assertInstanceOf(StreamInterface::class, $uploadedFile->getStream());
$this->assertInstanceOf(Stream::class, $uploadedFile->getStream());
$this->assertSame($content, (string) $uploadedFile->getStream());
}
}

0 comments on commit 712f4f0

Please sign in to comment.