2020use OCA \Libresign \Helper \ValidateHelper ;
2121use OCA \Libresign \Service \IdentifyMethodService ;
2222use OCA \Libresign \Service \SignerElementsService ;
23- use OCP \Files \Config \IUserMountCache ;
2423use OCP \Files \IMimeTypeDetector ;
2524use OCP \Files \IRootFolder ;
2625use OCP \IAppConfig ;
@@ -48,7 +47,6 @@ final class ValidateHelperTest extends \OCA\Libresign\Tests\Unit\TestCase {
4847 private IGroupManager &MockObject $ groupManager ;
4948 private IUserManager &MockObject $ userManager ;
5049 private IRootFolder &MockObject $ root ;
51- private IUserMountCache &MockObject $ userMountCache ;
5250
5351 public function setUp (): void {
5452 $ this ->l10n = $ this ->createMock (IL10N ::class);
@@ -70,7 +68,6 @@ public function setUp(): void {
7068 $ this ->groupManager = $ this ->createMock (IGroupManager::class);
7169 $ this ->userManager = $ this ->createMock (IUserManager::class);
7270 $ this ->root = $ this ->createMock (IRootFolder::class);
73- $ this ->userMountCache = $ this ->createMock (IUserMountCache::class);
7471 }
7572
7673 private function getValidateHelper (): ValidateHelper {
@@ -91,7 +88,6 @@ private function getValidateHelper(): ValidateHelper {
9188 $ this ->groupManager ,
9289 $ this ->userManager ,
9390 $ this ->root ,
94- $ this ->userMountCache ,
9591 );
9692 return $ validateHelper ;
9793 }
@@ -117,12 +113,12 @@ public function testValidateFileWhenFileIdDoesNotExist():void {
117113 $ this ->root ->method ('getById ' )->will ($ this ->returnCallback (function ():void {
118114 throw new \Exception ('not found ' );
119115 }));
120- $ this ->userMountCache
121- ->method ('getMountsForFileId ' )
122- ->willreturn ([]);
116+ $ user = $ this ->createMock (\OCP \IUser::class);
117+ $ user ->method ('getUID ' )->willReturn ('john.doe ' );
123118 $ this ->getValidateHelper ()->validateFile ([
124119 'file ' => ['fileId ' => 123 ],
125- 'name ' => 'test '
120+ 'name ' => 'test ' ,
121+ 'userManager ' => $ user ,
126122 ]);
127123 }
128124
@@ -137,12 +133,13 @@ public function testValidateNewFileUsingFileIdWithSuccess():void {
137133 $ this ->root
138134 ->method ('getById ' )
139135 ->willReturn ([$ file ]);
140- $ this -> userMountCache
141- -> method ( ' getMountsForFileId ' )
142- -> willreturn ([] );
136+
137+ $ user = $ this -> createMock (\ OCP \IUser::class);
138+ $ user -> method ( ' getUID ' )-> willReturn ( ' john.doe ' );
143139 $ actual = $ this ->getValidateHelper ()->validateNewFile ([
144140 'file ' => ['fileId ' => 123 ],
145- 'name ' => 'test '
141+ 'name ' => 'test ' ,
142+ 'userManager ' => $ user ,
146143 ]);
147144 $ this ->assertNull ($ actual );
148145 }
@@ -186,10 +183,7 @@ public function testValidateMimeTypeAcceptedByNodeId(string $mimetype, int $dest
186183 if ($ exception ) {
187184 $ this ->expectExceptionMessage ($ exception );
188185 }
189- $ this ->userMountCache
190- ->method ('getMountsForFileId ' )
191- ->willreturn ([]);
192- $ actual = $ this ->getValidateHelper ()->validateMimeTypeAcceptedByNodeId (171 , $ destination );
186+ $ actual = $ this ->getValidateHelper ()->validateMimeTypeAcceptedByNodeId (171 , '' , $ destination );
193187 if (!$ exception ) {
194188 $ this ->assertNull ($ actual );
195189 }
@@ -391,9 +385,6 @@ public function testValidateIfNodeIdExistsWhenGetFileThrowException():void {
391385 ->will ($ this ->returnCallback (function ():void {
392386 throw new \Exception ('not found ' );
393387 }));
394- $ this ->userMountCache
395- ->method ('getMountsForFileId ' )
396- ->willreturn ([]);
397388 $ this ->getValidateHelper ()->validateIfNodeIdExists (171 );
398389 }
399390
@@ -402,9 +393,6 @@ public function testValidateIfNodeIdExistsWithInvalidFile():void {
402393 $ this ->root
403394 ->method ('getById ' )
404395 ->willReturn ([0 => null ]);
405- $ this ->userMountCache
406- ->method ('getMountsForFileId ' )
407- ->willreturn ([]);
408396 $ this ->getValidateHelper ()->validateIfNodeIdExists (171 );
409397 }
410398
@@ -415,9 +403,6 @@ public function testValidateIfNodeIdExistsWithSuccess():void {
415403 $ this ->root
416404 ->method ('getById ' )
417405 ->willReturn (['file ' ]);
418- $ this ->userMountCache
419- ->method ('getMountsForFileId ' )
420- ->willreturn ([]);
421406 $ actual = $ this ->getValidateHelper ()->validateIfNodeIdExists (171 );
422407 $ this ->assertNull ($ actual );
423408 }
0 commit comments