removing SPACE_ID_FROM_OCIS from test code

This commit is contained in:
Niraj Acharya
2024-10-03 09:08:10 +05:45
parent 2c03dd0807
commit db844fb5ab
15 changed files with 249 additions and 130 deletions
+19 -16
View File
@@ -59,8 +59,8 @@ class SpacesTUSContext implements Context {
* @throws GuzzleException
*/
public function userHasUploadedFileViaTusInSpace(string $user, string $source, string $destination, string $spaceName): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$this->tusContext->uploadFileUsingTus($user, $source, $destination);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$this->tusContext->uploadFileUsingTus($user, $source, $destination, $spaceId);
$this->featureContext->setLastUploadDeleteTime(\time());
}
@@ -82,8 +82,8 @@ class SpacesTUSContext implements Context {
string $destination,
string $spaceName
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$this->tusContext->uploadFileUsingTus($user, $source, $destination);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$this->tusContext->uploadFileUsingTus($user, $source, $destination, $spaceId);
$this->featureContext->setLastUploadDeleteTime(\time());
}
@@ -106,8 +106,8 @@ class SpacesTUSContext implements Context {
string $content,
TableNode $headers
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$response = $this->tusContext->createNewTUSResourceWithHeaders($user, $headers, $content);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$response = $this->tusContext->createNewTUSResourceWithHeaders($user, $headers, $content, $spaceId);
$this->featureContext->theHTTPStatusCodeShouldBe(201, "Expected response status code should be 201", $response);
}
@@ -130,8 +130,8 @@ class SpacesTUSContext implements Context {
string $content,
TableNode $headers
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$response = $this->tusContext->createNewTUSResourceWithHeaders($user, $headers, $content);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$response = $this->tusContext->createNewTUSResourceWithHeaders($user, $headers, $content, $spaceId);
$this->featureContext->setResponse($response);
}
@@ -147,13 +147,14 @@ class SpacesTUSContext implements Context {
* @throws Exception|GuzzleException
*/
private function uploadFileViaTus(string $user, string $content, string $resource, string $spaceName): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$tmpFile = $this->tusContext->writeDataToTempFile($content);
try {
$this->tusContext->uploadFileUsingTus(
$user,
\basename($tmpFile),
$resource
$resource,
$spaceId
);
$this->featureContext->setLastUploadDeleteTime(\time());
} catch (Exception $e) {
@@ -241,7 +242,7 @@ class SpacesTUSContext implements Context {
break;
default:
}
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$mtime = new DateTime($mtime);
$mtime = $mtime->format('U');
$user = $this->featureContext->getActualUsername($user);
@@ -249,6 +250,7 @@ class SpacesTUSContext implements Context {
$user,
$source,
$destination,
$spaceId,
['mtime' => $mtime]
);
$this->featureContext->setLastUploadDeleteTime(\time());
@@ -297,7 +299,7 @@ class SpacesTUSContext implements Context {
string $content,
string $spaceName
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$response = $this->tusContext->sendsAChunkToTUSLocationWithOffsetAndData($user, $offset, $content, $checksum);
$this->featureContext->setResponse($response);
}
@@ -370,8 +372,8 @@ class SpacesTUSContext implements Context {
string $spaceName,
TableNode $headers
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$createResponse = $this->tusContext->createNewTUSResource($user, $headers);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$createResponse = $this->tusContext->createNewTUSResource($user, $headers, $spaceId);
$this->featureContext->theHTTPStatusCodeShouldBe(201, "", $createResponse);
$response = $this->tusContext->sendsAChunkToTUSLocationWithOffsetAndData($user, $offset, $data, $checksum);
$this->featureContext->setResponse($response);
@@ -394,7 +396,7 @@ class SpacesTUSContext implements Context {
string $spaceName,
string $mtime
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$mtime = new DateTime($mtime);
Assert::assertEquals(
$mtime->format('U'),
@@ -404,7 +406,8 @@ class SpacesTUSContext implements Context {
$this->featureContext->getBaseUrl(),
$resource,
$this->featureContext->getStepLineRef(),
$this->featureContext->getDavPathVersion()
$this->featureContext->getDavPathVersion(),
$spaceId,
)
);
}