summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/cache/cache.php7
-rw-r--r--tests/lib/files/cache/updater.php9
-rw-r--r--tests/lib/files/mount.php58
-rw-r--r--tests/lib/files/mount/manager.php67
-rw-r--r--tests/lib/streamwrappers.php4
5 files changed, 76 insertions, 69 deletions
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index 250842805e5..4051a6e234b 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -162,10 +162,11 @@ class Cache extends \PHPUnit_Framework_TestCase {
$file4 = 'folder/foo/1';
$file5 = 'folder/foo/2';
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar');
+ $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
- $this->cache->put($file1, $data);
- $this->cache->put($file2, $data);
- $this->cache->put($file3, $data);
+ $this->cache->put($file1, $folderData);
+ $this->cache->put($file2, $folderData);
+ $this->cache->put($file3, $folderData);
$this->cache->put($file4, $data);
$this->cache->put($file5, $data);
diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php
index aaf932c97fe..dad3cd7e650 100644
--- a/tests/lib/files/cache/updater.php
+++ b/tests/lib/files/cache/updater.php
@@ -42,14 +42,11 @@ class Updater extends \PHPUnit_Framework_TestCase {
$this->scanner->scan('');
$this->cache = $this->storage->getCache();
+ \OC\Files\Filesystem::tearDown();
if (!self::$user) {
- if (!\OC\Files\Filesystem::getView()) {
- self::$user = uniqid();
- \OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
- } else {
- self::$user = \OC_User::getUser();
- }
+ self::$user = uniqid();
}
+ \OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
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)));
+ }
+}
diff --git a/tests/lib/streamwrappers.php b/tests/lib/streamwrappers.php
index 2237ee7d378..c7e51ccfa48 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\Mount::clear();
+ \OC\Files\Filesystem::clearMounts();
$storage = new \OC\Files\Storage\Temporary(array());
$storage->file_put_contents('foo.txt', 'asd');
- new \OC\Files\Mount($storage, '/');
+ \OC\Files\Filesystem::mount($storage, array(), '/');
$this->assertTrue(file_exists('oc:///foo.txt'));
$this->assertEquals('asd', file_get_contents('oc:///foo.txt'));