From 0272f94373fae63668bcf76c96c237d64517d7ef Mon Sep 17 00:00:00 2001 From: nirajacharya2 <122071597+nirajacharya2@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:38:37 +0545 Subject: [PATCH] removing usage of a stepdefination inside another stepdefination in WebDavLockingContext (#8746) --- .../bootstrap/WebDavLockingContext.php | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/features/bootstrap/WebDavLockingContext.php b/tests/acceptance/features/bootstrap/WebDavLockingContext.php index a74135f988..a907e5fa40 100644 --- a/tests/acceptance/features/bootstrap/WebDavLockingContext.php +++ b/tests/acceptance/features/bootstrap/WebDavLockingContext.php @@ -556,7 +556,13 @@ class WebDavLockingContext implements Context { ); $this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response); - $this->numberOfLockShouldBeReported($lockCount - 1, $itemToUnlock, $user); + $lockCountAfterUnlock = $this->countLockOfResources($user, $itemToUnlock); + + Assert::assertEquals( + $lockCount - 1, + $lockCountAfterUnlock, + "Expected $lockCount lock(s) for '$itemToUnlock' but found '$lockCount'" + ); } /** @@ -831,11 +837,37 @@ class WebDavLockingContext implements Context { string $lockOwner, string $publicWebDAVAPIVersion ) { + $response = $this->publicUploadWithUserLockToken( + $filename, + $content, + $itemToUseLockOf, + $lockOwner, + $publicWebDAVAPIVersion + ); + $this->featureContext->setResponse($response); + } + + /** + * @param string $filename + * @param string $content + * @param string $itemToUseLockOf + * @param string $lockOwner + * @param string $publicWebDAVAPIVersion + * + * @return ResponseInterface + */ + public function publicUploadWithUserLockToken( + string $filename, + string $content, + string $itemToUseLockOf, + string $lockOwner, + string $publicWebDAVAPIVersion + ): ResponseInterface { $lockOwner = $this->featureContext->getActualUsername($lockOwner); $headers = [ "If" => "(<" . $this->tokenOfLastLock[$lockOwner][$itemToUseLockOf] . ">)" ]; - $response = $this->publicWebDavContext->publicUploadContent( + return $this->publicWebDavContext->publicUploadContent( $filename, '', $content, @@ -843,7 +875,6 @@ class WebDavLockingContext implements Context { $headers, $publicWebDAVAPIVersion ); - $this->featureContext->setResponse($response); } /** @@ -863,13 +894,14 @@ class WebDavLockingContext implements Context { string $publicWebDAVAPIVersion ) { $lockOwner = $this->featureContext->getLastCreatedPublicShareToken(); - $this->publicUploadFileSendingLockTokenOfUser( + $response = $this->publicUploadWithUserLockToken( $filename, $content, $itemToUseLockOf, $lockOwner, $publicWebDAVAPIVersion ); + $this->featureContext->setResponse($response); } /**