|
23 | 23 |
|
24 | 24 | use DateTimeZone; |
25 | 25 | use OC\Files\Mount\MoveableMount; |
| 26 | +use OC\Files\Utils\PathHelper; |
26 | 27 | use OC\KnownUser\KnownUserService; |
27 | 28 | use OC\Share20\DefaultShareProvider; |
28 | 29 | use OC\Share20\Exception; |
@@ -213,6 +214,14 @@ private function createManagerMock() { |
213 | 214 | ]); |
214 | 215 | } |
215 | 216 |
|
| 217 | + private function createFolderMock(string $folderPath): MockObject&Folder { |
| 218 | + $folder = $this->createMock(Folder::class); |
| 219 | + $folder->method('getPath')->willReturn($folderPath); |
| 220 | + $folder->method('getRelativePath')->willReturnCallback( |
| 221 | + fn (string $path): ?string => PathHelper::getRelativePath($folderPath, $path) |
| 222 | + ); |
| 223 | + return $folder; |
| 224 | + } |
216 | 225 |
|
217 | 226 | public function testDeleteNoShareId() { |
218 | 227 | $this->expectException(\InvalidArgumentException::class); |
@@ -528,14 +537,11 @@ public function testPromoteReshare(): void { |
528 | 537 | ->setMethods(['updateShare', 'getSharesInFolder', 'generalCreateChecks']) |
529 | 538 | ->getMock(); |
530 | 539 |
|
531 | | - $folder = $this->createMock(Folder::class); |
532 | | - $folder->method('getPath')->willReturn('/path/to/folder'); |
| 540 | + $folder = $this->createFolderMock('/path/to/folder'); |
533 | 541 |
|
534 | | - $subFolder = $this->createMock(Folder::class); |
535 | | - $subFolder->method('getPath')->willReturn('/path/to/folder/sub'); |
| 542 | + $subFolder = $this->createFolderMock('/path/to/folder/sub'); |
536 | 543 |
|
537 | | - $otherFolder = $this->createMock(Folder::class); |
538 | | - $otherFolder->method('getPath')->willReturn('/path/to/otherfolder/'); |
| 544 | + $otherFolder = $this->createFolderMock('/path/to/otherfolder/'); |
539 | 545 |
|
540 | 546 | $share = $this->createMock(IShare::class); |
541 | 547 | $share->method('getShareType')->willReturn(IShare::TYPE_USER); |
@@ -581,8 +587,7 @@ public function testPromoteReshareWhenUserHasAnotherShare(): void { |
581 | 587 | ->setMethods(['updateShare', 'getSharesInFolder', 'getSharedWith', 'generalCreateChecks']) |
582 | 588 | ->getMock(); |
583 | 589 |
|
584 | | - $folder = $this->createMock(Folder::class); |
585 | | - $folder->method('getPath')->willReturn('/path/to/folder'); |
| 590 | + $folder = $this->createFolderMock('/path/to/folder'); |
586 | 591 |
|
587 | 592 | $share = $this->createMock(IShare::class); |
588 | 593 | $share->method('getShareType')->willReturn(IShare::TYPE_USER); |
@@ -610,8 +615,7 @@ public function testPromoteReshareOfUsersInGroupShare(): void { |
610 | 615 | ->setMethods(['updateShare', 'getSharesInFolder', 'getSharedWith', 'generalCreateChecks']) |
611 | 616 | ->getMock(); |
612 | 617 |
|
613 | | - $folder = $this->createMock(Folder::class); |
614 | | - $folder->method('getPath')->willReturn('/path/to/folder'); |
| 618 | + $folder = $this->createFolderMock('/path/to/folder'); |
615 | 619 |
|
616 | 620 | $userA = $this->createMock(IUser::class); |
617 | 621 | $userA->method('getUID')->willReturn('userA'); |
|
0 commit comments