Skip to content

Commit 4e04820

Browse files
committed
test: adjust tests to new trashbin quota check
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent f4c2342 commit 4e04820

1 file changed

Lines changed: 36 additions & 5 deletions

File tree

apps/files_trashbin/tests/Sabre/TrashbinPluginTest.php

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
namespace OCA\Files_Trashbin\Tests\Sabre;
1010

1111
use OC\Files\FileInfo;
12-
use OC\Files\View;
1312
use OCA\Files_Trashbin\Sabre\ITrash;
1413
use OCA\Files_Trashbin\Sabre\RestoreFolder;
1514
use OCA\Files_Trashbin\Sabre\TrashbinPlugin;
1615
use OCA\Files_Trashbin\Trash\ITrashItem;
16+
use OCP\Files\Folder;
17+
use OCP\Files\IRootFolder;
18+
use OCP\Files\Mount\IMountManager;
19+
use OCP\Files\Mount\IMountPoint;
20+
use OCP\Files\Storage\IStorage;
1721
use OCP\IPreview;
22+
use OCP\IUser;
1823
use Sabre\DAV\Server;
1924
use Sabre\DAV\Tree;
2025
use Test\TestCase;
@@ -34,6 +39,13 @@ public function testQuota(int $quota, int $fileSize, bool $expectedResult): void
3439
$fileInfo = $this->createMock(ITrashItem::class);
3540
$fileInfo->method('getSize')
3641
->willReturn($fileSize);
42+
$user = $this->createMock(IUser::class);
43+
$user->method('getUID')
44+
->willReturn('test');
45+
$fileInfo->method('getUser')
46+
->willReturn($user);
47+
$fileInfo->method('getOriginalLocation')
48+
->willReturn('relative/original/location');
3749

3850
$trashNode = $this->createMock(ITrash::class);
3951
$trashNode->method('getFileInfo')
@@ -46,11 +58,30 @@ public function testQuota(int $quota, int $fileSize, bool $expectedResult): void
4658

4759
$previewManager = $this->createMock(IPreview::class);
4860

49-
$view = $this->createMock(View::class);
50-
$view->method('free_space')
61+
$userFolder = $this->createMock(Folder::class);
62+
$userFolder->method('getFullPath')
63+
->with('relative/original') // the parent path
64+
->willReturn('/full/path/to/original');
65+
$rootFolder = $this->createMock(IRootFolder::class);
66+
$rootFolder->method('getUserFolder')
67+
->willReturn($userFolder);
68+
69+
$storage = $this->createMock(IStorage::class);
70+
$storage->method('free_space')
71+
->with('path/to/original')
5172
->willReturn($quota);
73+
$mount = $this->createMock(IMountPoint::class);
74+
$mount->method('getStorage')
75+
->willReturn($storage);
76+
$mount->method('getInternalPath')
77+
->with('/full/path/to/original')
78+
->willReturn('path/to/original');
79+
$mountManager = $this->createMock(IMountManager::class);
80+
$mountManager->method('find')
81+
->with('/full/path/to/original')
82+
->willReturn($mount);
5283

53-
$plugin = new TrashbinPlugin($previewManager, $view);
84+
$plugin = new TrashbinPlugin($previewManager, $rootFolder, $mountManager);
5485
$plugin->initialize($this->server);
5586

5687
$sourcePath = 'trashbin/test/trash/file1';
@@ -63,7 +94,7 @@ public static function quotaProvider(): array {
6394
[ 1024, 512, true ],
6495
[ 512, 513, false ],
6596
[ FileInfo::SPACE_NOT_COMPUTED, 1024, true ],
66-
[ FileInfo::SPACE_UNKNOWN, 1024, true ],
97+
[ FileInfo::SPACE_UNKNOWN, 1024, true],
6798
[ FileInfo::SPACE_UNLIMITED, 1024, true ]
6899
];
69100
}

0 commit comments

Comments
 (0)