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 ;
@@ -66,6 +67,7 @@ protected function setUp(): void {
6667 $ this ->groupManager ,
6768 $ this ->knownUserService ,
6869 $ this ->l10nFactory ,
70+ new ShareDisableChecker ($ this ->config , $ this ->userManager , $ this ->groupManager ),
6971 );
7072 }
7173
@@ -87,7 +89,7 @@ public function testGetContactsWithoutFilter(): void {
8789 ],
8890 ],
8991 ]);
90- $ user ->expects ($ this ->exactly (2 ))
92+ $ user ->expects ($ this ->exactly (3 ))
9193 ->method ('getUID ' )
9294 ->willReturn ('user123 ' );
9395
@@ -117,7 +119,7 @@ public function testGetContactsHidesOwnEntry(): void {
117119 ],
118120 ],
119121 ]);
120- $ user ->expects ($ this ->exactly (2 ))
122+ $ user ->expects ($ this ->exactly (3 ))
121123 ->method ('getUID ' )
122124 ->willReturn ('user123 ' );
123125
@@ -149,7 +151,7 @@ public function testGetContactsWithoutBinaryImage(): void {
149151 'PHOTO ' => base64_encode ('photophotophoto ' ),
150152 ],
151153 ]);
152- $ user ->expects ($ this ->exactly (2 ))
154+ $ user ->expects ($ this ->exactly (3 ))
153155 ->method ('getUID ' )
154156 ->willReturn ('user123 ' );
155157
@@ -178,7 +180,7 @@ public function testGetContactsWithoutAvatarURI(): void {
178180 'PHOTO ' => 'VALUE=uri:https://photo ' ,
179181 ],
180182 ]);
181- $ user ->expects ($ this ->exactly (2 ))
183+ $ user ->expects ($ this ->exactly (3 ))
182184 ->method ('getUID ' )
183185 ->willReturn ('user123 ' );
184186
@@ -195,18 +197,18 @@ public static function dataGetContactsWhenUserIsInExcludeGroups(): array {
195197 ['yes ' , '["excludedGroup1"] ' , ['anotherGroup1 ' ], ['user123 ' , 'user12345 ' ]],
196198 ['yes ' , '["excludedGroup1"] ' , ['anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], ['user123 ' , 'user12345 ' ]],
197199 ['yes ' , '["excludedGroup1"] ' , ['excludedGroup1 ' ], []],
198- ['yes ' , '["excludedGroup1"] ' , ['anotherGroup1 ' , 'excludedGroup1 ' ], [' user123 ' , ' user12345 ' ]],
199- ['yes ' , '["excludedGroup1"] ' , ['excludedGroup1 ' , 'anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], [' user123 ' , ' user12345 ' ]],
200+ ['yes ' , '["excludedGroup1"] ' , ['anotherGroup1 ' , 'excludedGroup1 ' ], []],
201+ ['yes ' , '["excludedGroup1"] ' , ['excludedGroup1 ' , 'anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], []],
200202 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , [], ['user123 ' , 'user12345 ' ]],
201203 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' ], ['user123 ' , 'user12345 ' ]],
202204 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], ['user123 ' , 'user12345 ' ]],
203205 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup1 ' ], []],
204206 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup2 ' ], []],
205207 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup3 ' ], []],
206208 ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup1 ' , 'excludedGroup2 ' , 'excludedGroup3 ' ], []],
207- ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' , 'excludedGroup1 ' ], [' user123 ' , ' user12345 ' ]],
208- ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' , 'excludedGroup2 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], [' user123 ' , ' user12345 ' ]],
209- ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup3 ' , 'anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], [' user123 ' , ' user12345 ' ]],
209+ ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' , 'excludedGroup1 ' ], []],
210+ ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['anotherGroup1 ' , 'excludedGroup2 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], []],
211+ ['yes ' , '["excludedGroup1", "excludedGroup2", "excludedGroup3"] ' , ['excludedGroup3 ' , 'anotherGroup1 ' , 'anotherGroup2 ' , 'anotherGroup3 ' ], []],
210212 ['allow ' , '[] ' , [], []],
211213 ['allow ' , '["allowedGroup1"] ' , [], []],
212214 ['allow ' , '["allowedGroup1"] ' , ['anotherGroup1 ' ], []],
@@ -243,11 +245,15 @@ public function testGetContactsWhenUserIsInExcludeGroups(string $excludeGroups,
243245
244246 /** @var IUser|MockObject $currentUser */
245247 $ currentUser = $ this ->createMock (IUser::class);
246- $ currentUser ->expects ($ this ->exactly (2 ))
248+ $ currentUser ->expects ($ this ->exactly (3 ))
247249 ->method ('getUID ' )
248250 ->willReturn ('user001 ' );
249251
250- $ this ->groupManager ->expects ($ this ->once ())
252+ $ this ->userManager ->method ('get ' )
253+ ->with ('user001 ' )
254+ ->willReturn ($ currentUser );
255+
256+ $ this ->groupManager ->expects ($ this ->exactly (2 ))
251257 ->method ('getUserGroupIds ' )
252258 ->with ($ this ->equalTo ($ currentUser ))
253259 ->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 ' ]);
@@ -334,7 +344,7 @@ public function testGetContactsOnlyShareIfInTheSameGroup(): void {
334344
335345 /** @var IUser|MockObject $currentUser */
336346 $ currentUser = $ this ->createMock (IUser::class);
337- $ currentUser ->expects ($ this ->exactly (2 ))
347+ $ currentUser ->expects ($ this ->exactly (3 ))
338348 ->method ('getUID ' )
339349 ->willReturn ('user001 ' );
340350
@@ -407,7 +417,7 @@ public function testGetContactsOnlyEnumerateIfInTheSameGroup(): void {
407417
408418 /** @var IUser|MockObject $currentUser */
409419 $ currentUser = $ this ->createMock (IUser::class);
410- $ currentUser ->expects ($ this ->exactly (2 ))
420+ $ currentUser ->expects ($ this ->exactly (3 ))
411421 ->method ('getUID ' )
412422 ->willReturn ('user001 ' );
413423
@@ -479,7 +489,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookMatch(): void {
479489
480490 /** @var IUser|MockObject $currentUser */
481491 $ currentUser = $ this ->createMock (IUser::class);
482- $ currentUser ->expects ($ this ->exactly (2 ))
492+ $ currentUser ->expects ($ this ->exactly (3 ))
483493 ->method ('getUID ' )
484494 ->willReturn ('user001 ' );
485495
@@ -538,7 +548,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookMatchWithOwnGroupsOnly():
538548
539549 /** @var IUser|MockObject $currentUser */
540550 $ currentUser = $ this ->createMock (IUser::class);
541- $ currentUser ->expects ($ this ->exactly (2 ))
551+ $ currentUser ->expects ($ this ->exactly (3 ))
542552 ->method ('getUID ' )
543553 ->willReturn ('user001 ' );
544554
@@ -617,7 +627,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookOrSameGroup(): void {
617627
618628 /** @var IUser|MockObject $currentUser */
619629 $ currentUser = $ this ->createMock (IUser::class);
620- $ currentUser ->expects ($ this ->exactly (2 ))
630+ $ currentUser ->expects ($ this ->exactly (3 ))
621631 ->method ('getUID ' )
622632 ->willReturn ('user001 ' );
623633
@@ -691,7 +701,7 @@ public function testGetContactsOnlyEnumerateIfPhoneBookOrSameGroupInOwnGroupsOnl
691701
692702 /** @var IUser|MockObject $currentUser */
693703 $ currentUser = $ this ->createMock (IUser::class);
694- $ currentUser ->expects ($ this ->exactly (2 ))
704+ $ currentUser ->expects ($ this ->exactly (3 ))
695705 ->method ('getUID ' )
696706 ->willReturn ('user001 ' );
697707
0 commit comments