remove the usage of a stepdef inside another stepdefin SpacesTUSContext.php (#9179)
This commit is contained in:
@@ -134,6 +134,33 @@ class SpacesTUSContext implements Context {
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads a file with content to the specified space using the TUS protocol via the WebDAV API.
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $content
|
||||
* @param string $resource
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception|GuzzleException
|
||||
*/
|
||||
private function uploadFileViaTus(string $user, string $content, string $resource, string $spaceName): void {
|
||||
$this->spacesContext->setSpaceIDByName($user, $spaceName);
|
||||
$tmpFile = $this->tusContext->writeDataToTempFile($content);
|
||||
try {
|
||||
$this->tusContext->uploadFileUsingTus(
|
||||
$user,
|
||||
\basename($tmpFile),
|
||||
$resource
|
||||
);
|
||||
$this->featureContext->setLastUploadDeleteTime(\time());
|
||||
} catch (Exception $e) {
|
||||
Assert::assertStringContainsString('Unable to create resource', (string)$e);
|
||||
}
|
||||
\unlink($tmpFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" uploads a file with content "([^"]*)" to "([^"]*)" via TUS inside of the space "([^"]*)" using the WebDAV API$/
|
||||
*
|
||||
@@ -151,19 +178,7 @@ class SpacesTUSContext implements Context {
|
||||
string $resource,
|
||||
string $spaceName
|
||||
): void {
|
||||
$this->spacesContext->setSpaceIDByName($user, $spaceName);
|
||||
$tmpFile = $this->tusContext->writeDataToTempFile($content);
|
||||
try {
|
||||
$this->tusContext->uploadFileUsingTus(
|
||||
$user,
|
||||
\basename($tmpFile),
|
||||
$resource
|
||||
);
|
||||
$this->featureContext->setLastUploadDeleteTime(\time());
|
||||
} catch (Exception $e) {
|
||||
Assert::assertStringContainsString('Unable to create resource', (string)$e);
|
||||
}
|
||||
\unlink($tmpFile);
|
||||
$this->uploadFileViaTus($user, $content, $resource, $spaceName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +198,7 @@ class SpacesTUSContext implements Context {
|
||||
string $resource,
|
||||
string $spaceName
|
||||
): void {
|
||||
$this->userUploadsAFileWithContentToViaTusInsideOfTheSpaceUsingTheWebdavApi($user, $content, $resource, $spaceName);
|
||||
$this->uploadFileViaTus($user, $content, $resource, $spaceName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user