Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2022-08-24 19:01:10 +0300
committerJulius Härtl <jus@bitgrid.net>2022-08-24 23:20:32 +0300
commit83b1415906babd3ad521055dd2142fed09250ca6 (patch)
treed736456cc7a17d3ce4181cd5cc013852e54a7dde /tests
parent4baf960c218d9fc14c7827adf774286c45918855 (diff)
Only pass parent if paths matchperf/parent-node
As the user folder might be initialized by the root from two levels down the hierarchy, passing this as a parent only works if the path matches Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Node/FolderTest.php36
1 files changed, 33 insertions, 3 deletions
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index 2be0257aacb..ddf6c412dcd 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -14,6 +14,7 @@ use OC\Files\Config\CachedMountInfo;
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\Mount\MountPoint;
+use OC\Files\Node\File;
use OC\Files\Node\Folder;
use OC\Files\Node\Node;
use OC\Files\Node\Root;
@@ -105,11 +106,13 @@ class FolderTest extends NodeTest {
->method('getUser')
->willReturn($this->user);
+ $node = new File($root, $view, '/bar/foo/asd');
$root->method('get')
- ->with('/bar/foo/asd');
+ ->with('/bar/foo/asd')
+ ->willReturn($node);
- $node = new Folder($root, $view, '/bar/foo');
- $node->get('asd');
+ $parentNode = new Folder($root, $view, '/bar/foo');
+ self::assertEquals($node, $parentNode->get('asd'));
}
public function testNodeExists() {
@@ -183,6 +186,33 @@ class FolderTest extends NodeTest {
$this->assertEquals($child, $result);
}
+ public function testNewFolderDeepParent() {
+ $manager = $this->createMock(Manager::class);
+ /**
+ * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
+ */
+ $view = $this->createMock(View::class);
+ $root = $this->getMockBuilder(Root::class)
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->getMock();
+ $root->expects($this->any())
+ ->method('getUser')
+ ->willReturn($this->user);
+
+ $view->method('getFileInfo')
+ ->with('/foobar')
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
+
+ $view->method('mkdir')
+ ->with('/foobar/asd/sdf')
+ ->willReturn(true);
+
+ $node = new Folder($root, $view, '/foobar');
+ $child = new Folder($root, $view, '/foobar/asd/sdf', null, null);
+ $result = $node->newFolder('asd/sdf');
+ $this->assertEquals($child, $result);
+ }
+
public function testNewFolderNotPermitted() {
$this->expectException(\OCP\Files\NotPermittedException::class);