2525use OCP \Files \Mount \IMountPoint ;
2626use OCP \Files \Mount \IShareOwnerlessMount ;
2727use OCP \Files \Node ;
28+ use OCP \Files \NotFoundException ;
2829use OCP \Files \Storage \IStorage ;
2930use OCP \HintException ;
3031use OCP \IConfig ;
@@ -667,6 +668,24 @@ public function testGetShareById(): void {
667668 }
668669
669670
671+ public function testGetShareByIdNodeAccessible (): void {
672+ $ share = $ this ->createMock (IShare::class);
673+ $ share
674+ ->expects ($ this ->once ())
675+ ->method ('getNode ' )
676+ ->willThrowException (new NotFoundException ());
677+
678+ $ this ->defaultProvider
679+ ->expects ($ this ->once ())
680+ ->method ('getShareById ' )
681+ ->with (42 )
682+ ->willReturn ($ share );
683+
684+ $ this ->expectException (ShareNotFound::class);
685+ $ this ->manager ->getShareById ('default:42 ' );
686+ }
687+
688+
670689 public function testGetExpiredShareById (): void {
671690 $ this ->expectException (\OCP \Share \Exceptions \ShareNotFound::class);
672691
@@ -2875,10 +2894,11 @@ public function testCreateShareOfIncomingFederatedShare(): void {
28752894 }
28762895
28772896 public function testGetSharesBy (): void {
2878- $ share = $ this ->manager ->newShare ();
2879-
28802897 $ node = $ this ->createMock (Folder::class);
28812898
2899+ $ share = $ this ->manager ->newShare ();
2900+ $ share ->setNode ($ node );
2901+
28822902 $ this ->defaultProvider ->expects ($ this ->once ())
28832903 ->method ('getSharesBy ' )
28842904 ->with (
@@ -2930,6 +2950,8 @@ public function testGetSharesByOwnerless(): void {
29302950 * deleted (as they are evaluated). but share 8 should still be there.
29312951 */
29322952 public function testGetSharesByExpiredLinkShares (): void {
2953+ $ node = $ this ->createMock (File::class);
2954+
29332955 $ manager = $ this ->createManagerMock ()
29342956 ->setMethods (['deleteShare ' ])
29352957 ->getMock ();
@@ -2943,6 +2965,7 @@ public function testGetSharesByExpiredLinkShares(): void {
29432965 for ($ i = 0 ; $ i < 8 ; $ i ++) {
29442966 $ share = $ this ->manager ->newShare ();
29452967 $ share ->setId ($ i );
2968+ $ share ->setNode ($ node );
29462969 $ shares [] = $ share ;
29472970 }
29482971
@@ -2963,8 +2986,6 @@ public function testGetSharesByExpiredLinkShares(): void {
29632986 $ shares2 [] = clone $ shares [$ i ];
29642987 }
29652988
2966- $ node = $ this ->createMock (File::class);
2967-
29682989 /*
29692990 * Simulate the getSharesBy call.
29702991 */
@@ -3126,8 +3147,10 @@ public function testGetShareByTokenHideDisabledUser(): void {
31263147 $ date = new \DateTime ();
31273148 $ date ->setTime (0 , 0 , 0 );
31283149 $ date ->add (new \DateInterval ('P2D ' ));
3150+ $ node = $ this ->createMock (File::class);
31293151 $ share = $ this ->manager ->newShare ();
31303152 $ share ->setExpirationDate ($ date );
3153+ $ share ->setNode ($ node );
31313154 $ share ->setShareOwner ('owner ' );
31323155 $ share ->setSharedBy ('sharedBy ' );
31333156
@@ -3205,8 +3228,10 @@ public function testGetShareByTokenNotExpired(): void {
32053228 $ date = new \DateTime ();
32063229 $ date ->setTime (0 , 0 , 0 );
32073230 $ date ->add (new \DateInterval ('P2D ' ));
3231+ $ node = $ this ->createMock (Folder::class);
32083232 $ share = $ this ->manager ->newShare ();
32093233 $ share ->setExpirationDate ($ date );
3234+ $ share ->setNode ($ node );
32103235
32113236 $ this ->defaultProvider ->expects ($ this ->once ())
32123237 ->method ('getShareByToken ' )
0 commit comments