summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-02-23 12:31:22 +0100
committerVincent Petry <pvince81@owncloud.com>2015-02-25 16:03:15 +0100
commit20738d287e456ddb05a617f6b808f152cc3028a9 (patch)
tree30614bb8beaf76326367a5efffb3df8e733b709f /tests
parent14c592fe865748f38dd6ee31634d053f83a8e791 (diff)
downloadnextcloud-server-20738d287e456ddb05a617f6b808f152cc3028a9.tar.gz
nextcloud-server-20738d287e456ddb05a617f6b808f152cc3028a9.zip
Properly detect streamCopy errors
Now checking whether the written bytes match the number of read bytes.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/storage/wrapper/quota.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/lib/files/storage/wrapper/quota.php b/tests/lib/files/storage/wrapper/quota.php
index dc4de4697db..8ca8f308b71 100644
--- a/tests/lib/files/storage/wrapper/quota.php
+++ b/tests/lib/files/storage/wrapper/quota.php
@@ -99,6 +99,28 @@ class Quota extends \Test\Files\Storage\Storage {
$this->assertEquals('foobarqwe', $instance->file_get_contents('foo'));
}
+ public function testStreamCopyWithEnoughSpace() {
+ $instance = $this->getLimitedStorage(16);
+ $inputStream = fopen('data://text/plain,foobarqwerty', 'r');
+ $outputStream = $instance->fopen('foo', 'w+');
+ list($count, $result) = \OC_Helper::streamCopy($inputStream, $outputStream);
+ $this->assertEquals(12, $count);
+ $this->assertTrue($result);
+ fclose($inputStream);
+ fclose($outputStream);
+ }
+
+ public function testStreamCopyNotEnoughSpace() {
+ $instance = $this->getLimitedStorage(9);
+ $inputStream = fopen('data://text/plain,foobarqwerty', 'r');
+ $outputStream = $instance->fopen('foo', 'w+');
+ list($count, $result) = \OC_Helper::streamCopy($inputStream, $outputStream);
+ $this->assertEquals(9, $count);
+ $this->assertFalse($result);
+ fclose($inputStream);
+ fclose($outputStream);
+ }
+
public function testReturnFalseWhenFopenFailed() {
$failStorage = $this->getMock(
'\OC\Files\Storage\Local',