aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-10-14 17:23:29 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-12-19 14:44:08 +0100
commit28c885dbf23732aa104b31fa5d1c956cf287f210 (patch)
tree40e67d0c9e464c7cb4d9d2ab40ce1b2515b9d7e3 /tests
parente30cd2f03f81d805bcb3c80f6c1f9d04984f7ebd (diff)
downloadnextcloud-server-28c885dbf23732aa104b31fa5d1c956cf287f210.tar.gz
nextcloud-server-28c885dbf23732aa104b31fa5d1c956cf287f210.zip
fix: Use getRelativePath method to check if node is inside folderbackport/47425/stable30
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Share20/ManagerTest.php24
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index d21ac89fd03..c780d29bfed 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -9,6 +9,7 @@ namespace Test\Share20;
use DateTimeZone;
use OC\Files\Mount\MoveableMount;
+use OC\Files\Utils\PathHelper;
use OC\KnownUser\KnownUserService;
use OC\Share20\DefaultShareProvider;
use OC\Share20\Exception;
@@ -199,6 +200,14 @@ class ManagerTest extends \Test\TestCase {
]);
}
+ private function createFolderMock(string $folderPath): MockObject&Folder {
+ $folder = $this->createMock(Folder::class);
+ $folder->method('getPath')->willReturn($folderPath);
+ $folder->method('getRelativePath')->willReturnCallback(
+ fn (string $path): ?string => PathHelper::getRelativePath($folderPath, $path)
+ );
+ return $folder;
+ }
public function testDeleteNoShareId() {
$this->expectException(\InvalidArgumentException::class);
@@ -514,14 +523,11 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['updateShare', 'getSharesInFolder', 'generalCreateChecks'])
->getMock();
- $folder = $this->createMock(Folder::class);
- $folder->method('getPath')->willReturn('/path/to/folder');
+ $folder = $this->createFolderMock('/path/to/folder');
- $subFolder = $this->createMock(Folder::class);
- $subFolder->method('getPath')->willReturn('/path/to/folder/sub');
+ $subFolder = $this->createFolderMock('/path/to/folder/sub');
- $otherFolder = $this->createMock(Folder::class);
- $otherFolder->method('getPath')->willReturn('/path/to/otherfolder/');
+ $otherFolder = $this->createFolderMock('/path/to/otherfolder/');
$share = $this->createMock(IShare::class);
$share->method('getShareType')->willReturn(IShare::TYPE_USER);
@@ -567,8 +573,7 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['updateShare', 'getSharesInFolder', 'getSharedWith', 'generalCreateChecks'])
->getMock();
- $folder = $this->createMock(Folder::class);
- $folder->method('getPath')->willReturn('/path/to/folder');
+ $folder = $this->createFolderMock('/path/to/folder');
$share = $this->createMock(IShare::class);
$share->method('getShareType')->willReturn(IShare::TYPE_USER);
@@ -596,8 +601,7 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['updateShare', 'getSharesInFolder', 'getSharedWith', 'generalCreateChecks'])
->getMock();
- $folder = $this->createMock(Folder::class);
- $folder->method('getPath')->willReturn('/path/to/folder');
+ $folder = $this->createFolderMock('/path/to/folder');
$userA = $this->createMock(IUser::class);
$userA->method('getUID')->willReturn('userA');