summaryrefslogtreecommitdiffstats
path: root/tests/lib/files
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2013-06-29 04:00:03 -0700
committerBart Visscher <bartv@thisnet.nl>2013-06-29 04:00:03 -0700
commitd699ee9845b17ddb0945f263e4370e453ef48684 (patch)
tree6307a70543fdda4134e840fe18f28df96f41e886 /tests/lib/files
parent68c0d54568bb70f5bf7d30551beecd1fa3704683 (diff)
parenta7c70915d592cd3cc06c6dc86ba3d2707d000871 (diff)
downloadnextcloud-server-d699ee9845b17ddb0945f263e4370e453ef48684.tar.gz
nextcloud-server-d699ee9845b17ddb0945f263e4370e453ef48684.zip
Merge pull request #3635 from owncloud/storage-wrapper
Give apps the option to wrap storage backends
Diffstat (limited to 'tests/lib/files')
-rw-r--r--tests/lib/files/mount/mount.php46
-rw-r--r--tests/lib/files/storage/wrapper.php26
2 files changed, 72 insertions, 0 deletions
diff --git a/tests/lib/files/mount/mount.php b/tests/lib/files/mount/mount.php
new file mode 100644
index 00000000000..b057204ad35
--- /dev/null
+++ b/tests/lib/files/mount/mount.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Files\Mount;
+
+
+use OC\Files\Storage\Loader;
+use OC\Files\Storage\Wrapper\Wrapper;
+
+class Mount extends \PHPUnit_Framework_TestCase {
+ public function testFromStorageObject() {
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mount = new \OC\Files\Mount\Mount($storage, '/foo');
+ $this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
+ }
+
+ public function testFromStorageClassname() {
+ $mount = new \OC\Files\Mount\Mount('\OC\Files\Storage\Temporary', '/foo');
+ $this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
+ }
+
+ public function testWrapper() {
+ $test = $this;
+ $wrapper = function ($mountPoint, $storage) use (&$test) {
+ $test->assertEquals('/foo/', $mountPoint);
+ $test->assertInstanceOf('\OC\Files\Storage\Storage', $storage);
+ return new Wrapper(array('storage' => $storage));
+ };
+
+ $loader = new Loader();
+ $loader->addStorageWrapper($wrapper);
+
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mount = new \OC\Files\Mount\Mount($storage, '/foo', array(), $loader);
+ $this->assertInstanceOf('\OC\Files\Storage\Wrapper\Wrapper', $mount->getStorage());
+ }
+}
diff --git a/tests/lib/files/storage/wrapper.php b/tests/lib/files/storage/wrapper.php
new file mode 100644
index 00000000000..2794a0a6263
--- /dev/null
+++ b/tests/lib/files/storage/wrapper.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Files\Storage;
+
+class Wrapper extends Storage {
+ /**
+ * @var string tmpDir
+ */
+ private $tmpDir;
+
+ public function setUp() {
+ $this->tmpDir = \OC_Helper::tmpFolder();
+ $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir));
+ $this->instance = new \OC\Files\Storage\Wrapper\Wrapper(array('storage' => $storage));
+ }
+
+ public function tearDown() {
+ \OC_Helper::rmdirr($this->tmpDir);
+ }
+}