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 );
@@ -290,11 +296,15 @@ public function testGetContactsOnlyShareIfInTheSameGroupWhenUserIsInExcludeGroup
290296
291297 /** @var IUser|MockObject $currentUser */
292298 $ currentUser = $ this ->createMock (IUser::class);
293- $ currentUser ->expects ($ this ->exactly (2 ))
299+ $ currentUser ->expects ($ this ->exactly (3 ))
294300 ->method ('getUID ' )
295301 ->willReturn ('user001 ' );
296302
297- $ this ->groupManager ->expects ($ this ->once ())
303+ $ this ->userManager ->method ('get ' )
304+ ->with ('user001 ' )
305+ ->willReturn ($ currentUser );
306+
307+ $ this ->groupManager ->expects ($ this ->exactly (2 ))
298308 ->method ('getUserGroupIds ' )
299309 ->with ($ this ->equalTo ($ currentUser ))
300310 ->willReturn (['group1 ' , 'group2 ' , 'group3 ' ]);
@@ -332,7 +342,7 @@ public function testGetContactsOnlyShareIfInTheSameGroup(): void {
332342
333343 /** @var IUser|MockObject $currentUser */
334344 $ currentUser = $ this ->createMock (IUser::class);
335- $ currentUser ->expects ($ this ->exactly (2 ))
345+ $ currentUser ->expects ($ this ->exactly (3 ))
336346 ->method ('getUID ' )
337347 ->willReturn ('user001 ' );
338348
@@ -405,7 +415,7 @@ public function testGetContactsOnlyEnumerateIfInTheSameGroup(): void {
405415
406416 /** @var IUser|MockObject $currentUser */
407417 $ currentUser = $ this ->createMock (IUser::class);
408- $ currentUser ->expects ($ this ->exactly (2 ))
418+ $ currentUser ->expects ($ this ->exactly (3 ))
409419 ->method ('getUID ' )
410420 ->willReturn ('user001 ' );
411421
@@ -477,7 +487,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookMatch(): void {
477487
478488 /** @var IUser|MockObject $currentUser */
479489 $ currentUser = $ this ->createMock (IUser::class);
480- $ currentUser ->expects ($ this ->exactly (2 ))
490+ $ currentUser ->expects ($ this ->exactly (3 ))
481491 ->method ('getUID ' )
482492 ->willReturn ('user001 ' );
483493
@@ -536,7 +546,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookMatchWithOwnGroupsOnly():
536546
537547 /** @var IUser|MockObject $currentUser */
538548 $ currentUser = $ this ->createMock (IUser::class);
539- $ currentUser ->expects ($ this ->exactly (2 ))
549+ $ currentUser ->expects ($ this ->exactly (3 ))
540550 ->method ('getUID ' )
541551 ->willReturn ('user001 ' );
542552
@@ -615,7 +625,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookOrSameGroup(): void {
615625
616626 /** @var IUser|MockObject $currentUser */
617627 $ currentUser = $ this ->createMock (IUser::class);
618- $ currentUser ->expects ($ this ->exactly (2 ))
628+ $ currentUser ->expects ($ this ->exactly (3 ))
619629 ->method ('getUID ' )
620630 ->willReturn ('user001 ' );
621631
@@ -689,7 +699,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookOrSameGroupInOwnGroupsOnl
689699
690700 /** @var IUser|MockObject $currentUser */
691701 $ currentUser = $ this ->createMock (IUser::class);
692- $ currentUser ->expects ($ this ->exactly (2 ))
702+ $ currentUser ->expects ($ this ->exactly (3 ))
693703 ->method ('getUID ' )
694704 ->willReturn ('user001 ' );
695705
0 commit comments