11<?php
22
33use PHPUnit \Framework \TestCase ;
4- use PHPUnit \Framework \Attributes \DataProvider ;
5- use UnityWebPortal \lib \UnityGroup ;
64use UnityWebPortal \lib \UnityOrg ;
75use UnityWebPortal \lib \UnitySQL ;
86
97class QualifyUserTest extends TestCase
108{
11- public static function provider ()
12- {
13- return [
14- getNonExistentUserAndExpectedUIDGIDNoCustomMapping (),
15- getNonExistentUserAndExpectedUIDGIDWithCustomMapping (),
16- ];
17- }
18-
199 private function assertRequestedPIGroup (bool $ expected )
2010 {
2111 global $ USER , $ SQL ;
@@ -85,12 +75,10 @@ private function approveGroup($uid)
8575 ]);
8676 }
8777
88-
89-
90- #[DataProvider("provider " )]
91- public function testQualifyUserByJoinGoupByPI ($ user_to_qualify_args , $ expected_uid_gid )
78+ public function testQualifyUserByJoinGoupByPI ()
9279 {
9380 global $ USER , $ SSO , $ LDAP , $ SQL , $ MAILER , $ REDIS , $ WEBHOOK ;
81+ $ user_to_qualify_args = getUnqualifiedUser ();
9482 $ pi_user_args = getUserIsPIHasNoMembersNoMemberRequests ();
9583 switchUser (...$ pi_user_args );
9684 $ pi_group = $ USER ->getPIGroup ();
@@ -135,14 +123,6 @@ public function testQualifyUserByJoinGoupByPI($user_to_qualify_args, $expected_u
135123 $ this ->assertTrue ($ USER ->exists ());
136124 $ this ->assertTrue ($ newOrg ->exists ());
137125
138- $ user_entry = $ LDAP ->getUserEntry ($ approve_uid );
139- $ qualified_user_group_entry = $ LDAP ->getGroupEntry ($ approve_uid );
140- $ this ->assertEquals ($ expected_uid_gid , $ user_entry ->getAttribute ("uidnumber " )[0 ]);
141- $ this ->assertEquals (
142- $ expected_uid_gid ,
143- $ qualified_user_group_entry ->getAttribute ("gidnumber " )[0 ],
144- );
145-
146126 // $third_request_failed = false;
147127 // try {
148128 $ this ->requestGroupMembership ($ pi_group ->gid );
@@ -154,9 +134,7 @@ public function testQualifyUserByJoinGoupByPI($user_to_qualify_args, $expected_u
154134 $ this ->assertTrue (!$ pi_group ->requestExists ($ USER ));
155135 } finally {
156136 switchUser (...$ user_to_qualify_args );
157- $ this ->ensureOrgGroupDoesNotExist ();
158- $ this ->ensureUserNotInPIGroup ($ pi_group );
159- $ this ->ensureUserDoesNotExist ();
137+ ensureUserNotInPIGroup ($ pi_group );
160138 }
161139 }
162140
@@ -190,16 +168,15 @@ public function testQualifyMultipleUsersByJoinGoupByPI()
190168 } finally {
191169 foreach ($ users_to_qualify_args as $ user_to_qualify_args ) {
192170 switchUser (...$ user_to_qualify_args );
193- $ this ->ensureUserNotInPIGroup ($ pi_group );
194- $ this ->ensureUserDoesNotExist ();
171+ ensureUserNotInPIGroup ($ pi_group );
195172 }
196173 }
197174 }
198175
199- #[DataProvider("provider " )]
200- public function testQualifyUserByJoinGoupByAdmin ($ user_to_qualify_args , $ expected_uid_gid )
176+ public function testQualifyUserByJoinGoupByAdmin ()
201177 {
202178 global $ USER , $ SSO , $ LDAP , $ SQL , $ MAILER , $ REDIS , $ WEBHOOK ;
179+ $ user_to_qualify_args = getUnqualifiedUser ();
203180 switchUser (...getUserIsPIHasNoMembersNoMemberRequests ());
204181 $ pi_group = $ USER ->getPIGroup ();
205182 $ gid = $ pi_group ->gid ;
@@ -243,14 +220,6 @@ public function testQualifyUserByJoinGoupByAdmin($user_to_qualify_args, $expecte
243220 $ this ->assertTrue ($ USER ->exists ());
244221 $ this ->assertTrue ($ newOrg ->exists ());
245222
246- $ user_entry = $ LDAP ->getUserEntry ($ approve_uid );
247- $ qualified_user_group_entry = $ LDAP ->getGroupEntry ($ approve_uid );
248- $ this ->assertEquals ($ expected_uid_gid , $ user_entry ->getAttribute ("uidnumber " )[0 ]);
249- $ this ->assertEquals (
250- $ expected_uid_gid ,
251- $ qualified_user_group_entry ->getAttribute ("gidnumber " )[0 ],
252- );
253-
254223 // $third_request_failed = false;
255224 // try {
256225 $ this ->requestGroupMembership ($ pi_group ->gid );
@@ -262,16 +231,14 @@ public function testQualifyUserByJoinGoupByAdmin($user_to_qualify_args, $expecte
262231 $ this ->assertTrue (!$ pi_group ->requestExists ($ USER ));
263232 } finally {
264233 switchUser (...$ user_to_qualify_args );
265- $ this ->ensureOrgGroupDoesNotExist ();
266- $ this ->ensureUserNotInPIGroup ($ pi_group );
267- $ this ->ensureUserDoesNotExist ();
234+ ensureUserNotInPIGroup ($ pi_group );
268235 }
269236 }
270237
271- #[DataProvider("provider " )]
272- public function testQualifyUserByCreateGroup ($ user_to_qualify_args , $ expected_uid_gid )
238+ public function testQualifyUserByCreateGroup ()
273239 {
274240 global $ USER , $ SSO , $ LDAP , $ SQL , $ MAILER , $ REDIS , $ WEBHOOK ;
241+ $ user_to_qualify_args = getUnqualifiedUser ();
275242 switchuser (...$ user_to_qualify_args );
276243 $ pi_group = $ USER ->getPIGroup ();
277244 $ this ->assertTrue (!$ USER ->exists ());
@@ -309,14 +276,6 @@ public function testQualifyUserByCreateGroup($user_to_qualify_args, $expected_ui
309276 $ this ->assertTrue ($ USER ->exists ());
310277 $ this ->assertTrue ($ newOrg ->exists ());
311278
312- $ user_entry = $ LDAP ->getUserEntry ($ approve_uid );
313- $ qualified_user_group_entry = $ LDAP ->getGroupEntry ($ approve_uid );
314- $ this ->assertEquals ($ expected_uid_gid , $ user_entry ->getAttribute ("uidnumber " )[0 ]);
315- $ this ->assertEquals (
316- $ expected_uid_gid ,
317- $ qualified_user_group_entry ->getAttribute ("gidnumber " )[0 ],
318- );
319-
320279 // $third_request_failed = false;
321280 // try {
322281 $ this ->requestGroupCreation ();
@@ -327,9 +286,7 @@ public function testQualifyUserByCreateGroup($user_to_qualify_args, $expected_ui
327286 $ this ->assertRequestedPIGroup (false );
328287 } finally {
329288 switchUser (...$ user_to_qualify_args );
330- $ this ->ensureOrgGroupDoesNotExist ();
331- $ this ->ensurePIGroupDoesNotExist ();
332- $ this ->ensureUserDoesNotExist ();
289+ ensurePIGroupDoesNotExist ();
333290 }
334291 }
335292}
0 commit comments