mirror of
https://github.com/owncloud/ocis
synced 2026-04-26 01:35:25 +02:00
test(refactor): refactor some scenarios to the original and step definition
This commit is contained in:
@@ -1624,7 +1624,7 @@ trait WebDav {
|
||||
* @param array|null $headers
|
||||
* @param int|null $noOfChunks Only use for chunked upload when $this->chunkingToUse is not null
|
||||
*
|
||||
* @return void
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function uploadFileWithHeaders(
|
||||
@@ -1633,25 +1633,27 @@ trait WebDav {
|
||||
string $destination,
|
||||
?array $headers = [],
|
||||
?int $noOfChunks = 0
|
||||
):void {
|
||||
try {
|
||||
$this->pauseUploadDelete();
|
||||
$this->response = UploadHelper::upload(
|
||||
$this->getBaseUrl(),
|
||||
$this->getActualUsername($user),
|
||||
$this->getUserPassword($user),
|
||||
$source,
|
||||
$destination,
|
||||
$this->getStepLineRef(),
|
||||
$headers,
|
||||
$this->getDavPathVersion(),
|
||||
$noOfChunks
|
||||
);
|
||||
$this->lastUploadDeleteTime = \time();
|
||||
} catch (BadResponseException $e) {
|
||||
// 4xx and 5xx responses cause an exception
|
||||
$this->response = $e->getResponse();
|
||||
): ResponseInterface {
|
||||
$doChunkUpload = true;
|
||||
if ($noOfChunks <= 0) {
|
||||
$doChunkUpload = false;
|
||||
}
|
||||
|
||||
$this->pauseUploadDelete();
|
||||
$response = UploadHelper::upload(
|
||||
$this->getBaseUrl(),
|
||||
$this->getActualUsername($user),
|
||||
$this->getUserPassword($user),
|
||||
$source,
|
||||
$destination,
|
||||
$this->getStepLineRef(),
|
||||
$headers,
|
||||
$this->getDavPathVersion(),
|
||||
$doChunkUpload,
|
||||
$noOfChunks,
|
||||
);
|
||||
$this->lastUploadDeleteTime = \time();
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1662,7 +1664,7 @@ trait WebDav {
|
||||
* @param boolean $async
|
||||
* @param array|null $headers
|
||||
*
|
||||
* @return void
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function userUploadsAFileInChunk(
|
||||
string $user,
|
||||
@@ -1671,7 +1673,7 @@ trait WebDav {
|
||||
int $noOfChunks = 2,
|
||||
bool $async = false,
|
||||
?array $headers = []
|
||||
):void {
|
||||
): ResponseInterface {
|
||||
$user = $this->getActualUsername($user);
|
||||
Assert::assertGreaterThan(
|
||||
0,
|
||||
@@ -1682,46 +1684,13 @@ trait WebDav {
|
||||
if ($async === true) {
|
||||
$headers['OC-LazyOps'] = 'true';
|
||||
}
|
||||
$this->uploadFileWithHeaders(
|
||||
return $this->uploadFileWithHeaders(
|
||||
$user,
|
||||
$this->acceptanceTestsDirLocation() . $source,
|
||||
$destination,
|
||||
$headers,
|
||||
$noOfChunks
|
||||
);
|
||||
$this->pushToLastStatusCodesArrays();
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploading with old/new DAV and chunked/non-chunked.
|
||||
* Except do not do the new-DAV-new-chunking combination. That is not being
|
||||
* supported on all implementations.
|
||||
*
|
||||
* @When user :user uploads file :source to filenames based on :destination with all mechanisms using the WebDAV API
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userUploadsAFileToWithAllMechanismsExceptNewChunking(
|
||||
string $user,
|
||||
string $source,
|
||||
string $destination
|
||||
):void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$this->uploadResponses = UploadHelper::uploadWithAllMechanisms(
|
||||
$this->getBaseUrl(),
|
||||
$this->getActualUsername($user),
|
||||
$this->getUserPassword($user),
|
||||
$this->acceptanceTestsDirLocation() . $source,
|
||||
$destination,
|
||||
$this->getStepLineRef(),
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1741,24 +1710,9 @@ trait WebDav {
|
||||
string $destination,
|
||||
int $noOfChunks = 2
|
||||
):void {
|
||||
$this->userUploadsAFileInChunk($user, $source, $destination, $noOfChunks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the HTTP status code of all upload responses should be "([^"]*)"$/
|
||||
*
|
||||
* @param int $statusCode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theHTTPStatusCodeOfAllUploadResponsesShouldBe(int $statusCode):void {
|
||||
foreach ($this->uploadResponses as $response) {
|
||||
Assert::assertEquals(
|
||||
$statusCode,
|
||||
$response->getStatusCode(),
|
||||
'Response did not return expected status code'
|
||||
);
|
||||
}
|
||||
$response = $this->userUploadsAFileInChunk($user, $source, $destination, $noOfChunks);
|
||||
$this->setResponse($response);
|
||||
$this->pushToLastStatusCodesArrays();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1950,32 +1904,6 @@ trait WebDav {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the HTTP status code of all upload responses should be between "(\d+)" and "(\d+)"$/
|
||||
*
|
||||
* @param int $minStatusCode
|
||||
* @param int $maxStatusCode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theHTTPStatusCodeOfAllUploadResponsesShouldBeBetween(
|
||||
int $minStatusCode,
|
||||
int $maxStatusCode
|
||||
):void {
|
||||
foreach ($this->uploadResponses as $response) {
|
||||
Assert::assertGreaterThanOrEqual(
|
||||
$minStatusCode,
|
||||
$response->getStatusCode(),
|
||||
'Response did not return expected status code'
|
||||
);
|
||||
Assert::assertLessThanOrEqual(
|
||||
$maxStatusCode,
|
||||
$response->getStatusCode(),
|
||||
'Response did not return expected status code'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user
|
||||
* @param string $destination
|
||||
@@ -2193,6 +2121,7 @@ trait WebDav {
|
||||
$this->getStepLineRef(),
|
||||
["X-OC-Mtime" => $mtime],
|
||||
$this->getDavPathVersion(),
|
||||
false,
|
||||
1,
|
||||
$isGivenStep
|
||||
);
|
||||
@@ -2227,6 +2156,7 @@ trait WebDav {
|
||||
$this->getStepLineRef(),
|
||||
["X-OC-Mtime" => $mtime],
|
||||
$this->getDavPathVersion(),
|
||||
false,
|
||||
1,
|
||||
true
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user