Skip to content

Commit

Permalink
tests(s3): Fix NonSeekableStream stream implementation metadata in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed May 23, 2023
1 parent 98aa50a commit a2b37a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/private/Files/Stream/SeekableHttpStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public function stream_tell() {
public function stream_stat() {
if ($this->getCurrent()) {
$stat = fstat($this->getCurrent());
$stat = $stat ? $stat : [];
$stat['size'] = $this->totalSize;
return $stat;
} else {
Expand Down
12 changes: 10 additions & 2 deletions tests/lib/Files/ObjectStore/S3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,15 @@ public function testUploadNonSeekable() {

$s3 = $this->getInstance();

$s3->writeObject('multiparttest', NonSeekableStream::wrap(fopen(__FILE__, 'r')));
// We need an actual non-seekable resource here as NonSeekableStream won't be enough
// when it is passed to the GuzzleHttp\Psr7\Utils::streamFor
// which checks the actual stream meta data using stream_get_meta_data
@posix_mkfifo('/tmp/fifo', 0644);
$stream = fopen('/tmp/fifo', 'rw+');
stream_set_blocking($stream, false);
fwrite($stream, file_get_contents(__FILE__));

$s3->writeObject('multiparttest', NonSeekableStream::wrap($stream));

$result = $s3->readObject('multiparttest');

Expand Down Expand Up @@ -119,7 +127,7 @@ public function testEmptyUpload() {
$s3 = $this->getInstance();

$emptyStream = fopen("php://memory", "r");
fwrite($emptyStream, null);
fwrite($emptyStream, '');

$s3->writeObject('emptystream', $emptyStream);

Expand Down

0 comments on commit a2b37a8

Please sign in to comment.