Reuse code from core

This commit is contained in:
sagargurung1001@gmail.com
2022-09-08 13:00:48 +05:45
parent 88a28ca8cd
commit 2115324aed

View File

@@ -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 = '<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:prop>
<oc:checksums />
</d:prop>
</d:propfind>';
$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);
}
/**