Merge pull request #4535 from owncloud/reuseCodeFavorites

[full-ci][tests-only]Refactor and Reuse code from core
This commit is contained in:
Phil Davis
2022-09-09 13:56:42 +05:45
committed by GitHub
2 changed files with 19 additions and 47 deletions
@@ -3192,48 +3192,20 @@ class SpacesContext implements Context {
$this->featureContext->setResponseXmlObject($responseXml);
}
/**
* @Then /^as user "([^"]*)" (?:file|folder|entry|resource) "([^"]*)" inside space "([^"]*)" should contain a property "([^"]*)" with value "([^"]*)"$/
*
* @param string $user
* @param string $resourceName
* @param string $spaceName
* @param string $property
* @param string $expectedValue
*
* @return void
*
* @throws Exception|GuzzleException
*/
public function asUserFileInsideSpaceShouldContainAPropertyWithValue(
string $user,
string $resourceName,
string $spaceName,
string $property,
string $expectedValue
):void {
$space = $this->getSpaceByName($user, $spaceName);
$fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($resourceName, "/");
$body = WebDavHelper::getBodyForPropfind([$property]);
$headers['Depth'] = '1';
$this->featureContext->setResponse(
$this->sendPropfindRequestToUrl(
$fullUrl,
$user,
$this->featureContext->getPasswordForUser($user),
'',
$headers,
$body
)
);
$responseXml = $this->featureContext->getResponseXml(null, __METHOD__);
$this->featureContext->setResponseXmlObject($responseXml);
$this->webDavPropertiesContext->checkSingleResponseContainsAPropertyWithValueAndAlternative(
$property,
$expectedValue,
$expectedValue
);
}
/**
* @Then /^as user "([^"]*)" (?:file|folder|entry) "([^"]*)" inside space "([^"]*)" (should|should not) be favorited$/
*
* @param string $user
* @param string $path
* @param string $spaceName
* @param string $shouldOrNot
*
* @return void
*/
public function asUserFileOrFolderInsideSpaceShouldOrNotBeFavorited(string $user, string $path, string $spaceName, string $shouldOrNot):void {
$this->setSpaceIDByName($user, $spaceName);
$this->favoritesContext->asUserFileOrFolderShouldBeFavorited($user, $path, ($shouldOrNot === 'should') ? 1 : 0);
}
/**
* @When /^user "([^"]*)" favorites element "([^"]*)" in space "([^"]*)" using the WebDAV API$/