summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFlorin Peter <github@florin-peter.de>2013-05-01 01:38:06 +0200
committerFlorin Peter <github@florin-peter.de>2013-05-01 01:38:06 +0200
commit3c100af1329c1c101f38f23f2d74710954387fdf (patch)
tree9b8dff5ea23da3ca6ed6984f8cec741143e42833 /tests
parent5deba29bdfedc3ee2babece9eafff0bb709cd90c (diff)
downloadnextcloud-server-3c100af1329c1c101f38f23f2d74710954387fdf.tar.gz
nextcloud-server-3c100af1329c1c101f38f23f2d74710954387fdf.zip
revert changes to fbbc76f281f50afa3072d99e4e0d413df835b3d3 because master is very unstable right now
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/mount.php58
-rw-r--r--tests/lib/files/mount/manager.php67
-rw-r--r--tests/lib/streamwrappers.php4
3 files changed, 60 insertions, 69 deletions
diff --git a/tests/lib/files/mount.php b/tests/lib/files/mount.php
new file mode 100644
index 00000000000..a3dc06cc668
--- /dev/null
+++ b/tests/lib/files/mount.php
@@ -0,0 +1,58 @@
+<?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
deleted file mode 100644
index 154c35ccead..00000000000
--- a/tests/lib/files/mount/manager.php
+++ /dev/null
@@ -1,67 +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 \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)));
- }
-}
diff --git a/tests/lib/streamwrappers.php b/tests/lib/streamwrappers.php
index c7e51ccfa48..2237ee7d378 100644
--- a/tests/lib/streamwrappers.php
+++ b/tests/lib/streamwrappers.php
@@ -77,10 +77,10 @@ class Test_StreamWrappers extends PHPUnit_Framework_TestCase {
}
public function testOC() {
- \OC\Files\Filesystem::clearMounts();
+ \OC\Files\Mount::clear();
$storage = new \OC\Files\Storage\Temporary(array());
$storage->file_put_contents('foo.txt', 'asd');
- \OC\Files\Filesystem::mount($storage, array(), '/');
+ new \OC\Files\Mount($storage, '/');
$this->assertTrue(file_exists('oc:///foo.txt'));
$this->assertEquals('asd', file_get_contents('oc:///foo.txt'));