@@ -39,6 +39,7 @@ class MailPluginTest extends TestCase {
3939 protected IGroupManager &MockObject $ groupManager ;
4040 protected KnownUserService &MockObject $ knownUserService ;
4141 protected IUserSession &MockObject $ userSession ;
42+ protected IUserManager &MockObject $ userManager ;
4243
4344 #[\Override]
4445 protected function setUp (): void {
@@ -49,6 +50,17 @@ protected function setUp(): void {
4950 $ this ->groupManager = $ this ->createMock (IGroupManager::class);
5051 $ this ->knownUserService = $ this ->createMock (KnownUserService::class);
5152 $ this ->userSession = $ this ->createMock (IUserSession::class);
53+ $ this ->userManager = $ this ->createMock (IUserManager::class);
54+ $ this ->userManager
55+ ->method ('get ' )
56+ ->willReturnCallback (function (string $ uid ): IUser {
57+ $ user = $ this ->createMock (IUser::class);
58+ $ user
59+ ->method ('getUID ' )
60+ ->willReturn ($ uid );
61+
62+ return $ user ;
63+ });
5264 $ this ->cloudIdManager = new CloudIdManager (
5365 $ this ->createMock (ICacheFactory::class),
5466 $ this ->createMock (IEventDispatcher::class),
@@ -69,6 +81,7 @@ public function instantiatePlugin(int $shareType) {
6981 $ this ->knownUserService ,
7082 $ this ->userSession ,
7183 $ this ->getEmailValidatorWithStrictEmailCheck (),
84+ $ this ->userManager ,
7285 [],
7386 $ shareType ,
7487 );
@@ -727,7 +740,7 @@ public static function dataSearchUser(): array {
727740 ]
728741 ],
729742 false ,
730- ['users ' => [], 'exact ' => ['users ' => [['uuid ' => 'uid1 ' , 'name ' => 'User ' , 'label ' => 'User (test@example.com) ' ,'value ' => ['shareType ' => IShare::TYPE_USER , 'shareWith ' => 'test ' ], 'shareWithDisplayNameUnique ' => 'test@example.com ' ]]]],
743+ ['users ' => [], 'exact ' => ['users ' => [['uuid ' => 'uid1 ' , 'name ' => 'User ' , 'label ' => 'User (test@example.com) ' , 'value ' => ['shareType ' => IShare::TYPE_USER , 'shareWith ' => 'test ' ], 'shareWithDisplayNameUnique ' => 'test@example.com ' ]]]],
731744 true ,
732745 false ,
733746 ],
@@ -872,12 +885,6 @@ function ($appName, $key, $default) {
872885 return $ userToGroupMapping [$ user ->getUID ()];
873886 });
874887
875- $ this ->groupManager ->expects ($ this ->any ())
876- ->method ('isInGroup ' )
877- ->willReturnCallback (function ($ userId , $ group ) use ($ userToGroupMapping ) {
878- return in_array ($ group , $ userToGroupMapping [$ userId ]);
879- });
880-
881888 $ moreResults = $ this ->plugin ->search ($ searchTerm , 2 , 0 , $ this ->searchResult );
882889 $ result = $ this ->searchResult ->asArray ();
883890
@@ -942,7 +949,7 @@ public static function dataSearchEmailGroupsOnly(): array {
942949 'UID ' => 'User ' ,
943950 ]
944951 ],
945- ['emails ' => [], 'exact ' => ['emails ' => [['label ' => 'test@example.com ' , 'uuid ' => 'test@example.com ' , 'value ' => ['shareType ' => IShare::TYPE_EMAIL ,'shareWith ' => 'test@example.com ' ]]]]],
952+ ['emails ' => [], 'exact ' => ['emails ' => [['label ' => 'test@example.com ' , 'uuid ' => 'test@example.com ' , 'value ' => ['shareType ' => IShare::TYPE_EMAIL , 'shareWith ' => 'test@example.com ' ]]]]],
946953 false ,
947954 false ,
948955 [
@@ -996,12 +1003,6 @@ function ($appName, $key, $default) {
9961003 return $ userToGroupMapping [$ user ->getUID ()];
9971004 });
9981005
999- $ this ->groupManager ->expects ($ this ->any ())
1000- ->method ('isInGroup ' )
1001- ->willReturnCallback (function ($ userId , $ group ) use ($ userToGroupMapping ) {
1002- return in_array ($ group , $ userToGroupMapping [$ userId ]);
1003- });
1004-
10051006 $ moreResults = $ this ->plugin ->search ($ searchTerm , 2 , 0 , $ this ->searchResult );
10061007 $ result = $ this ->searchResult ->asArray ();
10071008
@@ -1024,7 +1025,7 @@ public static function dataSearchUserGroupsOnly(): array {
10241025 'UID ' => 'User ' ,
10251026 ]
10261027 ],
1027- ['users ' => [['label ' => 'User (test@example.com) ' , 'uuid ' => 'User ' , 'name ' => 'User ' , 'value ' => ['shareType ' => IShare::TYPE_USER , 'shareWith ' => 'test ' ],'shareWithDisplayNameUnique ' => 'test@example.com ' ,]], 'exact ' => ['users ' => []]],
1028+ ['users ' => [['label ' => 'User (test@example.com) ' , 'uuid ' => 'User ' , 'name ' => 'User ' , 'value ' => ['shareType ' => IShare::TYPE_USER , 'shareWith ' => 'test ' ], 'shareWithDisplayNameUnique ' => 'test@example.com ' ,]], 'exact ' => ['users ' => []]],
10281029 false ,
10291030 false ,
10301031 [
0 commit comments