diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-04-26 00:01:36 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-04-26 00:01:36 +0200 |
commit | 809b5f81f6ee448563462ae8f642fbb8a6a11499 (patch) | |
tree | 88f31a78a59d073b3731e00c26bb6ae05be032a5 /tests/lib/files | |
parent | bcd9a6903317a786f5f947374a8680130e4a8297 (diff) | |
download | nextcloud-server-809b5f81f6ee448563462ae8f642fbb8a6a11499.tar.gz nextcloud-server-809b5f81f6ee448563462ae8f642fbb8a6a11499.zip |
Further seperation of mount management logic
Diffstat (limited to 'tests/lib/files')
-rw-r--r-- | tests/lib/files/mount.php | 58 | ||||
-rw-r--r-- | tests/lib/files/mount/manager.php | 67 |
2 files changed, 67 insertions, 58 deletions
diff --git a/tests/lib/files/mount.php b/tests/lib/files/mount.php deleted file mode 100644 index a3dc06cc668..00000000000 --- a/tests/lib/files/mount.php +++ /dev/null @@ -1,58 +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; - -use \OC\Files\Storage\Temporary; - -class LongId extends Temporary { - public function getId() { - return 'long:' . str_repeat('foo', 50) . parent::getId(); - } -} - -class Mount extends \PHPUnit_Framework_TestCase { - public function setup() { - \OC_Util::setupFS(); - \OC\Files\Mount::clear(); - } - - public function testFind() { - $this->assertNull(\OC\Files\Mount::find('/')); - - $rootMount = new \OC\Files\Mount(new Temporary(array()), '/'); - $this->assertEquals($rootMount, \OC\Files\Mount::find('/')); - $this->assertEquals($rootMount, \OC\Files\Mount::find('/foo/bar')); - - $storage = new Temporary(array()); - $mount = new \OC\Files\Mount($storage, '/foo'); - $this->assertEquals($rootMount, \OC\Files\Mount::find('/')); - $this->assertEquals($mount, \OC\Files\Mount::find('/foo/bar')); - - $this->assertEquals(1, count(\OC\Files\Mount::findIn('/'))); - new \OC\Files\Mount(new Temporary(array()), '/bar'); - $this->assertEquals(2, count(\OC\Files\Mount::findIn('/'))); - - $id = $mount->getStorageId(); - $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($id)); - - $mount2 = new \OC\Files\Mount($storage, '/foo/bar'); - $this->assertEquals(array($mount, $mount2), \OC\Files\Mount::findByStorageId($id)); - } - - public function testLong() { - $storage = new LongId(array()); - $mount = new \OC\Files\Mount($storage, '/foo'); - - $id = $mount->getStorageId(); - $storageId = $storage->getId(); - $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($id)); - $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($storageId)); - $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId(md5($storageId))); - } -} diff --git a/tests/lib/files/mount/manager.php b/tests/lib/files/mount/manager.php new file mode 100644 index 00000000000..154c35ccead --- /dev/null +++ b/tests/lib/files/mount/manager.php @@ -0,0 +1,67 @@ +<?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 \PHPUnit_Framework_TestCase { + /** + * @var \OC\Files\Mount\Manager + */ + private $manager; + + public function setup() { + $this->manager = new \OC\Files\Mount\Manager(); + } + + public function testFind() { + $this->assertNull($this->manager->find('/')); + + $rootMount = new \OC\Files\Mount\Mount(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\Mount($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\Mount(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\Mount($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\Mount($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))); + } +} |