Skip to content

Commit 5873e70

Browse files
committed
tests should cleanup after themselves
1 parent a5a79b5 commit 5873e70

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

resources/lib/UnitySQL.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ public function accDeletionRequestExists($uid)
283283
return count($stmt->fetchAll()) > 0;
284284
}
285285

286+
public function deleteAccountDeletionRequest($uid)
287+
{
288+
if (!$this->accDeletionRequestExists($requestor, $dest)) {
289+
return;
290+
}
291+
$stmt = $this->conn->prepare(
292+
"DELETE FROM " . self::TABLE_ACCOUNT_DELETION_REQUESTS . " WHERE uid=:uid"
293+
);
294+
$stmt->bindParam(":uid", $uid);
295+
$stmt->execute();
296+
}
297+
286298
public function getSiteVar($name)
287299
{
288300
$stmt = $this->conn->prepare(

test/functional/AccountDeletionRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testRequestAccountDeletionUserHasNoGroups()
4949
);
5050
$this->assertNumberAccountDeletionRequests(1);
5151
} finally {
52-
$SQL->removeRequest($USER->getUID());
52+
$SQL->deleteAccountDeletionRequest($USER->getUID());
5353
$this->assertNumberAccountDeletionRequests(0);
5454
}
5555
}
@@ -68,7 +68,7 @@ public function testRequestAccountDeletionUserHasGroup()
6868
);
6969
$this->assertNumberAccountDeletionRequests(0);
7070
} finally {
71-
$SQL->removeRequest($USER->getUID());
71+
$SQL->deleteAccountDeletionRequest($USER->getUID());
7272
$this->assertNumberAccountDeletionRequests(0);
7373
}
7474
}

test/functional/PiBecomeRequestTest.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,21 @@ public function testRequestBecomePi()
3535
{
3636
global $USER, $SQL;
3737
switchUser(...getUserNotPiNotRequestedBecomePi());
38-
error_log(json_encode($SQL->getConn()->prepare("select * from requests"))->execute()->fetchAll());
3938
$this->assertFalse($USER->isPI());
4039
$this->assertNumberPiBecomeRequests(0);
41-
post(
42-
__DIR__ . "/../../webroot/panel/account.php",
43-
["form_type" => "pi_request"]
44-
);
45-
$this->assertNumberPiBecomeRequests(1);
46-
post(
47-
__DIR__ . "/../../webroot/panel/account.php",
48-
["form_type" => "pi_request"]
49-
);
50-
$this->assertNumberPiBecomeRequests(1);
40+
try {
41+
post(
42+
__DIR__ . "/../../webroot/panel/account.php",
43+
["form_type" => "pi_request"]
44+
);
45+
$this->assertNumberPiBecomeRequests(1);
46+
post(
47+
__DIR__ . "/../../webroot/panel/account.php",
48+
["form_type" => "pi_request"]
49+
);
50+
$this->assertNumberPiBecomeRequests(1);
51+
} finally {
52+
$SQL->removeRequest($USER->getUID());
53+
}
5154
}
5255
}

0 commit comments

Comments
 (0)