Skip to content

Commit 81f7835

Browse files
committed
ignore order of list
1 parent 6c7f3c0 commit 81f7835

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

test/functional/PiMemberApproveTest.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ public function testApproveRequest()
3131
$pi = $USER;
3232
$piGroup = $USER->getPIGroup();
3333
$this->assertTrue($piGroup->exists());
34-
$this->assertEquals([$pi->getUID()], $piGroup->getGroupMemberUIDs());
34+
$this->assertTrue(
35+
arraysAreEqualUnOrdered(
36+
[$pi->getUID()],
37+
$piGroup->getGroupMemberUIDs()
38+
)
39+
);
3540
$this->assertEmpty($piGroup->getRequests());
3641
$requestedUser = new UnityUser(self::$requestUid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
3742
try {
@@ -41,7 +46,12 @@ public function testApproveRequest()
4146
$piGroup->approveUser($requestedUser);
4247
$this->assertEmpty($piGroup->getRequests());
4348

44-
$this->assertEquals([$pi->getUID(), self::$requestUid], $piGroup->getGroupMemberUIDs());
49+
$this->assertTrue(
50+
arraysAreEqualUnOrdered(
51+
[$pi->getUID(), self::$requestUid],
52+
$piGroup->getGroupMemberUIDs()
53+
)
54+
);
4555
$this->assertTrue($piGroup->userExists($requestedUser));
4656
} finally {
4757
$piGroup->removeUser($requestedUser);
@@ -56,7 +66,12 @@ public function testApproveNonexistentRequest()
5666
$pi = $USER;
5767
$piGroup = $USER->getPIGroup();
5868
$this->assertTrue($piGroup->exists());
59-
$this->assertEquals([$pi->getUID()], $piGroup->getGroupMemberUIDs());
69+
$this->assertTrue(
70+
arraysAreEqualUnOrdered(
71+
[$pi->getUID()],
72+
$piGroup->getGroupMemberUIDs()
73+
)
74+
);
6075
$this->assertEmpty($piGroup->getRequests());
6176

6277
$notRequestedUser = new UnityUser(self::$noRequestUid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);

test/functional/PiMemberDenyTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ public function testDenyRequest()
2828
$pi = $USER;
2929
$piGroup = $USER->getPIGroup();
3030
$this->assertTrue($piGroup->exists());
31-
$this->assertEquals([$pi->getUID()], $piGroup->getGroupMemberUIDs());
31+
$this->assertTrue(
32+
arraysAreEqualUnOrdered(
33+
[$pi->getUID()],
34+
$piGroup->getGroupMemberUIDs()
35+
)
36+
);
3237
$this->assertEmpty($piGroup->getRequests());
3338
$requestedUser = new UnityUser(self::$requestUid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
3439
try {
@@ -37,7 +42,12 @@ public function testDenyRequest()
3742

3843
$piGroup->denyUser($requestedUser);
3944
$this->assertEmpty($piGroup->getRequests());
40-
$this->assertEquals([$pi->getUID()], $piGroup->getGroupMemberUIDs());
45+
$this->assertTrue(
46+
arraysAreEqualUnOrdered(
47+
[$pi->getUID()],
48+
$piGroup->getGroupMemberUIDs()
49+
)
50+
);
4151
$this->assertFalse($piGroup->userExists($requestedUser));
4252
} finally {
4353
$SQL->removeRequest(self::$requestUid, $piGroup->getPIUID());

test/phpunit-bootstrap.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
mb_convert_encoding("Hello, World!", "UTF-16")
5050
];
5151

52+
function arraysAreEqualUnOrdered(array $a, array $b): bool
53+
{
54+
return (array_diff($a, $b) == [] && array_diff($b, $a) == []);
55+
}
56+
57+
5258
function switchUser(
5359
string $eppn,
5460
string $given_name,

0 commit comments

Comments
 (0)