From 2115324aedf32bbee3e2f8b6831aa78138b8f30c Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Thu, 8 Sep 2022 13:00:48 +0545 Subject: [PATCH] Reuse code from core --- .../features/bootstrap/SpacesContext.php | 46 +++++-------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index f033f3192f..147d4869fe 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -70,6 +70,11 @@ class SpacesContext implements Context { */ private WebDavLockingContext $webDavLockingContext; + /** + * @var ChecksumContext + */ + private ChecksumContext $checksumContext; + /** * @var string */ @@ -456,6 +461,7 @@ class SpacesContext implements Context { $this->webDavPropertiesContext = $environment->getContext('WebDavPropertiesContext'); $this->favoritesContext = $environment->getContext('FavoritesContext'); $this->webDavLockingContext = $environment->getContext('WebDavLockingContext'); + $this->checksumContext = $environment->getContext('ChecksumContext'); // Run the BeforeScenario function in OCSContext to set it up correctly $this->ocsContext->before($scope); $this->baseUrl = \trim($this->featureContext->getBaseUrl(), "/"); @@ -2724,25 +2730,8 @@ class SpacesContext implements Context { string $path, string $spaceName ): void { - $space = $this->getSpaceByName($user, $spaceName); - $fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($path, "/"); - $body = ' - - - - - '; - - $this->featureContext->setResponse( - $this->sendPropfindRequestToUrl( - $fullUrl, - $user, - $this->featureContext->getPasswordForUser($user), - $this->featureContext->getStepLineRef(), - [], - $body - ) - ); + $this->setSpaceIDByName($user, $spaceName); + $this->checksumContext->userRequestsTheChecksumOfViaPropfind($user, $path); } /** @@ -2751,7 +2740,7 @@ class SpacesContext implements Context { * @param string $user * @param string $checksum * @param string $content - * @param string $path + * @param string $destination * @param string $spaceName * * @throws GuzzleException @@ -2760,22 +2749,11 @@ class SpacesContext implements Context { string $user, string $checksum, string $content, - string $path, + string $destination, string $spaceName ): void { - $space = $this->getSpaceByName($user, $spaceName); - $fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($path, "/"); - - $this->featureContext->setResponse( - $this->sendPutRequestToUrl( - $fullUrl, - $user, - $this->featureContext->getPasswordForUser($user), - "", - ['OC-Checksum' => $checksum], - $content - ) - ); + $this->setSpaceIDByName($user, $spaceName); + $this->featureContext->userUploadsAFileWithChecksumAndContentTo($user, $checksum, $content, $destination); } /**