@@ -612,15 +612,18 @@ public function testVerifyPasswordHookFails() {
612612 self ::invokePrivate ($ this ->manager , 'verifyPassword ' , ['password ' ]);
613613 }
614614
615- public function createShare ($ id , $ type , $ path , $ sharedWith , $ sharedBy , $ shareOwner ,
615+ public function createShare ($ id , $ type , $ node , $ sharedWith , $ sharedBy , $ shareOwner ,
616616 $ permissions , $ expireDate = null , $ password = null , $ attributes = null ) {
617617 $ share = $ this ->createMock (IShare::class);
618618
619619 $ share ->method ('getShareType ' )->willReturn ($ type );
620620 $ share ->method ('getSharedWith ' )->willReturn ($ sharedWith );
621621 $ share ->method ('getSharedBy ' )->willReturn ($ sharedBy );
622622 $ share ->method ('getShareOwner ' )->willReturn ($ shareOwner );
623- $ share ->method ('getNode ' )->willReturn ($ path );
623+ $ share ->method ('getNode ' )->willReturn ($ node );
624+ if ($ node && $ node ->getId ()) {
625+ $ share ->method ('getNodeId ' )->willReturn ($ node ->getId ());
626+ }
624627 $ share ->method ('getPermissions ' )->willReturn ($ permissions );
625628 $ share ->method ('getAttributes ' )->willReturn ($ attributes );
626629 $ share ->method ('getExpirationDate ' )->willReturn ($ expireDate );
@@ -645,8 +648,10 @@ public function dataGeneralChecks() {
645648 ->willReturn (false );
646649 $ file ->method ('getStorage ' )
647650 ->willReturn ($ storage );
651+ $ file ->method ('getId ' )->willReturn (108 );
648652 $ node ->method ('getStorage ' )
649653 ->willReturn ($ storage );
654+ $ node ->method ('getId ' )->willReturn (108 );
650655
651656 $ data = [
652657 [$ this ->createShare (null , IShare::TYPE_USER , $ file , null , $ user0 , $ user0 , 31 , null , null ), 'SharedWith is not a valid user ' , true ],
@@ -676,6 +681,7 @@ public function dataGeneralChecks() {
676681 ];
677682
678683 $ nonShareAble = $ this ->createMock (Folder::class);
684+ $ nonShareAble ->method ('getId ' )->willReturn (108 );
679685 $ nonShareAble ->method ('isShareable ' )->willReturn (false );
680686 $ nonShareAble ->method ('getPath ' )->willReturn ('path ' );
681687 $ nonShareAble ->method ('getName ' )->willReturn ('name ' );
@@ -711,16 +717,22 @@ public function dataGeneralChecks() {
711717 $ data [] = [$ this ->createShare (null , IShare::TYPE_GROUP , $ limitedPermssions , $ group0 , $ user0 , $ user0 , 17 , null , null ), 'Cannot increase permissions of path ' , true ];
712718 $ data [] = [$ this ->createShare (null , IShare::TYPE_LINK , $ limitedPermssions , null , $ user0 , $ user0 , 3 , null , null ), 'Cannot increase permissions of path ' , true ];
713719
720+ $ nonMovableStorage = $ this ->createMock (Storage \IStorage::class);
721+ $ nonMovableStorage ->method ('instanceOfStorage ' )
722+ ->with ('\OCA\Files_Sharing\External\Storage ' )
723+ ->willReturn (false );
724+ $ nonMovableStorage ->method ('getPermissions ' )->willReturn (\OCP \Constants::PERMISSION_ALL );
714725 $ nonMoveableMountPermssions = $ this ->createMock (Folder::class);
715726 $ nonMoveableMountPermssions ->method ('isShareable ' )->willReturn (true );
716727 $ nonMoveableMountPermssions ->method ('getPermissions ' )->willReturn (\OCP \Constants::PERMISSION_READ );
717728 $ nonMoveableMountPermssions ->method ('getId ' )->willReturn (108 );
718729 $ nonMoveableMountPermssions ->method ('getPath ' )->willReturn ('path ' );
719730 $ nonMoveableMountPermssions ->method ('getName ' )->willReturn ('name ' );
731+ $ nonMoveableMountPermssions ->method ('getInternalPath ' )->willReturn ('' );
720732 $ nonMoveableMountPermssions ->method ('getOwner ' )
721733 ->willReturn ($ owner );
722734 $ nonMoveableMountPermssions ->method ('getStorage ' )
723- ->willReturn ($ storage );
735+ ->willReturn ($ nonMovableStorage );
724736
725737 $ data [] = [$ this ->createShare (null , IShare::TYPE_USER , $ nonMoveableMountPermssions , $ user2 , $ user0 , $ user0 , 11 , null , null ), 'Cannot increase permissions of path ' , false ];
726738 $ data [] = [$ this ->createShare (null , IShare::TYPE_GROUP , $ nonMoveableMountPermssions , $ group0 , $ user0 , $ user0 , 11 , null , null ), 'Cannot increase permissions of path ' , false ];
0 commit comments