@@ -112,11 +112,12 @@ private function ensureUserDoesNotExist()
112
112
}
113
113
$ all_users_group = $ LDAP ->getUserGroup ();
114
114
$ all_member_uids = $ all_users_group ->getAttribute ("memberuid " );
115
- $ new_uids = array_diff ($ all_member_uids , [$ USER ->uid ]);
116
115
if (in_array ($ USER ->uid , $ all_member_uids )) {
117
116
$ all_users_group ->setAttribute (
118
117
"memberuid " ,
119
- array_diff ($ all_member_uids , [$ USER ->uid ])
118
+ // array_diff will break the contiguity of the array indexes
119
+ // ldap_mod_replace requires contiguity, array_values restores contiguity
120
+ array_values (array_diff ($ all_member_uids , [$ USER ->uid ]))
120
121
);
121
122
$ all_users_group ->write ();
122
123
assert (!in_array ($ USER ->uid , $ all_users_group ->getAttribute ("memberuid " )));
@@ -221,6 +222,41 @@ public function testCreateUserByJoinGoupByPI()
221
222
}
222
223
}
223
224
225
+ public function testCreateMultipleUsersByJoinGoupByPI ()
226
+ {
227
+ global $ USER , $ SSO , $ LDAP , $ SQL , $ MAILER , $ REDIS , $ WEBHOOK ;
228
+ $ pi_user_args = getUserIsPIHasNoMembersNoMemberRequests ();
229
+ switchUser (...$ pi_user_args );
230
+ $ pi_group = $ USER ->getPIGroup ();
231
+ $ gid = $ pi_group ->gid ;
232
+ $ this ->assertTrue ($ pi_group ->exists ());
233
+ $ users_to_create_args = getNonexistentUsersWithExistentOrg ();
234
+ try {
235
+ foreach ($ users_to_create_args as $ user_to_create_args ) {
236
+ switchUser (...$ user_to_create_args );
237
+ $ this ->assertTrue (!$ USER ->exists ());
238
+ $ this ->assertTrue (!$ pi_group ->userExists ($ USER ));
239
+ $ this ->assertRequestedMembership (false , $ gid );
240
+ $ this ->requestGroupMembership ($ pi_group ->gid );
241
+ $ this ->assertRequestedMembership (true , $ gid );
242
+ $ approve_uid = $ USER ->uid ;
243
+ switchUser (...$ pi_user_args );
244
+ // $this->assertTrue(!$pi_group->userExists($USER));
245
+ $ this ->approveUserByPI ($ approve_uid );
246
+ switchUser (...$ user_to_create_args );
247
+ $ this ->assertTrue (!$ pi_group ->requestExists ($ USER ));
248
+ $ this ->assertRequestedMembership (false , $ gid );
249
+ $ this ->assertTrue ($ pi_group ->userExists ($ USER ));
250
+ $ this ->assertTrue ($ USER ->exists ());
251
+ }
252
+ } finally {
253
+ foreach ($ users_to_create_args as $ user_to_create_args ) {
254
+ switchUser (...$ user_to_create_args );
255
+ $ this ->ensureUserNotInPIGroup ($ pi_group );
256
+ $ this ->ensureUserDoesNotExist ();
257
+ }
258
+ }
259
+ }
224
260
225
261
public function testCreateUserByJoinGoupByAdmin ()
226
262
{
0 commit comments