|
24 | 24 | */ |
25 | 25 | class NotificationContext implements Context { |
26 | 26 | private FeatureContext $featureContext; |
27 | | - private string $notificationEndpointPath = '/apps/notifications/api/v1/notifications?format=json'; |
| 27 | + private string $notificationEndpointPath = '/apps/notifications/api/v1/notifications'; |
28 | 28 | private string $globalNotificationEndpointPath = '/apps/notifications/api/v1/notifications/global'; |
29 | 29 |
|
30 | 30 | private array $notificationIds; |
@@ -115,7 +115,7 @@ public function listAllNotifications(string $user): ResponseInterface { |
115 | 115 | $this->featureContext->getActualUsername($user), |
116 | 116 | $this->featureContext->getPasswordForUser($user), |
117 | 117 | 'GET', |
118 | | - $this->notificationEndpointPath, |
| 118 | + $this->notificationEndpointPath . '?format=json', |
119 | 119 | [], |
120 | 120 | 2, |
121 | 121 | $headers, |
@@ -216,7 +216,7 @@ public function userDeletesNotification(string $user): ResponseInterface { |
216 | 216 | $this->featureContext->getActualUsername($user), |
217 | 217 | $this->featureContext->getPasswordForUser($user), |
218 | 218 | 'DELETE', |
219 | | - $this->notificationEndpointPath, |
| 219 | + $this->notificationEndpointPath . '?format=json', |
220 | 220 | \json_encode($payload), |
221 | 221 | 2, |
222 | 222 | ); |
@@ -614,4 +614,50 @@ public function userDeletesDeprovisioningNotification(?string $user = null): voi |
614 | 614 | ); |
615 | 615 | $this->featureContext->setResponse($response); |
616 | 616 | } |
| 617 | + |
| 618 | + /** |
| 619 | + * deletes notification using id |
| 620 | + * |
| 621 | + * @param string $user |
| 622 | + * @param string $notificationId |
| 623 | + * |
| 624 | + * @return ResponseInterface |
| 625 | + * @throws GuzzleException |
| 626 | + * @throws JsonException |
| 627 | + */ |
| 628 | + public function deleteNotificationUsingId(string $user, string $notificationId): ResponseInterface { |
| 629 | + $deleteNotificationEndpoint = $this->notificationEndpointPath . '/' . $notificationId; |
| 630 | + return OcsApiHelper::sendRequest( |
| 631 | + $this->featureContext->getBaseUrl(), |
| 632 | + $this->featureContext->getActualUsername($user), |
| 633 | + $this->featureContext->getPasswordForUser($user), |
| 634 | + 'DELETE', |
| 635 | + $deleteNotificationEndpoint, |
| 636 | + ); |
| 637 | + } |
| 638 | + |
| 639 | + /** |
| 640 | + * @When user :user deletes a notification related to resource :resource with subject :subject using id |
| 641 | + * |
| 642 | + * @param string $user |
| 643 | + * @param string $resource |
| 644 | + * @param string $subject |
| 645 | + * |
| 646 | + * @return void |
| 647 | + * @throws GuzzleException |
| 648 | + * @throws JsonException |
| 649 | + */ |
| 650 | + public function userDeletesNotificationOfResourceAndSubjectById( |
| 651 | + string $user, |
| 652 | + string $resource, |
| 653 | + string $subject, |
| 654 | + ): void { |
| 655 | + $allNotifications = $this->listAllNotifications($user); |
| 656 | + $filteredNotificationId = $this->filterNotificationsBySubjectAndResource( |
| 657 | + $subject, |
| 658 | + $resource, |
| 659 | + $allNotifications, |
| 660 | + )[0]->notification_id; |
| 661 | + $this->featureContext->setResponse($this->deleteNotificationUsingId($user, $filteredNotificationId)); |
| 662 | + } |
617 | 663 | } |
0 commit comments