Skip to content

Commit 64670d2

Browse files
fix mail cleanup
1 parent 2dd40cf commit 64670d2

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

tests/acceptance/bootstrap/NotificationContext.php

+40-28
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ public function getLastNotificationId(): array {
4848
}
4949

5050
/**
51-
* @AfterScenario
51+
* delete de-provisioning notification
5252
*
5353
* @return void
54+
* @throws GuzzleException
5455
*/
5556
public function deleteDeprovisioningNotification(): void {
5657
$payload["ids"] = ["deprovision"];
@@ -66,6 +67,41 @@ public function deleteDeprovisioningNotification(): void {
6667
);
6768
}
6869

70+
/**
71+
* Delete all the inbucket emails
72+
*
73+
* @return void
74+
* @throws GuzzleException
75+
*/
76+
public function clearInbucketMessages(): void {
77+
try {
78+
$usersList = $this->featureContext->getAllCreatedUsers();
79+
foreach ($usersList as $emailRecipient) {
80+
EmailHelper::deleteAllEmailsForAMailbox(
81+
EmailHelper::getLocalEmailUrl(),
82+
$this->featureContext->getStepLineRef(),
83+
$emailRecipient['email']
84+
);
85+
}
86+
} catch (Exception $e) {
87+
echo __METHOD__ .
88+
" could not delete inbucket messages, is inbucket set up?\n" .
89+
$e->getMessage();
90+
}
91+
}
92+
93+
/**
94+
* @AfterScenario
95+
*
96+
* @return void
97+
* @throws GuzzleException
98+
* @throws JsonException
99+
*/
100+
public function deleteAllNotifications(): void {
101+
$this->deleteDeprovisioningNotification();
102+
$this->clearInbucketMessages();
103+
}
104+
69105
/**
70106
* @var string
71107
*/
@@ -151,7 +187,7 @@ public function userListAllNotifications(string $user): void {
151187
* @throws GuzzleException
152188
* @throws JsonException
153189
*/
154-
public function deleteAllNotifications(string $user): ResponseInterface {
190+
public function deleteAllInAppNotifications(string $user): ResponseInterface {
155191
$response = $this->listAllNotifications($user);
156192
if (isset($this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data)) {
157193
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data;
@@ -173,7 +209,7 @@ public function deleteAllNotifications(string $user): ResponseInterface {
173209
* @throws JsonException
174210
*/
175211
public function userDeletesAllNotifications(string $user): void {
176-
$response = $this->deleteAllNotifications($user);
212+
$response = $this->deleteAllInAppNotifications($user);
177213
$this->featureContext->setResponse($response);
178214
}
179215

@@ -187,7 +223,7 @@ public function userDeletesAllNotifications(string $user): void {
187223
* @throws JsonException
188224
*/
189225
public function userHasDeletedAllNotifications(string $user): void {
190-
$response = $this->deleteAllNotifications($user);
226+
$response = $this->deleteAllInAppNotifications($user);
191227
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
192228
}
193229

@@ -661,30 +697,6 @@ public function assertEmailContains(
661697
);
662698
}
663699

664-
/**
665-
* Delete all the inbucket emails
666-
*
667-
* @AfterScenario @email
668-
*
669-
* @return void
670-
*/
671-
public function clearInbucketMessages(): void {
672-
try {
673-
$usersList = $this->featureContext->getAllCreatedUsers();
674-
foreach ($usersList as $emailRecipient) {
675-
EmailHelper::deleteAllEmailsForAMailbox(
676-
EmailHelper::getLocalEmailUrl(),
677-
$this->featureContext->getStepLineRef(),
678-
$emailRecipient['email']
679-
);
680-
}
681-
} catch (Exception $e) {
682-
echo __METHOD__ .
683-
" could not delete inbucket messages, is inbucket set up?\n" .
684-
$e->getMessage();
685-
}
686-
}
687-
688700
/**
689701
*
690702
* @param string|null $user

0 commit comments

Comments
 (0)