Skip to content

Commit a7dfd50

Browse files
committed
add test case
1 parent 5b9be7a commit a7dfd50

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

test/functional/AccountDeletionRequestTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,25 @@ public function testRequestAccountDeletionUserHasRequest()
6969
ensureUserNotInPIGroup($pi_group);
7070
}
7171
}
72+
73+
public function testRequestAccountDeletionCancel()
74+
{
75+
global $USER;
76+
switchUser(...getBlankUser());
77+
$this->assertEmpty($USER->getPIGroupGIDs());
78+
$this->assertNumberAccountDeletionRequests(0);
79+
$this->assertNumberRequests(0);
80+
try {
81+
http_post(__DIR__ . "/../../webroot/panel/account.php", [
82+
"form_type" => "account_deletion_request",
83+
]);
84+
$this->assertNumberAccountDeletionRequests(1);
85+
http_post(__DIR__ . "/../../webroot/panel/account.php", [
86+
"form_type" => "cancel_account_deletion_request",
87+
]);
88+
$this->assertNumberAccountDeletionRequests(0);
89+
} finally {
90+
ensureUserNotRequestedAccountDeletion();
91+
}
92+
}
7293
}

test/phpunit-bootstrap.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ function ensureOrgGroupDoesNotExist()
206206
}
207207
}
208208

209+
function ensureUserNotRequestedAccountDeletion()
210+
{
211+
global $USER, $SSO, $LDAP, $SQL, $MAILER, $WEBHOOK;
212+
if ($SQL->accDeletionRequestExists($USER->uid)) {
213+
$SQL->deleteAccountDeletionRequest($USER->uid);
214+
}
215+
}
216+
209217
function ensureUserNotInPIGroup(UnityGroup $pi_group)
210218
{
211219
global $USER;

0 commit comments

Comments
 (0)