From 0d9f676901e017a4e71f82835e6a78e5f635f80b Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi <41103328+SwikritiT@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:25:01 +0545 Subject: [PATCH] tests: refactor send profind request to space function (#7835) --- .../features/bootstrap/SpacesContext.php | 44 +++++++++++++------ .../bootstrap/WebDavLockingContext.php | 6 +-- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 14966c178..3fcc05d63 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -3477,25 +3477,41 @@ class SpacesContext implements Context { * @param string $spaceName * @param ?string $resource * - * @throws GuzzleException - * * @return void + * + * @throws JsonException + * + * @throws GuzzleException */ public function userSendsPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = ""): void { + $this->featureContext->setResponse( + $this->sendPropfindRequestToSpace($user, $spaceName, $resource) + ); + } + + /** + * @param string $user + * @param string $spaceName + * @param string|null $resource + * + * @return ResponseInterface + * @throws GuzzleException + * + * @throws JsonException + */ + public function sendPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = ""): ResponseInterface { $this->setSpaceIDByName($user, $spaceName); $properties = ['oc:permissions','oc:file-parent','oc:fileid','oc:share-types','oc:privatelink','d:resourcetype','oc:size','oc:name','d:getcontenttype','oc:tags','d:lockdiscovery','d:activelock']; - $this->featureContext->setResponse( - WebDavHelper::propfind( - $this->featureContext->getBaseUrl(), - $this->featureContext->getActualUsername($user), - $this->featureContext->getPasswordForUser($user), - $resource, - $properties, - $this->featureContext->getStepLineRef(), - "0", - "files", - WebDavHelper::DAV_VERSION_SPACES - ) + return WebDavHelper::propfind( + $this->featureContext->getBaseUrl(), + $this->featureContext->getActualUsername($user), + $this->featureContext->getPasswordForUser($user), + $resource, + $properties, + $this->featureContext->getStepLineRef(), + "0", + "files", + WebDavHelper::DAV_VERSION_SPACES ); } diff --git a/tests/acceptance/features/bootstrap/WebDavLockingContext.php b/tests/acceptance/features/bootstrap/WebDavLockingContext.php index 30354d6ee..3fc79a939 100644 --- a/tests/acceptance/features/bootstrap/WebDavLockingContext.php +++ b/tests/acceptance/features/bootstrap/WebDavLockingContext.php @@ -914,9 +914,9 @@ class WebDavLockingContext implements Context { * @throws GuzzleException */ public function numberOfLockShouldBeReportedInProjectSpace(int $count, string $file, string $spaceName, string $user) { - $this->spacesContext->userSendsPropfindRequestToSpace($user, $spaceName, $file); - $this->featureContext->theHTTPStatusCodeShouldBe(207, ""); - $responseXml = $this->featureContext->getResponseXml(); + $response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file); + $this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response); + $responseXml = $this->featureContext->getResponseXml($response); $xmlPart = $responseXml->xpath("//d:response//d:lockdiscovery/d:activelock"); if (\is_array($xmlPart)) { $lockCount = \count($xmlPart);