@@ -72,13 +72,15 @@ private function getAccessMock() {
7272 ->method ('getConnection ' )
7373 ->will ($ this ->returnValue ($ connector ));
7474
75+ $ access ->userManager = $ this ->createMock (Manager::class);
76+
7577 return $ access ;
7678 }
7779
7880 private function getPluginManagerMock () {
7981 return $ this ->getMockBuilder ('\OCA\User_LDAP\GroupPluginManager ' )->getMock ();
8082 }
81-
83+
8284 /**
8385 * @param Access|\PHPUnit_Framework_MockObject_MockObject $access
8486 */
@@ -119,12 +121,21 @@ public function testCountEmptySearchString() {
119121 }
120122 return [];
121123 });
122-
124+ $ access ->expects ($ this ->any ())
125+ ->method ('combineFilterWithAnd ' )
126+ ->willReturn ('pseudo=filter ' );
127+ $ access ->expects ($ this ->any ())
128+ ->method ('fetchListOfUsers ' )
129+ ->will ($ this ->returnValue ([])); // return val does not matter here
123130 // for primary groups
124131 $ access ->expects ($ this ->once ())
125132 ->method ('countUsers ' )
126133 ->will ($ this ->returnValue (2 ));
127134
135+ $ access ->userManager ->expects ($ this ->any ())
136+ ->method ('getAttributes ' )
137+ ->willReturn (['displayName ' , 'mail ' ]);
138+
128139 $ groupBackend = new GroupLDAP ($ access , $ pluginManager );
129140 $ users = $ groupBackend ->countUsersInGroup ('group ' );
130141
@@ -164,6 +175,13 @@ public function testCountWithSearchString() {
164175 ->will ($ this ->returnCallback (function () {
165176 return 'foobar ' . \OC ::$ server ->getSecureRandom ()->generate (7 );
166177 }));
178+ $ access ->expects ($ this ->any ())
179+ ->method ('combineFilterWithAnd ' )
180+ ->willReturn ('pseudo=filter ' );
181+
182+ $ access ->userManager ->expects ($ this ->any ())
183+ ->method ('getAttributes ' )
184+ ->willReturn (['displayName ' , 'mail ' ]);
167185
168186 $ groupBackend = new GroupLDAP ($ access ,$ pluginManager );
169187 $ users = $ groupBackend ->countUsersInGroup ('group ' , '3 ' );
@@ -193,7 +211,7 @@ public function testCountUsersWithPlugin() {
193211 $ ldap = new GroupLDAP ($ access , $ pluginManager );
194212
195213 $ this ->assertEquals ($ ldap ->countUsersInGroup ('gid ' , 'search ' ),42 );
196- }
214+ }
197215
198216 public function testGidNumber2NameSuccess () {
199217 $ access = $ this ->getAccessMock ();
@@ -533,7 +551,13 @@ public function testUsersInGroupPrimaryMembersOnly() {
533551 $ access ->expects ($ this ->exactly (2 ))
534552 ->method ('nextcloudUserNames ' )
535553 ->willReturnOnConsecutiveCalls (['lisa ' , 'bart ' , 'kira ' , 'brad ' ], ['walle ' , 'dino ' , 'xenia ' ]);
536- $ access ->userManager = $ this ->createMock (Manager::class);
554+ $ access ->expects ($ this ->any ())
555+ ->method ('fetchListOfUsers ' )
556+ ->will ($ this ->returnValue ([])); // return val does not matter here
557+
558+ $ access ->userManager ->expects ($ this ->any ())
559+ ->method ('getAttributes ' )
560+ ->willReturn (['displayName ' , 'mail ' ]);
537561
538562 $ groupBackend = new GroupLDAP ($ access , $ pluginManager );
539563 $ users = $ groupBackend ->usersInGroup ('foobar ' );
@@ -568,7 +592,12 @@ public function testUsersInGroupPrimaryAndUnixMembers() {
568592 $ access ->expects ($ this ->once ())
569593 ->method ('nextcloudUserNames ' )
570594 ->will ($ this ->returnValue (array ('lisa ' , 'bart ' , 'kira ' , 'brad ' )));
571- $ access ->userManager = $ this ->createMock (Manager::class);
595+ $ access ->expects ($ this ->any ())
596+ ->method ('fetchListOfUsers ' )
597+ ->will ($ this ->returnValue ([])); // return val does not matter here
598+ $ access ->userManager ->expects ($ this ->any ())
599+ ->method ('getAttributes ' )
600+ ->willReturn (['displayName ' , 'mail ' ]);
572601
573602 $ groupBackend = new GroupLDAP ($ access , $ pluginManager );
574603 $ users = $ groupBackend ->usersInGroup ('foobar ' );
@@ -602,10 +631,19 @@ public function testCountUsersInGroupPrimaryMembersOnly() {
602631 $ access ->expects ($ this ->any ())
603632 ->method ('groupname2dn ' )
604633 ->will ($ this ->returnValue ('cn=foobar,dc=foo,dc=bar ' ));
605-
634+ $ access ->expects ($ this ->any ())
635+ ->method ('fetchListOfUsers ' )
636+ ->will ($ this ->returnValue ([])); // return val does not matter here
606637 $ access ->expects ($ this ->once ())
607638 ->method ('countUsers ' )
608639 ->will ($ this ->returnValue (4 ));
640+ $ access ->expects ($ this ->any ())
641+ ->method ('combineFilterWithAnd ' )
642+ ->willReturn ('pseudo=filter ' );
643+
644+ $ access ->userManager ->expects ($ this ->any ())
645+ ->method ('getAttributes ' )
646+ ->willReturn (['displayName ' , 'mail ' ]);
609647
610648 $ groupBackend = new GroupLDAP ($ access , $ pluginManager );
611649 $ users = $ groupBackend ->countUsersInGroup ('foobar ' );
@@ -770,7 +808,7 @@ public function testCreateGroupWithPlugin() {
770808 $ this ->assertEquals ($ ldap ->createGroup ('gid ' ),true );
771809 }
772810
773-
811+
774812 public function testCreateGroupFailing () {
775813 $ this ->expectException (\Exception::class);
776814
@@ -825,7 +863,7 @@ public function testDeleteGroupWithPlugin() {
825863 $ this ->assertEquals ($ ldap ->deleteGroup ('gid ' ),'result ' );
826864 }
827865
828-
866+
829867 public function testDeleteGroupFailing () {
830868 $ this ->expectException (\Exception::class);
831869
@@ -871,7 +909,7 @@ public function testAddToGroupWithPlugin() {
871909 $ this ->assertEquals ($ ldap ->addToGroup ('uid ' , 'gid ' ),'result ' );
872910 }
873911
874-
912+
875913 public function testAddToGroupFailing () {
876914 $ this ->expectException (\Exception::class);
877915
@@ -917,7 +955,7 @@ public function testRemoveFromGroupWithPlugin() {
917955 $ this ->assertEquals ($ ldap ->removeFromGroup ('uid ' , 'gid ' ),'result ' );
918956 }
919957
920-
958+
921959 public function testRemoveFromGroupFailing () {
922960 $ this ->expectException (\Exception::class);
923961
@@ -963,7 +1001,7 @@ public function testGetGroupDetailsWithPlugin() {
9631001 $ this ->assertEquals ($ ldap ->getGroupDetails ('gid ' ),'result ' );
9641002 }
9651003
966-
1004+
9671005 public function testGetGroupDetailsFailing () {
9681006 $ this ->expectException (\Exception::class);
9691007
0 commit comments