diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-06-08 13:42:02 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-06-08 13:42:02 +0200 |
commit | a968b8409d153257d63cc78f71139303557f4617 (patch) | |
tree | 6b6cdf36c6df99f0f5ef1999814b2645a4edc719 /tests | |
parent | f051b7381ba00d538dd5ad0b1ba5b016d4aa62b1 (diff) | |
parent | a9455be14a36013adead81de06e3799e6e7efb9b (diff) | |
download | nextcloud-server-a968b8409d153257d63cc78f71139303557f4617.tar.gz nextcloud-server-a968b8409d153257d63cc78f71139303557f4617.zip |
Merge pull request #16158 from owncloud/mountprovider-after-setup
Call newly registered mount providers after the filesystem is setup
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/filesystem.php | 42 | ||||
-rw-r--r-- | tests/lib/hooks/forwardingemitter.php | 2 |
2 files changed, 43 insertions, 1 deletions
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index 082d22781fa..b7061bd19a0 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -22,11 +22,39 @@ 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; + } + + /** + * Get the pre-registered mount points + * + * @param IUser $user + * @param IStorageFactory $loader + * @return \OCP\Files\Mount\IMountPoint[] + */ + 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 +72,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 +303,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 +413,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')); + } } diff --git a/tests/lib/hooks/forwardingemitter.php b/tests/lib/hooks/forwardingemitter.php index decf6bb354c..5e8e252d3e3 100644 --- a/tests/lib/hooks/forwardingemitter.php +++ b/tests/lib/hooks/forwardingemitter.php @@ -17,7 +17,7 @@ class DummyForwardingEmitter extends \OC\Hooks\ForwardingEmitter { /** * @param \OC\Hooks\Emitter $emitter */ - public function forward($emitter) { + public function forward(\OC\Hooks\Emitter $emitter) { parent::forward($emitter); } } |