summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Files/Storage/Storage.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/lib/Files/Storage/Storage.php b/tests/lib/Files/Storage/Storage.php
index 04aafece2e3..a25a3f74f9e 100644
--- a/tests/lib/Files/Storage/Storage.php
+++ b/tests/lib/Files/Storage/Storage.php
@@ -23,6 +23,7 @@
namespace Test\Files\Storage;
use OC\Files\Cache\Watcher;
+use OCP\Files\Storage\IWriteStreamStorage;
abstract class Storage extends \Test\TestCase {
/**
@@ -628,4 +629,20 @@ abstract class Storage extends \Test\TestCase {
$this->instance->rename('bar.txt.part', 'bar.txt');
$this->assertEquals('bar', $this->instance->file_get_contents('bar.txt'));
}
+
+ public function testWriteStream() {
+ $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
+
+ if (!$this->instance->instanceOfStorage(IWriteStreamStorage::class)) {
+ $this->markTestSkipped('Not a WriteSteamStorage');
+ }
+ /** @var IWriteStreamStorage $storage */
+ $storage = $this->instance;
+
+ $source = fopen($textFile, 'r');
+
+ $storage->writeStream('test.txt', $source);
+ $this->assertTrue($storage->file_exists('test.txt'));
+ $this->assertEquals(file_get_contents($textFile), $storage->file_get_contents('test.txt'));
+ }
}