From b88cd12b9dafd75142b67f09150724219f59a5e9 Mon Sep 17 00:00:00 2001 From: Amrita <54478846+amrita-shrestha@users.noreply.github.com> Date: Tue, 18 Jul 2023 16:22:28 +0545 Subject: [PATCH] [tests-only][full-ci]Backport delete notification tests coverage (#6836) * Add tests for space notification (#6372) * Add tests for deleting specific notification --- .../deleteNotification.feature | 30 ++ .../apiNotification/notification.feature | 1 - .../apiNotification/spaceNotification.feature | 472 ++++++++++++++++++ .../features/apiSpaces/notification.feature | 180 ------- .../bootstrap/NotificationContext.php | 157 +++++- .../acceptance/features/bootstrap/Sharing.php | 3 +- .../features/bootstrap/SpacesContext.php | 42 ++ 7 files changed, 701 insertions(+), 184 deletions(-) create mode 100644 tests/acceptance/features/apiNotification/deleteNotification.feature create mode 100644 tests/acceptance/features/apiNotification/spaceNotification.feature delete mode 100644 tests/acceptance/features/apiSpaces/notification.feature diff --git a/tests/acceptance/features/apiNotification/deleteNotification.feature b/tests/acceptance/features/apiNotification/deleteNotification.feature new file mode 100644 index 00000000000..bb32c544ea0 --- /dev/null +++ b/tests/acceptance/features/apiNotification/deleteNotification.feature @@ -0,0 +1,30 @@ +@api +Feature: Delete notification + As a user + I want to delete notifications + So that I can filter notifications + + Background: + Given these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + And user "Alice" has uploaded file with content "other data" to "/textfile1.txt" + And user "Alice" has created folder "my_data" + And user "Alice" has shared folder "my_data" with user "Brian" + And user "Alice" has shared file "/textfile1.txt" with user "Brian" + + + Scenario: delete a notification + When user "Brian" deletes a notification related to resource "my_data" with subject "Resource shared" + Then the HTTP status code should be "200" + And user "Brian" should have a notification with subject "Resource shared" and message: + | message | + | Alice Hansen shared textfile1.txt with you | + But user "Brian" should not have a notification related to resource "my_data" with subject "Resource shared" + + + Scenario: delete all notifications + When user "Brian" deletes all notifications + Then the HTTP status code should be "200" + And user "Brian" should not have any notification diff --git a/tests/acceptance/features/apiNotification/notification.feature b/tests/acceptance/features/apiNotification/notification.feature index 4734f2da04a..4d522b33f8c 100644 --- a/tests/acceptance/features/apiNotification/notification.feature +++ b/tests/acceptance/features/apiNotification/notification.feature @@ -267,7 +267,6 @@ Feature: Notification Examples: | language | subject | message | | de | Neue Freigabe | Alice Hansen hat textfile1.txt mit Ihnen geteilt | - | en | Resource shared | Alice Hansen shared textfile1.txt with you | | es | Recurso compartido | Alice Hansen compartió textfile1.txt contigo | diff --git a/tests/acceptance/features/apiNotification/spaceNotification.feature b/tests/acceptance/features/apiNotification/spaceNotification.feature new file mode 100644 index 00000000000..8e03466d15f --- /dev/null +++ b/tests/acceptance/features/apiNotification/spaceNotification.feature @@ -0,0 +1,472 @@ +@api +Feature: Notification + As a user + I want to be notified of actions related to space + So that I can stay updated about the spaces + + Background: + Given these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + | Carol | + And the administrator has given "Alice" the role "Space Admin" using the settings api + And user "Alice" has created a space "notification checking" with the default quota using the GraphApi + + + Scenario: get a notification of space shared + Given user "Alice" has shared a space "notification checking" with settings: + | shareWith | Brian | + | role | editor | + When user "Brian" lists all notifications + Then the HTTP status code should be "200" + And the JSON response should contain a notification message with the subject "Space shared" and the message-details should match + """ + { + "type": "object", + "required": [ + "app", + "datetime", + "message", + "messageRich", + "messageRichParameters", + "notification_id", + "object_id", + "object_type", + "subject", + "subjectRich", + "user" + ], + "properties": { + "app": { + "type": "string", + "enum": [ + "userlog" + ] + }, + "message": { + "type": "string", + "enum": [ + "Alice Hansen added you to Space notification checking" + ] + }, + "messageRich": { + "type": "string", + "enum": [ + "{user} added you to Space {space}" + ] + }, + "messageRichParameters": { + "type": "object", + "required": [ + "space", + "user" + ], + "properties": { + "space": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + }, + "name": { + "type": "string", + "enum": [ + "notification checking" + ] + } + } + }, + "user": { + "type": "object", + "required": [ + "displayname", + "id", + "name" + ], + "properties": { + "displayname": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + }, + "id": { + "type": "string", + "enim": [ + "%user_id%" + ] + }, + "name": { + "type": "string", + "enum": [ + "Alice" + ] + } + } + } + } + }, + "notification_id": { + "type": "string" + }, + "object_id": { + "type": "string", + "pattern": "^%space_id_pattern%$" + }, + "object_type": { + "type": "string", + "enum": [ + "storagespace" + ] + }, + "subject": { + "type": "string", + "enum": [ + "Space shared" + ] + }, + "subjectRich": { + "type": "string", + "enum": [ + "Space shared" + ] + }, + "user": { + "type": "string", + "enum": [ + "Alice" + ] + } + } + } + """ + + + Scenario: get a notification of space unshared + Given user "Alice" has shared a space "notification checking" with settings: + | shareWith | Brian | + | role | editor | + And user "Alice" has unshared a space "notification checking" shared with "Brian" + When user "Brian" lists all notifications + Then the HTTP status code should be "200" + And the JSON response should contain a notification message with the subject "Removed from Space" and the message-details should match + """ + { + "type": "object", + "required": [ + "app", + "datetime", + "message", + "messageRich", + "messageRichParameters", + "notification_id", + "object_id", + "object_type", + "subject", + "subjectRich", + "user" + ], + "properties": { + "app": { + "type": "string", + "enum": [ + "userlog" + ] + }, + "message": { + "type": "string", + "enum": [ + "Alice Hansen removed you from Space notification checking" + ] + }, + "messageRich": { + "type": "string", + "enum": [ + "{user} removed you from Space {space}" + ] + }, + "messageRichParameters": { + "type": "object", + "required": [ + "space", + "user" + ], + "properties": { + "space": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + }, + "name": { + "type": "string", + "enum": [ + "notification checking" + ] + } + } + }, + "user": { + "type": "object", + "required": [ + "displayname", + "id", + "name" + ], + "properties": { + "displayname": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + }, + "id": { + "type": "string", + "enim": [ + "%user_id%" + ] + }, + "name": { + "type": "string", + "enum": [ + "Alice" + ] + } + } + } + } + }, + "notification_id": { + "type": "string" + }, + "object_id": { + "type": "string", + "pattern": "^%space_id_pattern%$" + }, + "object_type": { + "type": "string", + "enum": [ + "storagespace" + ] + }, + "subject": { + "type": "string", + "enum": [ + "Removed from Space" + ] + }, + "subjectRich": { + "type": "string", + "enum": [ + "Removed from Space" + ] + }, + "user": { + "type": "string", + "enum": [ + "Alice" + ] + } + } + } + """ + + + Scenario: get a notification of space disabled + Given user "Alice" has shared a space "notification checking" with settings: + | shareWith | Brian | + | role | editor | + And user "Alice" has disabled a space "notification checking" + When user "Brian" lists all notifications + Then the HTTP status code should be "200" + And user "Brian" should have "2" notifications + And the JSON response should contain a notification message with the subject "Space disabled" and the message-details should match + """ + { + "type": "object", + "required": [ + "app", + "datetime", + "message", + "messageRich", + "messageRichParameters", + "notification_id", + "object_id", + "object_type", + "subject", + "subjectRich", + "user" + ], + "properties": { + "app": { + "type": "string", + "enum": [ + "userlog" + ] + }, + "message": { + "type": "string", + "enum": [ + "Alice Hansen disabled Space notification checking" + ] + }, + "messageRich": { + "type": "string", + "enum": [ + "{user} disabled Space {space}" + ] + }, + "messageRichParameters": { + "type": "object", + "required": [ + "space", + "user" + ], + "properties": { + "space": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + }, + "name": { + "type": "string", + "enum": [ + "notification checking" + ] + } + } + }, + "user": { + "type": "object", + "required": [ + "displayname", + "id", + "name" + ], + "properties": { + "displayname": { + "type": "string", + "enum": [ + "Alice Hansen" + ] + }, + "id": { + "type": "string", + "enim": [ + "%user_id%" + ] + }, + "name": { + "type": "string", + "enum": [ + "Alice" + ] + } + } + } + } + }, + "notification_id": { + "type": "string" + }, + "object_id": { + "type": "string", + "pattern": "^%space_id_pattern%$" + }, + "object_type": { + "type": "string", + "enum": [ + "storagespace" + ] + }, + "subject": { + "type": "string", + "enum": [ + "Space disabled" + ] + }, + "subjectRich": { + "type": "string", + "enum": [ + "Space disabled" + ] + }, + "user": { + "type": "string", + "enum": [ + "Alice" + ] + } + } + } + """ + + + Scenario Outline: get a notification about a space share in various languages + Given user "Brian" has switched the system language to "" + And user "Alice" has shared a space "notification checking" with settings: + | shareWith | Brian | + | role | editor | + When user "Brian" lists all notifications + Then the HTTP status code should be "200" + And the JSON response should contain a notification message with the subject "" and the message-details should match + """ + { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string", + "enum": [ + "" + ] + } + } + } + """ + Examples: + | language | subject | message | + | de | Space freigegeben | Alice Hansen hat Sie zu Space notification checking hinzugefügt | + | es | Space compartido | Alice Hansen te añadió al Space notification checking | + + + Scenario: all notification related to space get deleted when the sharer deletes that resource + Given user "Alice" has shared a space "notification checking" with settings: + | shareWith | Brian | + | role | editor | + And user "Alice" has unshared a space "notification checking" shared with "Brian" + And user "Alice" has disabled a space "notification checking" + And user "Alice" has deleted a space "notification checking" + When user "Brian" lists all notifications + Then the HTTP status code should be "200" + And the notifications should be empty + + + Scenario: user doesn't get any notification after being removed from space + Given user "Alice" has shared a space "notification checking" with settings: + | shareWith | Brian | + | role | editor | + And user "Alice" has unshared a space "notification checking" shared with "Brian" + And user "Alice" has disabled a space "notification checking" + When user "Brian" lists all notifications + Then the HTTP status code should be "200" + And user "Brian" should have "2" notifications diff --git a/tests/acceptance/features/apiSpaces/notification.feature b/tests/acceptance/features/apiSpaces/notification.feature deleted file mode 100644 index 763f8fe2602..00000000000 --- a/tests/acceptance/features/apiSpaces/notification.feature +++ /dev/null @@ -1,180 +0,0 @@ -@api -Feature: Notification - As a user - I want to be notified of actions related to me - So that I can stay updated about the information - - Background: - Given these users have been created with default attributes and without skeleton files: - | username | - | Alice | - | Brian | - | Carol | - And the administrator has given "Alice" the role "Space Admin" using the settings api - - - Scenario: user gets a notification of space sharing - Given user "Alice" has created a space "notification checking" with the default quota using the GraphApi - And user "Alice" has shared a space "notification checking" with settings: - | shareWith | Brian | - | role | editor | - When user "Brian" lists all notifications - Then the HTTP status code should be "200" - And the JSON response should contain a notification message with the subject "Space shared" and the message-details should match - """ - { - "type": "object", - "required": [ - "app", - "datetime", - "message", - "messageRich", - "messageRichParameters", - "notification_id", - "object_id", - "object_type", - "subject", - "subjectRich", - "user" - ], - "properties": { - "app": { - "type": "string", - "enum": [ - "userlog" - ] - }, - "message": { - "type": "string", - "enum": [ - "Alice Hansen added you to Space notification checking" - ] - }, - "messageRich": { - "type": "string", - "enum": [ - "{user} added you to Space {space}" - ] - }, - "messageRichParameters": { - "type": "object", - "required": [ - "space", - "user" - ], - "properties": { - "space": { - "type": "object", - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "string", - "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - }, - "name": { - "type": "string", - "enum": [ - "notification checking" - ] - } - } - }, - "user": { - "type": "object", - "required": [ - "displayname", - "id", - "name" - ], - "properties": { - "displayname": { - "type": "string", - "enum": [ - "Alice Hansen" - ] - }, - "id": { - "type": "string", - "enim": [ - "%user_id%" - ] - }, - "name": { - "type": "string", - "enum": [ - "Alice" - ] - } - } - } - } - }, - "notification_id": { - "type": "string" - }, - "object_id": { - "type": "string", - "pattern": "^%space_id_pattern%$" - }, - "object_type": { - "type": "string", - "enum": [ - "storagespace" - ] - }, - "subject": { - "type": "string", - "enum": [ - "Space shared" - ] - }, - "subjectRich": { - "type": "string", - "enum": [ - "Space shared" - ] - }, - "user": { - "type": "string", - "enum": [ - "Alice" - ] - } - } - } - """ - - - Scenario Outline: user gets a notification of space sharing in different languages - Given user "Alice" has created a space "notification checking" with the default quota using the GraphApi - And user "Brian" has switched the system language to "" - And user "Alice" has shared a space "notification checking" with settings: - | shareWith | Brian | - | role | editor | - When user "Brian" lists all notifications - Then the HTTP status code should be "200" - And the JSON response should contain a notification message with the subject "" and the message-details should match - """ - { - "type": "object", - "required": [ - "message" - ], - "properties": { - "message": { - "type": "string", - "enum": [ - "" - ] - } - } - } - """ - Examples: - | language | subject | message | - | de | Space freigegeben | Alice Hansen hat Sie zu Space notification checking hinzugefügt | - | en | Space shared | Alice Hansen added you to Space notification checking | - | es | Space compartido | Alice Hansen te añadió al Space notification checking | diff --git a/tests/acceptance/features/bootstrap/NotificationContext.php b/tests/acceptance/features/bootstrap/NotificationContext.php index 6836096a02c..ff4396b1b9b 100644 --- a/tests/acceptance/features/bootstrap/NotificationContext.php +++ b/tests/acceptance/features/bootstrap/NotificationContext.php @@ -14,6 +14,8 @@ use PHPUnit\Framework\Assert; use TestHelpers\GraphHelper; use Behat\Gherkin\Node\TableNode; +use GuzzleHttp\Exception\GuzzleException; +use Psr\Http\Message\ResponseInterface; require_once 'bootstrap.php'; @@ -104,6 +106,68 @@ public function userListAllNotifications(string $user):void { $this->featureContext->setResponse($response); } + /** + * @When user :user deletes all notifications + * + * @param string $user + * + * @return void + * @throws GuzzleException + * @throws JsonException + */ + public function userDeletesAllNotifications(string $user):void { + $this->userListAllNotifications($user); + if (isset($this->featureContext->getJsonDecodedResponseBodyContent()->ocs->data)) { + $responseBody = $this->featureContext->getJsonDecodedResponseBodyContent()->ocs->data; + foreach ($responseBody as $value) { + // set notificationId + $this->notificationIds[] = $value->notification_id; + } + } + $this->featureContext->setResponse($this->userDeletesNotification($user)); + } + + /** + * @When user :user deletes a notification related to resource :resource with subject :subject + * + * @param string $user + * @param string $resource + * @param string $subject + * + * @return void + * @throws GuzzleException + * @throws JsonException + */ + public function userDeletesNotificationOfResourceAndSubject(string $user, string $resource, string $subject):void { + $this->userListAllNotifications($user); + $this->filterResponseByNotificationSubjectAndResource($subject, $resource); + $this->featureContext->setResponse($this->userDeletesNotification($user)); + } + + /** + * deletes notification + * + * @param string $user + * + * @return void + * @throws GuzzleException + * @throws JsonException + */ + public function userDeletesNotification(string $user):ResponseInterface { + $this->setUserRecipient($user); + $payload["ids"] = $this->getNotificationIds(); + return OcsApiHelper::sendRequest( + $this->featureContext->getBaseUrl(), + $this->featureContext->getActualUsername($user), + $this->featureContext->getPasswordForUser($user), + 'DELETE', + $this->notificationEndpointPath, + $this->featureContext->getStepLineRef(), + \json_encode($payload), + 2 + ); + } + /** * @Then the notifications should be empty * @@ -111,10 +175,53 @@ public function userListAllNotifications(string $user):void { * @throws Exception */ public function theNotificationsShouldBeEmpty(): void { + $statusCode = $this->featureContext->getResponse()->getStatusCode(); + if ($statusCode !== 200) { + $response = $this->featureContext->getResponse()->getBody()->getContents(); + throw new \Exception( + __METHOD__ + . " Failed to get user notification list" . $response + ); + } $notifications = $this->featureContext->getJsonDecodedResponseBodyContent()->ocs->data; Assert::assertNull($notifications, "response should not contain any notification"); } + /** + * @Then user :user should not have any notification + * + * @param $user + * + * @return void + * @throws Exception + */ + public function userShouldNotHaveAnyNotification($user): void { + $this->userListAllNotifications($user); + $this->theNotificationsShouldBeEmpty(); + } + + /** + * @Then /^user "([^"]*)" should have "([^"]*)" notifications$/ + * + * @param string $user + * @param int $numberOfNotification + * + * @return void + * @throws Exception + */ + public function userShouldHaveNotifications(string $user, int $numberOfNotification): void { + if (!isset($this->featureContext->getJsonDecodedResponseBodyContent()->ocs->data)) { + throw new Exception("Notification is empty"); + } + $responseBody = $this->featureContext->getJsonDecodedResponseBodyContent()->ocs->data; + $actualNumber = \count($responseBody); + Assert::assertEquals( + $numberOfNotification, + $actualNumber, + "Expected number of notification was '$numberOfNotification', but got '$actualNumber'" + ); + } + /** * @Then /^the JSON response should contain a notification message with the subject "([^"]*)" and the message-details should match$/ * @@ -146,6 +253,8 @@ public function theJsonDataFromLastResponseShouldMatch( } /** + * filter notification according to subject + * * @param string $subject * * @return object @@ -169,7 +278,37 @@ public function filterResponseAccordingToNotificationSubject(string $subject): o } /** - * @Then user :user should get a notification with subject :subject and message: + * filter notification according to subject and resource + * + * @param string $subject + * @param string $resource + * + * @return array + */ + public function filterResponseByNotificationSubjectAndResource(string $subject, string $resource): array { + $responseBodyArray = []; + $statusCode = $this->featureContext->getResponse()->getStatusCode(); + if ($statusCode !== 200) { + $response = $this->featureContext->getResponse()->getBody()->getContents(); + Assert::fail($response . " Response should contain status code 200"); + } + if (isset($this->featureContext->getJsonDecodedResponseBodyContent()->ocs->data)) { + $responseBody = $this->featureContext->getJsonDecodedResponseBodyContent()->ocs->data; + foreach ($responseBody as $value) { + if (isset($value->subject) && $value->subject === $subject && isset($value->messageRichParameters->resource->name) && $value->messageRichParameters->resource->name === $resource) { + $this->notificationIds[] = $value->notification_id; + $responseBodyArray[] = $value; + } + } + } else { + $responseBodyArray[] = $this->featureContext->getJsonDecodedResponseBodyContent(); + Assert::fail("Response should contain notification but found: $responseBodyArray"); + } + return $responseBodyArray; + } + + /** + * @Then /^user "([^"]*)" should (?:get|have) a notification with subject "([^"]*)" and message:$/ * * @param string $user * @param string $subject @@ -179,7 +318,6 @@ public function filterResponseAccordingToNotificationSubject(string $subject): o */ public function userShouldGetANotificationWithMessage(string $user, string $subject, TableNode $table):void { $this->userListAllNotifications($user); - $this->featureContext->theHTTPStatusCodeShouldBe(200); $actualMessage = str_replace(["\r", "\n"], " ", $this->filterResponseAccordingToNotificationSubject($subject)->message); $expectedMessage = $table->getColumnsHash()[0]['message']; Assert::assertSame( @@ -189,6 +327,21 @@ public function userShouldGetANotificationWithMessage(string $user, string $subj ); } + /** + * @Then user :user should not have a notification related to resource :resource with subject :subject + * + * @param string $user + * @param string $resource + * @param string $subject + * + * @return void + */ + public function userShouldNotHaveANotificationRelatedToResourceWithSubject(string $user, string $resource, string $subject):void { + $this->userListAllNotifications($user); + $response = $this->filterResponseByNotificationSubjectAndResource($subject, $resource); + Assert::assertCount(0, $response, "Response should not contain notification related to resource '$resource' with subject '$subject' but found" . print_r($response, true)); + } + /** * @Then user :user should have received the following email from user :sender about the share of project space :spaceName * diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index c7262376d9a..623464255f9 100644 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -26,6 +26,7 @@ use Behat\Gherkin\Node\TableNode; use Psr\Http\Message\ResponseInterface; use PHPUnit\Framework\Assert; +use PHPUnit\Framework\ExpectationFailedException; use TestHelpers\OcsApiHelper; use TestHelpers\SharingHelper; use TestHelpers\HttpRequestHelper; @@ -3424,7 +3425,7 @@ public function assertSharesOfUserAreInState(string $user, string $state, TableN Assert::assertEquals($row['path'], $share['path']); $found = true; break; - } catch (PHPUnit\Framework\ExpectationFailedException $e) { + } catch (ExpectationFailedException $e) { } } if (!$found) { diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index ccc20fc81a8..402b43ff1f8 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -2099,6 +2099,28 @@ public function userHasSharedSpace( $this->ocsContext->theOCSStatusCodeShouldBe($expectedOCSStatus, "Expected OCS response status code $expectedOCSStatus"); } + /** + * @Given user :user has unshared a space :spaceName shared with :recipient + * + * @param string $user + * @param string $spaceName + * @param string $recipient + * + * @return void + * @throws GuzzleException + */ + public function userHasUnsharedASpaceSharedWith( + string $user, + string $spaceName, + string $recipient + ): void { + $this->sendUnshareSpaceRequest($user, $spaceName, $recipient); + $this->featureContext->theHTTPStatusCodeShouldBe( + 200, + "Expected response status code should be 200" + ); + } + /** * @When /^user "([^"]*)" unshares a space "([^"]*)" to (?:user|group) "([^"]*)"$/ * @@ -2154,6 +2176,26 @@ public function sendRemoveObjectFromSpaceRequest( ); } + /** + * @Given /^user "([^"]*)" has deleted a space "([^"]*)"$/ + * + * @param string $user + * @param string $spaceName + * + * @return void + * @throws GuzzleException + */ + public function userHasDeletedASpaceOwnedByUser( + string $user, + string $spaceName + ):void { + $this->sendDeleteSpaceRequest($user, $spaceName); + $this->featureContext->theHTTPStatusCodeShouldBe( + 204, + "Expected response status code should be 200" + ); + } + /** * @When /^user "([^"]*)" disables a space "([^"]*)"$/ * @When /^user "([^"]*)" (?:disables|tries to disable) a space "([^"]*)" owned by user "([^"]*)"$/