aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/files/filesystem.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-05-07 14:07:02 +0200
committerRobin Appelman <icewind@owncloud.com>2015-06-02 14:07:54 +0200
commit24131586d74836a0f08f57511f5ec40a3d3ee156 (patch)
treeb9f26128084ba1c75ac1ada3589fcfc09232639a /tests/lib/files/filesystem.php
parentc91b52d38cdfe68d17485795be6811c2120280b9 (diff)
downloadnextcloud-server-24131586d74836a0f08f57511f5ec40a3d3ee156.tar.gz
nextcloud-server-24131586d74836a0f08f57511f5ec40a3d3ee156.zip
call mount providers that are registered after the filesystem is setup
Diffstat (limited to 'tests/lib/files/filesystem.php')
-rw-r--r--tests/lib/files/filesystem.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php
index 082d22781fa..b5ee27fad5a 100644
--- a/tests/lib/files/filesystem.php
+++ b/tests/lib/files/filesystem.php
@@ -22,11 +22,32 @@
namespace Test\Files;
+use OC\Files\Mount\MountPoint;
+use OC\Files\Storage\Temporary;
use OC\User\NoUserException;
+use OCP\Files\Config\IMountProvider;
+use OCP\Files\Storage\IStorageFactory;
+use OCP\IUser;
+
+class DummyMountProvider implements IMountProvider {
+ private $mounts = [];
+
+ /**
+ * @param array $mounts
+ */
+ public function __construct(array $mounts) {
+ $this->mounts = $mounts;
+ }
+
+ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
+ return isset($this->mounts[$user->getUID()]) ? $this->mounts[$user->getUID()] : [];
+ }
+}
class Filesystem extends \Test\TestCase {
const TEST_FILESYSTEM_USER1 = "test-filesystem-user1";
+ const TEST_FILESYSTEM_USER2 = "test-filesystem-user1";
/**
* @var array tmpDirs
@@ -44,6 +65,10 @@ class Filesystem extends \Test\TestCase {
protected function setUp() {
parent::setUp();
+ $userBackend = new \OC_User_Dummy();
+ $userBackend->createUser(self::TEST_FILESYSTEM_USER1, self::TEST_FILESYSTEM_USER1);
+ $userBackend->createUser(self::TEST_FILESYSTEM_USER2, self::TEST_FILESYSTEM_USER2);
+ \OC::$server->getUserManager()->registerBackend($userBackend);
$this->loginAsUser();
}
@@ -271,6 +296,7 @@ class Filesystem extends \Test\TestCase {
/**
* Tests that an exception is thrown when passed user does not exist.
+ *
* @expectedException \OC\User\NoUserException
*/
public function testLocalMountWhenUserDoesNotExist() {
@@ -380,4 +406,13 @@ class Filesystem extends \Test\TestCase {
\OC_Config::setValue('cache_path', $oldCachePath);
}
+
+ public function testRegisterMountProviderAfterSetup() {
+ \OC\Files\Filesystem::initMountPoints(self::TEST_FILESYSTEM_USER2);
+ $this->assertEquals('/', \OC\Files\Filesystem::getMountPoint('/foo/bar'));
+ $mount = new MountPoint(new Temporary([]), '/foo/bar');
+ $mountProvider = new DummyMountProvider([self::TEST_FILESYSTEM_USER2 => [$mount]]);
+ \OC::$server->getMountProviderCollection()->registerProvider($mountProvider);
+ $this->assertEquals('/foo/bar/', \OC\Files\Filesystem::getMountPoint('/foo/bar'));
+ }
}