summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFlorin Peter <github@florin-peter.de>2013-04-30 20:53:56 +0200
committerFlorin Peter <github@florin-peter.de>2013-04-30 20:53:56 +0200
commitb2da07fe95b383c35ae0f0fd55756e0f409d4fcf (patch)
tree21b38224ec671ecf68bd9604a9a553a40f3f1677 /tests
parentfbbc76f281f50afa3072d99e4e0d413df835b3d3 (diff)
parent4ab3614248df4834aa6e1a684760e89c641d4818 (diff)
downloadnextcloud-server-b2da07fe95b383c35ae0f0fd55756e0f409d4fcf.tar.gz
nextcloud-server-b2da07fe95b383c35ae0f0fd55756e0f409d4fcf.zip
Merge branch 'master' into files_encryption to get the latest files_trashbin app
Conflicts: apps/files/l10n/bn_BD.php apps/files/l10n/da.php apps/files/l10n/de.php apps/files/l10n/de_DE.php apps/files/l10n/fa.php apps/files/l10n/fi_FI.php apps/files/l10n/hr.php apps/files/l10n/ms_MY.php apps/files/l10n/ro.php apps/files/l10n/si_LK.php apps/files/l10n/sl.php apps/files/l10n/ta_LK.php apps/files_external/l10n/de_DE.php apps/files_external/l10n/et_EE.php apps/user_ldap/l10n/tr.php core/l10n/bg_BG.php l10n/af_ZA/files.po l10n/af_ZA/files_external.po l10n/ar/core.po l10n/ar/files.po l10n/ar/files_external.po l10n/be/files.po l10n/be/files_external.po l10n/bg_BG/core.po l10n/bg_BG/files.po l10n/bg_BG/files_external.po l10n/bg_BG/files_trashbin.po l10n/bg_BG/files_versions.po l10n/bg_BG/settings.po l10n/bn_BD/core.po l10n/bn_BD/files.po l10n/bn_BD/files_external.po l10n/ca/core.po l10n/ca/files.po l10n/ca/files_external.po l10n/cs_CZ/core.po l10n/cs_CZ/files.po l10n/cs_CZ/files_external.po l10n/cs_CZ/lib.po l10n/cy_GB/core.po l10n/cy_GB/files.po l10n/cy_GB/files_external.po l10n/cy_GB/settings.po l10n/da/core.po l10n/da/files.po l10n/da/files_external.po l10n/de/core.po l10n/de/files.po l10n/de/files_external.po l10n/de_DE/core.po l10n/de_DE/files.po l10n/de_DE/files_external.po l10n/el/core.po l10n/el/files.po l10n/el/files_external.po l10n/eo/core.po l10n/eo/files.po l10n/eo/files_external.po l10n/es/core.po l10n/es/files.po l10n/es/files_external.po l10n/es_AR/core.po l10n/es_AR/files.po l10n/es_AR/files_external.po l10n/et_EE/core.po l10n/et_EE/files.po l10n/et_EE/files_external.po l10n/eu/core.po l10n/eu/files.po l10n/eu/files_external.po l10n/fa/core.po l10n/fa/files.po l10n/fa/files_external.po l10n/fi/files.po l10n/fi_FI/core.po l10n/fi_FI/files.po l10n/fi_FI/files_external.po l10n/fr/core.po l10n/fr/files.po l10n/fr/files_external.po l10n/gl/core.po l10n/gl/files.po l10n/gl/files_external.po l10n/he/core.po l10n/he/files.po l10n/he/files_external.po l10n/hi/files.po l10n/hi/files_external.po l10n/hr/core.po l10n/hr/files.po l10n/hr/files_external.po l10n/hu_HU/core.po l10n/hu_HU/files.po l10n/hu_HU/files_external.po l10n/hy/files.po l10n/hy/files_external.po l10n/ia/core.po l10n/ia/files.po l10n/ia/files_external.po l10n/id/core.po l10n/id/files.po l10n/id/files_external.po l10n/is/core.po l10n/is/files.po l10n/is/files_external.po l10n/it/core.po l10n/it/files.po l10n/it/files_external.po l10n/ja_JP/core.po l10n/ja_JP/files.po l10n/ja_JP/files_external.po l10n/ka/files.po l10n/ka/files_external.po l10n/ka_GE/core.po l10n/ka_GE/files.po l10n/ka_GE/files_external.po l10n/kn/files.po l10n/kn/files_external.po l10n/ko/core.po l10n/ko/files.po l10n/ko/files_external.po l10n/ku_IQ/files.po l10n/ku_IQ/files_external.po l10n/lb/core.po l10n/lb/files.po l10n/lb/files_external.po l10n/lt_LT/core.po l10n/lt_LT/files.po l10n/lt_LT/files_external.po l10n/lv/core.po l10n/lv/files.po l10n/lv/files_external.po l10n/mk/core.po l10n/mk/files.po l10n/mk/files_external.po l10n/ms_MY/core.po l10n/ms_MY/files.po l10n/ms_MY/files_external.po l10n/my_MM/files.po l10n/my_MM/files_external.po l10n/nb_NO/core.po l10n/nb_NO/files.po l10n/nb_NO/files_external.po l10n/ne/files.po l10n/ne/files_external.po l10n/nl/core.po l10n/nl/files.po l10n/nl/files_external.po l10n/nn_NO/files.po l10n/nn_NO/files_external.po l10n/oc/core.po l10n/oc/files.po l10n/oc/files_external.po l10n/pl/core.po l10n/pl/files.po l10n/pl/files_external.po l10n/pl_PL/files.po l10n/pt_BR/core.po l10n/pt_BR/files.po l10n/pt_BR/files_external.po l10n/pt_PT/core.po l10n/pt_PT/files.po l10n/pt_PT/files_external.po l10n/ro/core.po l10n/ro/files.po l10n/ro/files_external.po l10n/ru/core.po l10n/ru/files.po l10n/ru/files_external.po l10n/ru_RU/core.po l10n/ru_RU/files.po l10n/si_LK/core.po l10n/si_LK/files.po l10n/si_LK/files_external.po l10n/sk/files.po l10n/sk/files_external.po l10n/sk_SK/core.po l10n/sk_SK/files.po l10n/sk_SK/files_external.po l10n/sl/core.po l10n/sl/files.po l10n/sl/files_external.po l10n/sq/core.po l10n/sq/files.po l10n/sq/files_external.po l10n/sr/core.po l10n/sr/files.po l10n/sr/files_external.po l10n/sr@latin/files.po l10n/sr@latin/files_external.po l10n/sv/core.po l10n/sv/files.po l10n/sv/files_external.po l10n/sw_KE/files.po l10n/sw_KE/files_external.po l10n/ta_LK/core.po l10n/ta_LK/files.po l10n/ta_LK/files_external.po l10n/te/files.po l10n/te/files_external.po l10n/templates/core.pot l10n/templates/files.pot l10n/templates/files_encryption.pot l10n/templates/files_external.pot l10n/templates/files_sharing.pot l10n/templates/files_trashbin.pot l10n/templates/files_versions.pot l10n/templates/lib.pot l10n/templates/settings.pot l10n/templates/user_ldap.pot l10n/templates/user_webdavauth.pot l10n/th_TH/core.po l10n/th_TH/files.po l10n/th_TH/files_external.po l10n/tr/core.po l10n/tr/files.po l10n/tr/files_external.po l10n/tr/user_ldap.po l10n/uk/core.po l10n/uk/files.po l10n/uk/files_external.po l10n/ur_PK/files.po l10n/ur_PK/files_external.po l10n/vi/core.po l10n/vi/files.po l10n/vi/files_external.po l10n/zh_CN.GB2312/core.po l10n/zh_CN.GB2312/files.po l10n/zh_CN.GB2312/files_external.po l10n/zh_CN/core.po l10n/zh_CN/files.po l10n/zh_CN/files_external.po l10n/zh_HK/core.po l10n/zh_HK/files.po l10n/zh_HK/files_external.po l10n/zh_TW/core.po l10n/zh_TW/files.po l10n/zh_TW/files_external.po lib/base.php lib/files/mount/mount.php
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, 69 insertions, 60 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)));
+ }
+}
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'));