aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Connector
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2023-02-18 15:43:39 +0100
committerSimon L <szaimen@e.mail.de>2023-04-17 23:46:52 +0200
commit160bd75d0ad59b3692ae2e904be52c9e4e7295f4 (patch)
treef2edd76f77c54c6d356ea14ab5e6b141716da01f /apps/dav/tests/unit/Connector
parent85c9e75f33c0c46bc33023d1f4af05f149d480c3 (diff)
downloadnextcloud-server-160bd75d0ad59b3692ae2e904be52c9e4e7295f4.tar.gz
nextcloud-server-160bd75d0ad59b3692ae2e904be52c9e4e7295f4.zip
fix: Use proper path when creating node instances
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/dav/tests/unit/Connector')
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
index c6365cf3168..b0d3bdd8ec7 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
@@ -29,9 +29,12 @@
namespace OCA\DAV\Tests\Unit\Connector\Sabre;
use OC\Files\FileInfo;
+use OC\Files\Filesystem;
use OC\Files\Node\Node;
use OC\Files\Storage\Wrapper\Quota;
+use OC\Files\View;
use OCA\DAV\Connector\Sabre\Directory;
+use OCP\Constants;
use OCP\Files\ForbiddenException;
use OCP\Files\Mount\IMountPoint;
use Test\Traits\UserTrait;
@@ -91,6 +94,10 @@ class DirectoryTest extends \Test\TestCase {
->willReturn(Node::TYPE_FOLDER);
$this->info->method('getName')
->willReturn("folder");
+ $this->info->method('getPath')
+ ->willReturn("/admin/files/folder");
+ $this->info->method('getPermissions')
+ ->willReturn(Constants::PERMISSION_READ);
}
private function getDir($path = '/') {
@@ -207,12 +214,21 @@ class DirectoryTest extends \Test\TestCase {
$this->view->expects($this->once())
->method('getDirectoryContent')
- ->with('')
->willReturn([$info1, $info2]);
$this->view->expects($this->any())
->method('getRelativePath')
- ->willReturn('');
+ ->willReturnCallback(function($path) {
+ return str_replace('/admin/files/', '', $path);
+ });
+
+ $this->view->expects($this->any())
+ ->method('getAbsolutePath')
+ ->willReturnCallback(function($path) {
+ return Filesystem::normalizePath('/admin/files' . $path);
+ });
+
+ $this->overwriteService(View::class, $this->view);
$dir = new Directory($this->view, $this->info);
$nodes = $dir->getChildren();