summaryrefslogtreecommitdiffstats
path: root/tests/lib/files
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-03-30 13:59:48 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:28 +0200
commit498625ea3a9c5ad44597d39a8c4e1b1cdfe57929 (patch)
tree22ce40f10f214147677face2c4767db7e55aec80 /tests/lib/files
parenta905f641b3e619838c945caa29a1604f5b3ab8ba (diff)
downloadnextcloud-server-498625ea3a9c5ad44597d39a8c4e1b1cdfe57929.tar.gz
nextcloud-server-498625ea3a9c5ad44597d39a8c4e1b1cdfe57929.zip
adding unit tests for stream wrapper
Diffstat (limited to 'tests/lib/files')
-rw-r--r--tests/lib/files/stream/encryption.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/lib/files/stream/encryption.php b/tests/lib/files/stream/encryption.php
new file mode 100644
index 00000000000..51ccc3de390
--- /dev/null
+++ b/tests/lib/files/stream/encryption.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Test\Files\Stream;
+
+use OC\Files\View;
+use OCA\Encryption_Dummy\DummyModule;
+
+class Encryption extends \Test\TestCase {
+
+ /**
+ * @param string $mode
+ * @param integer $limit
+ */
+ protected function getStream($mode) {
+
+ $source = fopen('php://temp', $mode);
+ $internalPath = '';
+ $fullPath = '';
+ $header = [];
+ $uid = '';
+ $encryptionModule = new DummyModule();
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Storage')
+ ->disableOriginalConstructor()->getMock();
+ $encStorage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption')
+ ->disableOriginalConstructor()->getMock();
+ $util = new \OC\Encryption\Util(new View(), new \OC\User\Manager());;
+ $size = 12;
+ $unencryptedSize = 8000;
+
+ return \OC\Files\Stream\Encryption::wrap($source, $internalPath,
+ $fullPath, $header, $uid, $encryptionModule, $storage, $encStorage,
+ $util, $mode, $size, $unencryptedSize);
+ }
+
+ public function testWriteEnoughSpace() {
+ $stream = $this->getStream('w+');
+ $this->assertEquals(6, fwrite($stream, 'foobar'));
+ rewind($stream);
+ $this->assertEquals('foobar', fread($stream, 100));
+ }
+}