diff options
author | Robin Appelman <robin@icewind.nl> | 2018-11-28 15:18:29 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-11-28 15:18:29 +0100 |
commit | 9d9f6903c9e2a94f2a1b230fd35ec586b18b7a77 (patch) | |
tree | 3b9c04b67037cb4d1397e447a13b2cc563892a13 /tests/lib/Files/Node | |
parent | 802a978bb5c336edc0369335d1aa5d12807d2bcc (diff) | |
download | nextcloud-server-9d9f6903c9e2a94f2a1b230fd35ec586b18b7a77.tar.gz nextcloud-server-9d9f6903c9e2a94f2a1b230fd35ec586b18b7a77.zip |
Fix folder path containing leading slash when getting mount root by id
This fixes collabora on public link shared groupfolders
Fixes https://github.com/nextcloud/groupfolders/issues/225
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib/Files/Node')
-rw-r--r-- | tests/lib/Files/Node/FolderTest.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index c924c090232..2c87b645dd9 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -613,6 +613,54 @@ class FolderTest extends NodeTest { $this->assertEquals('/bar/foo/qwerty', $result[0]->getPath()); } + public function testGetByIdMountRoot() { + $manager = $this->createMock(Manager::class); + /** + * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view + */ + $view = $this->createMock(View::class); + $root = $this->getMockBuilder(Root::class) + ->setMethods(['getMountsIn', 'getMount']) + ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager]) + ->getMock(); + $storage = $this->createMock(\OC\Files\Storage\Storage::class); + $mount = new MountPoint($storage, '/bar'); + $cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([''])->getMock(); + + $fileInfo = new CacheEntry(['path' => '', 'mimetype' => 'text/plain'], null); + + $storage->expects($this->once()) + ->method('getCache') + ->will($this->returnValue($cache)); + + $this->userMountCache->expects($this->any()) + ->method('getMountsForFileId') + ->with(1) + ->will($this->returnValue([new CachedMountInfo( + $this->user, + 1, + 0, + '/bar/', + 1, + '' + )])); + + $cache->expects($this->once()) + ->method('get') + ->with(1) + ->will($this->returnValue($fileInfo)); + + $root->expects($this->once()) + ->method('getMount') + ->with('/bar') + ->will($this->returnValue($mount)); + + $node = new \OC\Files\Node\Folder($root, $view, '/bar'); + $result = $node->getById(1); + $this->assertEquals(1, count($result)); + $this->assertEquals('/bar', $result[0]->getPath()); + } + public function testGetByIdOutsideFolder() { $manager = $this->createMock(Manager::class); /** |