Browse Source

tests(s3): Fix NonSeekableStream stream implementation metadata in tests

Signed-off-by: Julius Härtl <jus@bitgrid.net>
Julius Härtl 11 months ago
parent
commit
a2b37a898d

+ 1 - 0
lib/private/Files/Stream/SeekableHttpStream.php

@@ -219,6 +219,7 @@ class SeekableHttpStream implements File {
 	public function stream_stat() {
 		if ($this->getCurrent()) {
 			$stat = fstat($this->getCurrent());
+			$stat = $stat ? $stat : [];
 			$stat['size'] = $this->totalSize;
 			return $stat;
 		} else {

+ 10 - 2
tests/lib/Files/ObjectStore/S3Test.php

@@ -80,7 +80,15 @@ class S3Test extends ObjectStoreTest {
 
 		$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');
 
@@ -119,7 +127,7 @@ class S3Test extends ObjectStoreTest {
 		$s3 = $this->getInstance();
 
 		$emptyStream = fopen("php://memory", "r");
-		fwrite($emptyStream, null);
+		fwrite($emptyStream, '');
 
 		$s3->writeObject('emptystream', $emptyStream);