summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-03-05 17:10:32 +0100
committerRobin Appelman <icewind@owncloud.com>2015-03-11 15:06:12 +0100
commit82a62fd24905c3072e19257171838bcf9c6d48ab (patch)
tree1c6179f2b1e520364e6d6167abb2de7ed96eee18 /tests
parente5c8fd37df9a5727bdfdf3664390b911a67a617a (diff)
downloadnextcloud-server-82a62fd24905c3072e19257171838bcf9c6d48ab.tar.gz
nextcloud-server-82a62fd24905c3072e19257171838bcf9c6d48ab.zip
Add test for storage factory
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/storage/storagefactory.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/lib/files/storage/storagefactory.php b/tests/lib/files/storage/storagefactory.php
new file mode 100644
index 00000000000..83cae447a4f
--- /dev/null
+++ b/tests/lib/files/storage/storagefactory.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Copyright (c) 2015 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;
+
+use OC\Files\Mount\MountPoint;
+use OCP\Files\Mount\IMountPoint;
+use OCP\Files\Storage;
+use Test\TestCase;
+use OC\Files\Storage\Wrapper\Wrapper;
+
+class DummyWrapper extends Wrapper {
+
+}
+
+class StorageFactory extends TestCase {
+ public function testSimpleWrapper() {
+ $instance = new \OC\Files\Storage\StorageFactory();
+ $mount = new MountPoint('\OC\Files\Storage\Temporary', '/foo', [[]], $instance);
+ $instance->addStorageWrapper('dummy', function ($mountPoint, Storage $storage, IMountPoint $mount) {
+ $this->assertInstanceOf('\OC\Files\Storage\Temporary', $storage);
+ $this->assertEquals('/foo/', $mount->getMountPoint());
+ $this->assertEquals('/foo/', $mountPoint);
+ return new DummyWrapper(['storage' => $storage]);
+ });
+ $wrapped = $mount->getStorage();
+ $this->assertInstanceOf('\Test\Files\Storage\DummyWrapper', $wrapped);
+ }
+
+ public function testRemoveWrapper() {
+ $instance = new \OC\Files\Storage\StorageFactory();
+ $mount = new MountPoint('\OC\Files\Storage\Temporary', '/foo', [[]], $instance);
+ $instance->addStorageWrapper('dummy', function ($mountPoint, Storage $storage) {
+ return new DummyWrapper(['storage' => $storage]);
+ });
+ $instance->removeStorageWrapper('dummy');
+ $wrapped = $mount->getStorage();
+ $this->assertInstanceOf('\OC\Files\Storage\Temporary', $wrapped);
+ }
+}