@@ -48,9 +48,10 @@ public function getLastNotificationId(): array {
48
48
}
49
49
50
50
/**
51
- * @AfterScenario
51
+ * delete all in-app notifications
52
52
*
53
53
* @return void
54
+ * @throws GuzzleException
54
55
*/
55
56
public function deleteDeprovisioningNotification (): void {
56
57
$ payload ["ids " ] = ["deprovision " ];
@@ -66,6 +67,41 @@ public function deleteDeprovisioningNotification(): void {
66
67
);
67
68
}
68
69
70
+ /**
71
+ * Delete all the emails
72
+ *
73
+ * @return void
74
+ * @throws GuzzleException
75
+ */
76
+ public function clearAllEmails (): 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 @notification
95
+ *
96
+ * @return void
97
+ * @throws GuzzleException
98
+ * @throws JsonException
99
+ */
100
+ public function deleteAllNotifications (): void {
101
+ $ this ->deleteDeprovisioningNotification ();
102
+ $ this ->clearAllEmails ();
103
+ }
104
+
69
105
/**
70
106
* @var string
71
107
*/
@@ -151,7 +187,7 @@ public function userListAllNotifications(string $user): void {
151
187
* @throws GuzzleException
152
188
* @throws JsonException
153
189
*/
154
- public function deleteAllNotifications (string $ user ): ResponseInterface {
190
+ public function deleteAllInAppNotifications (string $ user ): ResponseInterface {
155
191
$ response = $ this ->listAllNotifications ($ user );
156
192
if (isset ($ this ->featureContext ->getJsonDecodedResponseBodyContent ($ response )->ocs ->data )) {
157
193
$ responseBody = $ this ->featureContext ->getJsonDecodedResponseBodyContent ($ response )->ocs ->data ;
@@ -173,7 +209,7 @@ public function deleteAllNotifications(string $user): ResponseInterface {
173
209
* @throws JsonException
174
210
*/
175
211
public function userDeletesAllNotifications (string $ user ): void {
176
- $ response = $ this ->deleteAllNotifications ($ user );
212
+ $ response = $ this ->deleteAllInAppNotifications ($ user );
177
213
$ this ->featureContext ->setResponse ($ response );
178
214
}
179
215
@@ -187,7 +223,7 @@ public function userDeletesAllNotifications(string $user): void {
187
223
* @throws JsonException
188
224
*/
189
225
public function userHasDeletedAllNotifications (string $ user ): void {
190
- $ response = $ this ->deleteAllNotifications ($ user );
226
+ $ response = $ this ->deleteAllInAppNotifications ($ user );
191
227
$ this ->featureContext ->theHTTPStatusCodeShouldBe (200 , "" , $ response );
192
228
}
193
229
@@ -333,16 +369,13 @@ public function filterResponseAccordingToNotificationSubject(
333
369
$ responseBody = $ this ->featureContext ->getJsonDecodedResponseBodyContent ($ response )->ocs ->data ;
334
370
foreach ($ responseBody as $ value ) {
335
371
if (isset ($ value ->subject ) && $ value ->subject === $ subject ) {
336
- $ responseBody = $ value ;
337
372
// set notificationId
338
373
$ this ->notificationIds [] = $ value ->notification_id ;
339
- break ;
374
+ return $ value ;
340
375
}
341
376
}
342
- } else {
343
- $ responseBody = $ this ->featureContext ->getJsonDecodedResponseBodyContent ($ response );
344
377
}
345
- return $ responseBody ;
378
+ return new StdClass () ;
346
379
}
347
380
348
381
/**
@@ -663,30 +696,6 @@ public function assertEmailContains(
663
696
);
664
697
}
665
698
666
- /**
667
- * Delete all the inbucket emails
668
- *
669
- * @AfterScenario @email
670
- *
671
- * @return void
672
- */
673
- public function clearInbucketMessages (): void {
674
- try {
675
- $ usersList = $ this ->featureContext ->getAllCreatedUsers ();
676
- foreach ($ usersList as $ emailRecipient ) {
677
- EmailHelper::deleteAllEmailsForAMailbox (
678
- EmailHelper::getLocalEmailUrl (),
679
- $ this ->featureContext ->getStepLineRef (),
680
- $ emailRecipient ['email ' ]
681
- );
682
- }
683
- } catch (Exception $ e ) {
684
- echo __METHOD__ .
685
- " could not delete inbucket messages, is inbucket set up? \n" .
686
- $ e ->getMessage ();
687
- }
688
- }
689
-
690
699
/**
691
700
*
692
701
* @param string|null $user
0 commit comments