Skip to content

Commit a0ae411

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

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

test/functional/PiMemberApproveTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ public function testApproveRequest()
4141
$piGroup->approveUser($requestedUser);
4242
$this->assertEmpty($piGroup->getRequests());
4343

44-
$this->assertEquals([$pi->getUID(), self::$requestUid], $piGroup->getGroupMemberUIDs());
44+
$this->assertTrue(
45+
arraysAreEqualUnOrdered(
46+
[$pi->getUID(), self::$requestUid],
47+
$piGroup->getGroupMemberUIDs()
48+
)
49+
);
4550
$this->assertTrue($piGroup->userExists($requestedUser));
4651
} finally {
4752
$piGroup->removeUser($requestedUser);
@@ -56,7 +61,12 @@ public function testApproveNonexistentRequest()
5661
$pi = $USER;
5762
$piGroup = $USER->getPIGroup();
5863
$this->assertTrue($piGroup->exists());
59-
$this->assertEquals([$pi->getUID()], $piGroup->getGroupMemberUIDs());
64+
$this->assertTrue(
65+
arraysAreEqualUnOrdered(
66+
[$pi->getUID()],
67+
$piGroup->getGroupMemberUIDs()
68+
)
69+
);
6070
$this->assertEmpty($piGroup->getRequests());
6171

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

test/functional/PiMemberDenyTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ public function testDenyRequest()
3737

3838
$piGroup->denyUser($requestedUser);
3939
$this->assertEmpty($piGroup->getRequests());
40-
$this->assertEquals([$pi->getUID()], $piGroup->getGroupMemberUIDs());
40+
$this->assertTrue(
41+
arraysAreEqualUnOrdered(
42+
[$pi->getUID()],
43+
$piGroup->getGroupMemberUIDs()
44+
)
45+
);
4146
$this->assertFalse($piGroup->userExists($requestedUser));
4247
} finally {
4348
$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)