aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/files/mount
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/files/mount')
-rw-r--r--tests/lib/files/mount/manager.php68
-rw-r--r--tests/lib/files/mount/mount.php46
-rw-r--r--tests/lib/files/mount/mountpoint.php73
3 files changed, 0 insertions, 187 deletions
diff --git a/tests/lib/files/mount/manager.php b/tests/lib/files/mount/manager.php
deleted file mode 100644
index 78322b47d50..00000000000
--- a/tests/lib/files/mount/manager.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?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\Temporary;
-
-class LongId extends Temporary {
- public function getId() {
- return 'long:' . str_repeat('foo', 50) . parent::getId();
- }
-}
-
-class Manager extends \Test\TestCase {
- /**
- * @var \OC\Files\Mount\Manager
- */
- private $manager;
-
- protected function setup() {
- parent::setUp();
- $this->manager = new \OC\Files\Mount\Manager();
- }
-
- public function testFind() {
- $this->assertNull($this->manager->find('/'));
-
- $rootMount = new \OC\Files\Mount\MountPoint(new Temporary(array()), '/');
- $this->manager->addMount($rootMount);
- $this->assertEquals($rootMount, $this->manager->find('/'));
- $this->assertEquals($rootMount, $this->manager->find('/foo/bar'));
-
- $storage = new Temporary(array());
- $mount1 = new \OC\Files\Mount\MountPoint($storage, '/foo');
- $this->manager->addMount($mount1);
- $this->assertEquals($rootMount, $this->manager->find('/'));
- $this->assertEquals($mount1, $this->manager->find('/foo/bar'));
-
- $this->assertEquals(1, count($this->manager->findIn('/')));
- $mount2 = new \OC\Files\Mount\MountPoint(new Temporary(array()), '/bar');
- $this->manager->addMount($mount2);
- $this->assertEquals(2, count($this->manager->findIn('/')));
-
- $id = $mount1->getStorageId();
- $this->assertEquals(array($mount1), $this->manager->findByStorageId($id));
-
- $mount3 = new \OC\Files\Mount\MountPoint($storage, '/foo/bar');
- $this->manager->addMount($mount3);
- $this->assertEquals(array($mount1, $mount3), $this->manager->findByStorageId($id));
- }
-
- public function testLong() {
- $storage = new LongId(array());
- $mount = new \OC\Files\Mount\MountPoint($storage, '/foo');
- $this->manager->addMount($mount);
-
- $id = $mount->getStorageId();
- $storageId = $storage->getId();
- $this->assertEquals(array($mount), $this->manager->findByStorageId($id));
- $this->assertEquals(array($mount), $this->manager->findByStorageId($storageId));
- $this->assertEquals(array($mount), $this->manager->findByStorageId(md5($storageId)));
- }
-}
diff --git a/tests/lib/files/mount/mount.php b/tests/lib/files/mount/mount.php
deleted file mode 100644
index 584766de836..00000000000
--- a/tests/lib/files/mount/mount.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?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\StorageFactory;
-use OC\Files\Storage\Wrapper\Wrapper;
-
-class Mount extends \Test\TestCase {
- public function testFromStorageObject() {
- $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
- ->disableOriginalConstructor()
- ->getMock();
- $mount = new \OC\Files\Mount\MountPoint($storage, '/foo');
- $this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
- }
-
- public function testFromStorageClassname() {
- $mount = new \OC\Files\Mount\MountPoint('\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 StorageFactory();
- $loader->addStorageWrapper('test_wrapper', $wrapper);
-
- $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
- ->disableOriginalConstructor()
- ->getMock();
- $mount = new \OC\Files\Mount\MountPoint($storage, '/foo', array(), $loader);
- $this->assertInstanceOf('\OC\Files\Storage\Wrapper\Wrapper', $mount->getStorage());
- }
-}
diff --git a/tests/lib/files/mount/mountpoint.php b/tests/lib/files/mount/mountpoint.php
deleted file mode 100644
index 29610e6058d..00000000000
--- a/tests/lib/files/mount/mountpoint.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-/**
- * Copyright (c) 2015 Vincent Petry <pvince81@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;
-
-class MountPoint extends \Test\TestCase {
-
- public function testGetStorage() {
- $storage = $this->getMock('\OCP\Files\Storage');
- $storage->expects($this->once())
- ->method('getId')
- ->will($this->returnValue(123));
-
- $loader = $this->getMock('\OCP\Files\Storage\IStorageFactory');
- $loader->expects($this->once())
- ->method('getInstance')
- ->will($this->returnValue($storage));
-
- $mountPoint = new \OC\Files\Mount\MountPoint(
- // just use this because a real class is needed
- '\Test\Files\Mount\MountPoint',
- '/mountpoint',
- null,
- $loader
- );
-
- $this->assertEquals($storage, $mountPoint->getStorage());
- $this->assertEquals(123, $mountPoint->getStorageId());
- $this->assertEquals('/mountpoint/', $mountPoint->getMountPoint());
-
- $mountPoint->setMountPoint('another');
- $this->assertEquals('/another/', $mountPoint->getMountPoint());
- }
-
- public function testInvalidStorage() {
- $loader = $this->getMock('\OCP\Files\Storage\IStorageFactory');
- $loader->expects($this->once())
- ->method('getInstance')
- ->will($this->throwException(new \Exception('Test storage init exception')));
-
- $called = false;
- $wrapper = function($mountPoint, $storage) use ($called) {
- $called = true;
- };
-
- $mountPoint = new \OC\Files\Mount\MountPoint(
- // just use this because a real class is needed
- '\Test\Files\Mount\MountPoint',
- '/mountpoint',
- null,
- $loader
- );
-
- $this->assertNull($mountPoint->getStorage());
- // call it again to make sure the init code only ran once
- $this->assertNull($mountPoint->getStorage());
-
- $this->assertNull($mountPoint->getStorageId());
-
- // wrapping doesn't fail
- $mountPoint->wrapStorage($wrapper);
-
- $this->assertNull($mountPoint->getStorage());
-
- // storage wrapper never called
- $this->assertFalse($called);
- }
-}