1212use OC \Contacts \ContactsMenu \ContactsStore ;
1313use OC \KnownUser \KnownUserService ;
1414use OC \Profile \ProfileManager ;
15+ use OC \Share20 \ShareDisableChecker ;
1516use OCA \UserStatus \Db \UserStatus ;
1617use OCA \UserStatus \Service \StatusService ;
1718use OCP \Contacts \IManager ;
@@ -67,6 +68,7 @@ protected function setUp(): void {
6768 $ this ->groupManager ,
6869 $ this ->knownUserService ,
6970 $ this ->l10nFactory ,
71+ new ShareDisableChecker ($ this ->config , $ this ->userManager , $ this ->groupManager ),
7072 );
7173 }
7274
@@ -88,7 +90,7 @@ public function testGetContactsWithoutFilter(): void {
8890 ],
8991 ],
9092 ]);
91- $ user ->expects ($ this ->exactly (2 ))
93+ $ user ->expects ($ this ->exactly (3 ))
9294 ->method ('getUID ' )
9395 ->willReturn ('user123 ' );
9496
@@ -118,7 +120,7 @@ public function testGetContactsHidesOwnEntry(): void {
118120 ],
119121 ],
120122 ]);
121- $ user ->expects ($ this ->exactly (2 ))
123+ $ user ->expects ($ this ->exactly (3 ))
122124 ->method ('getUID ' )
123125 ->willReturn ('user123 ' );
124126
@@ -150,7 +152,7 @@ public function testGetContactsWithoutBinaryImage(): void {
150152 'PHOTO ' => base64_encode ('photophotophoto ' ),
151153 ],
152154 ]);
153- $ user ->expects ($ this ->exactly (2 ))
155+ $ user ->expects ($ this ->exactly (3 ))
154156 ->method ('getUID ' )
155157 ->willReturn ('user123 ' );
156158
@@ -179,7 +181,7 @@ public function testGetContactsWithoutAvatarURI(): void {
179181 'PHOTO ' => 'VALUE=uri:https://photo ' ,
180182 ],
181183 ]);
182- $ user ->expects ($ this ->exactly (2 ))
184+ $ user ->expects ($ this ->exactly (3 ))
183185 ->method ('getUID ' )
184186 ->willReturn ('user123 ' );
185187
@@ -196,18 +198,18 @@ public static function dataGetContactsWhenUserIsInExcludeGroups(): array {
196198 ['yes ' , '["excludedGroup1"] ' , ['anotherGroup1 ' ], ['user123 ' , 'user12345 ' ]],
197199 ['yes ' , '["excludedGroup1"] ' , ['anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], ['user123 ' , 'user12345 ' ]],
198200 ['yes ' , '["excludedGroup1"] ' , ['excludedGroup1 ' ], []],
199- ['yes ' , '["excludedGroup1"] ' , ['anotherGroup1 ' , 'excludedGroup1 ' ], [' user123 ' , ' user12345 ' ]],
200- ['yes ' , '["excludedGroup1"] ' , ['excludedGroup1 ' , 'anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], [' user123 ' , ' user12345 ' ]],
201+ ['yes ' , '["excludedGroup1"] ' , ['anotherGroup1 ' , 'excludedGroup1 ' ], []],
202+ ['yes ' , '["excludedGroup1"] ' , ['excludedGroup1 ' , 'anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], []],
201203 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , [], ['user123 ' , 'user12345 ' ]],
202204 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' ], ['user123 ' , 'user12345 ' ]],
203205 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], ['user123 ' , 'user12345 ' ]],
204206 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup1 ' ], []],
205207 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup2 ' ], []],
206208 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup3 ' ], []],
207209 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup1 ' , 'excludedGroup2 ' , 'excludedGroup3 ' ], []],
208- ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' , 'excludedGroup1 ' ], [' user123 ' , ' user12345 ' ]],
209- ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' , 'excludedGroup2 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], [' user123 ' , ' user12345 ' ]],
210- ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup3 ' , 'anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], [' user123 ' , ' user12345 ' ]],
210+ ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' , 'excludedGroup1 ' ], []],
211+ ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' , 'excludedGroup2 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], []],
212+ ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup3 ' , 'anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], []],
211213 ['allow ' , '[] ' , [], []],
212214 ['allow ' , '["allowedGroup1"] ' , [], []],
213215 ['allow ' , '["allowedGroup1"] ' , ['anotherGroup1 ' ], []],
@@ -244,11 +246,15 @@ public function testGetContactsWhenUserIsInExcludeGroups(string $excludeGroups,
244246
245247 /** @var IUser|MockObject $currentUser */
246248 $ currentUser = $ this ->createMock (IUser::class);
247- $ currentUser ->expects ($ this ->exactly (2 ))
249+ $ currentUser ->expects ($ this ->exactly (3 ))
248250 ->method ('getUID ' )
249251 ->willReturn ('user001 ' );
250252
251- $ this ->groupManager ->expects ($ this ->once ())
253+ $ this ->userManager ->method ('get ' )
254+ ->with ('user001 ' )
255+ ->willReturn ($ currentUser );
256+
257+ $ this ->groupManager ->expects ($ this ->exactly (2 ))
252258 ->method ('getUserGroupIds ' )
253259 ->with ($ this ->equalTo ($ currentUser ))
254260 ->willReturn ($ currentUserGroupIds );
@@ -291,11 +297,15 @@ public function testGetContactsOnlyShareIfInTheSameGroupWhenUserIsInExcludeGroup
291297
292298 /** @var IUser|MockObject $currentUser */
293299 $ currentUser = $ this ->createMock (IUser::class);
294- $ currentUser ->expects ($ this ->exactly (2 ))
300+ $ currentUser ->expects ($ this ->exactly (3 ))
295301 ->method ('getUID ' )
296302 ->willReturn ('user001 ' );
297303
298- $ this ->groupManager ->expects ($ this ->once ())
304+ $ this ->userManager ->method ('get ' )
305+ ->with ('user001 ' )
306+ ->willReturn ($ currentUser );
307+
308+ $ this ->groupManager ->expects ($ this ->exactly (2 ))
299309 ->method ('getUserGroupIds ' )
300310 ->with ($ this ->equalTo ($ currentUser ))
301311 ->willReturn (['group1 ' , 'group2 ' , 'group3 ' ]);
@@ -335,7 +345,7 @@ public function testGetContactsOnlyShareIfInTheSameGroup(): void {
335345
336346 /** @var IUser|MockObject $currentUser */
337347 $ currentUser = $ this ->createMock (IUser::class);
338- $ currentUser ->expects ($ this ->exactly (2 ))
348+ $ currentUser ->expects ($ this ->exactly (3 ))
339349 ->method ('getUID ' )
340350 ->willReturn ('user001 ' );
341351
@@ -408,7 +418,7 @@ public function testGetContactsOnlyEnumerateIfInTheSameGroup(): void {
408418
409419 /** @var IUser|MockObject $currentUser */
410420 $ currentUser = $ this ->createMock (IUser::class);
411- $ currentUser ->expects ($ this ->exactly (2 ))
421+ $ currentUser ->expects ($ this ->exactly (3 ))
412422 ->method ('getUID ' )
413423 ->willReturn ('user001 ' );
414424
@@ -480,7 +490,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookMatch(): void {
480490
481491 /** @var IUser|MockObject $currentUser */
482492 $ currentUser = $ this ->createMock (IUser::class);
483- $ currentUser ->expects ($ this ->exactly (2 ))
493+ $ currentUser ->expects ($ this ->exactly (3 ))
484494 ->method ('getUID ' )
485495 ->willReturn ('user001 ' );
486496
@@ -539,7 +549,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookMatchWithOwnGroupsOnly():
539549
540550 /** @var IUser|MockObject $currentUser */
541551 $ currentUser = $ this ->createMock (IUser::class);
542- $ currentUser ->expects ($ this ->exactly (2 ))
552+ $ currentUser ->expects ($ this ->exactly (3 ))
543553 ->method ('getUID ' )
544554 ->willReturn ('user001 ' );
545555
@@ -618,7 +628,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookOrSameGroup(): void {
618628
619629 /** @var IUser|MockObject $currentUser */
620630 $ currentUser = $ this ->createMock (IUser::class);
621- $ currentUser ->expects ($ this ->exactly (2 ))
631+ $ currentUser ->expects ($ this ->exactly (3 ))
622632 ->method ('getUID ' )
623633 ->willReturn ('user001 ' );
624634
@@ -692,7 +702,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookOrSameGroupInOwnGroupsOnl
692702
693703 /** @var IUser|MockObject $currentUser */
694704 $ currentUser = $ this ->createMock (IUser::class);
695- $ currentUser ->expects ($ this ->exactly (2 ))
705+ $ currentUser ->expects ($ this ->exactly (3 ))
696706 ->method ('getUID ' )
697707 ->willReturn ('user001 ' );
698708
0 commit comments