88namespace OCA \Files_Trashbin \Tests \Sabre ;
99
1010use OC \Files \FileInfo ;
11- use OC \Files \View ;
1211use OCA \Files_Trashbin \Sabre \ITrash ;
1312use OCA \Files_Trashbin \Sabre \RestoreFolder ;
1413use OCA \Files_Trashbin \Sabre \TrashbinPlugin ;
1514use OCA \Files_Trashbin \Trash \ITrashItem ;
15+ use OCP \Files \Folder ;
16+ use OCP \Files \IRootFolder ;
17+ use OCP \Files \Mount \IMountManager ;
18+ use OCP \Files \Mount \IMountPoint ;
19+ use OCP \Files \Storage \IStorage ;
1620use OCP \IPreview ;
21+ use OCP \IUser ;
1722use Sabre \DAV \Server ;
1823use Sabre \DAV \Tree ;
1924use Test \TestCase ;
@@ -34,6 +39,13 @@ protected function setUp(): void {
3439 public function testQuota (int $ quota , int $ fileSize , bool $ expectedResult ): void {
3540 $ fileInfo = $ this ->createMock (ITrashItem::class);
3641 $ fileInfo ->method ('getSize ' )->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 ' )->willReturn ($ fileInfo );
@@ -44,10 +56,29 @@ public function testQuota(int $quota, int $fileSize, bool $expectedResult): void
4456
4557 $ previewManager = $ this ->createMock (IPreview::class);
4658
47- $ view = $ this ->createMock (View::class);
48- $ view ->method ('free_space ' )->willReturn ($ quota );
59+ $ userFolder = $ this ->createMock (Folder::class);
60+ $ userFolder ->method ('getFullPath ' )
61+ ->with ('relative/original ' ) // the parent path
62+ ->willReturn ('/full/path/to/original ' );
63+ $ rootFolder = $ this ->createMock (IRootFolder::class);
64+ $ rootFolder ->method ('getUserFolder ' )
65+ ->willReturn ($ userFolder );
4966
50- $ plugin = new TrashbinPlugin ($ previewManager , $ view );
67+ $ storage = $ this ->createMock (IStorage::class);
68+ $ storage ->method ('free_space ' )->with ('path/to/original ' )
69+ ->willReturn ($ quota );
70+ $ mount = $ this ->createMock (IMountPoint::class);
71+ $ mount ->method ('getStorage ' )
72+ ->willReturn ($ storage );
73+ $ mount ->method ('getInternalPath ' )
74+ ->with ('/full/path/to/original ' )
75+ ->willReturn ('path/to/original ' );
76+ $ mountManager = $ this ->createMock (IMountManager::class);
77+ $ mountManager ->method ('find ' )
78+ ->with ('/full/path/to/original ' )
79+ ->willReturn ($ mount );
80+
81+ $ plugin = new TrashbinPlugin ($ previewManager , $ rootFolder , $ mountManager );
5182 $ plugin ->initialize ($ this ->server );
5283
5384 $ sourcePath = 'trashbin/test/trash/file1 ' ;
@@ -60,7 +91,7 @@ public function quotaProvider(): array {
6091 [ 1024 , 512 , true ],
6192 [ 512 , 513 , false ],
6293 [ FileInfo::SPACE_NOT_COMPUTED , 1024 , true ],
63- [ FileInfo::SPACE_UNKNOWN , 1024 , true ],
94+ [ FileInfo::SPACE_UNKNOWN , 1024 , true ],
6495 [ FileInfo::SPACE_UNLIMITED , 1024 , true ]
6596 ];
6697 }
0 commit comments