@@ -615,15 +615,18 @@ public function testVerifyPasswordHookFails() {
615615 self ::invokePrivate ($ this ->manager , 'verifyPassword ' , ['password ' ]);
616616 }
617617
618- public function createShare ($ id , $ type , $ path , $ sharedWith , $ sharedBy , $ shareOwner ,
618+ public function createShare ($ id , $ type , $ node , $ sharedWith , $ sharedBy , $ shareOwner ,
619619 $ permissions , $ expireDate = null , $ password = null , $ attributes = null ) {
620620 $ share = $ this ->createMock (IShare::class);
621621
622622 $ share ->method ('getShareType ' )->willReturn ($ type );
623623 $ share ->method ('getSharedWith ' )->willReturn ($ sharedWith );
624624 $ share ->method ('getSharedBy ' )->willReturn ($ sharedBy );
625625 $ share ->method ('getShareOwner ' )->willReturn ($ shareOwner );
626- $ share ->method ('getNode ' )->willReturn ($ path );
626+ $ share ->method ('getNode ' )->willReturn ($ node );
627+ if ($ node && $ node ->getId ()) {
628+ $ share ->method ('getNodeId ' )->willReturn ($ node ->getId ());
629+ }
627630 $ share ->method ('getPermissions ' )->willReturn ($ permissions );
628631 $ share ->method ('getAttributes ' )->willReturn ($ attributes );
629632 $ share ->method ('getExpirationDate ' )->willReturn ($ expireDate );
@@ -648,8 +651,10 @@ public function dataGeneralChecks() {
648651 ->willReturn (false );
649652 $ file ->method ('getStorage ' )
650653 ->willReturn ($ storage );
654+ $ file ->method ('getId ' )->willReturn (108 );
651655 $ node ->method ('getStorage ' )
652656 ->willReturn ($ storage );
657+ $ node ->method ('getId ' )->willReturn (108 );
653658
654659 $ data = [
655660 [$ this ->createShare (null , IShare::TYPE_USER , $ file , null , $ user0 , $ user0 , 31 , null , null ), 'SharedWith is not a valid user ' , true ],
@@ -679,6 +684,7 @@ public function dataGeneralChecks() {
679684 ];
680685
681686 $ nonShareAble = $ this ->createMock (Folder::class);
687+ $ nonShareAble ->method ('getId ' )->willReturn (108 );
682688 $ nonShareAble ->method ('isShareable ' )->willReturn (false );
683689 $ nonShareAble ->method ('getPath ' )->willReturn ('path ' );
684690 $ nonShareAble ->method ('getName ' )->willReturn ('name ' );
@@ -714,16 +720,22 @@ public function dataGeneralChecks() {
714720 $ data [] = [$ this ->createShare (null , IShare::TYPE_GROUP , $ limitedPermssions , $ group0 , $ user0 , $ user0 , 17 , null , null ), 'Cannot increase permissions of path ' , true ];
715721 $ data [] = [$ this ->createShare (null , IShare::TYPE_LINK , $ limitedPermssions , null , $ user0 , $ user0 , 3 , null , null ), 'Cannot increase permissions of path ' , true ];
716722
723+ $ nonMovableStorage = $ this ->createMock (Storage \IStorage::class);
724+ $ nonMovableStorage ->method ('instanceOfStorage ' )
725+ ->with ('\OCA\Files_Sharing\External\Storage ' )
726+ ->willReturn (false );
727+ $ nonMovableStorage ->method ('getPermissions ' )->willReturn (\OCP \Constants::PERMISSION_ALL );
717728 $ nonMoveableMountPermssions = $ this ->createMock (Folder::class);
718729 $ nonMoveableMountPermssions ->method ('isShareable ' )->willReturn (true );
719730 $ nonMoveableMountPermssions ->method ('getPermissions ' )->willReturn (\OCP \Constants::PERMISSION_READ );
720731 $ nonMoveableMountPermssions ->method ('getId ' )->willReturn (108 );
721732 $ nonMoveableMountPermssions ->method ('getPath ' )->willReturn ('path ' );
722733 $ nonMoveableMountPermssions ->method ('getName ' )->willReturn ('name ' );
734+ $ nonMoveableMountPermssions ->method ('getInternalPath ' )->willReturn ('' );
723735 $ nonMoveableMountPermssions ->method ('getOwner ' )
724736 ->willReturn ($ owner );
725737 $ nonMoveableMountPermssions ->method ('getStorage ' )
726- ->willReturn ($ storage );
738+ ->willReturn ($ nonMovableStorage );
727739
728740 $ data [] = [$ this ->createShare (null , IShare::TYPE_USER , $ nonMoveableMountPermssions , $ user2 , $ user0 , $ user0 , 11 , null , null ), 'Cannot increase permissions of path ' , false ];
729741 $ data [] = [$ this ->createShare (null , IShare::TYPE_GROUP , $ nonMoveableMountPermssions , $ group0 , $ user0 , $ user0 , 11 , null , null ), 'Cannot increase permissions of path ' , false ];
@@ -797,10 +809,9 @@ public function testGeneralChecks($share, $exceptionMessage, $exception) {
797809 ->method ('getId ' )
798810 ->willReturn (42 );
799811 // Id 108 is used in the data to refer to the node of the share.
800- $ userFolder ->expects ($ this ->any ())
801- ->method ('getFirstNodeById ' )
812+ $ userFolder ->method ('getById ' )
802813 ->with (108 )
803- ->willReturn ($ share ->getNode ());
814+ ->willReturn ([ $ share ->getNode ()] );
804815 $ userFolder ->expects ($ this ->any ())
805816 ->method ('getRelativePath ' )
806817 ->willReturnArgument (0 );
0 commit comments