removing usage of a stepdefination inside another stepdefination in WebDavPropertiesContext (#8745)

This commit is contained in:
nirajacharya2
2024-04-17 16:50:33 +05:45
committed by GitHub
parent d1b0b9f05e
commit 8556318809
3 changed files with 38 additions and 31 deletions

View File

@@ -252,7 +252,7 @@ class FavoritesContext implements Context {
*/
public function asUserFileOrFolderShouldBeFavorited(string $user, string $path, int $expectedValue = 1):void {
$property = "oc:favorite";
$this->webDavPropertiesContext->asUserFolderShouldContainAPropertyWithValue(
$this->webDavPropertiesContext->checkPropertyOfAFolder(
$user,
$path,
$property,

View File

@@ -3495,7 +3495,7 @@ class SpacesContext implements Context {
string $value
):void {
$this->setSpaceIDByName($user, $spaceName);
$this->webDavPropertiesContext->asUserFolderShouldContainAPropertyWithValue($user, $resourceName, $property, $value);
$this->webDavPropertiesContext->checkPropertyOfAFolder($user, $resourceName, $property, $value);
}
/**

View File

@@ -25,7 +25,6 @@ use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\TableNode;
use PHPUnit\Framework\Assert;
use TestHelpers\Asserts\WebDav as WebDavTest;
use TestHelpers\HttpRequestHelper;
use TestHelpers\WebDavHelper;
use Psr\Http\Message\ResponseInterface;
@@ -610,12 +609,23 @@ class WebDavPropertiesContext implements Context {
* @Then the value of the item :xpath in the response about user :user should be :value
*
* @param string $xpath
* @param string|null $user
* @param string $user
* @param string $expectedValue
*
* @return void
* @throws Exception
*/
public function theValueOfTheItemInTheResponseAboutUserShouldBe(string $xpath, string $user, string $expectedValue):void {
$this->assertValueOfItemInResponseAboutUserIs($xpath, $user, $expectedValue);
}
/**
* @param string $xpath
* @param string|null $user
* @param string $expectedValue
*
* @return void
*/
public function assertValueOfItemInResponseAboutUserIs(string $xpath, ?string $user, string $expectedValue):void {
$resXml = $this->featureContext->getResponseXml(
$this->featureContext->getResponse(),
@@ -897,6 +907,7 @@ class WebDavPropertiesContext implements Context {
/**
* @Then /^as user "([^"]*)" (?:file|folder|entry) "([^"]*)" should contain a property "([^"]*)" with value "([^"]*)" or with value "([^"]*)"$/
* @Then /^as user "([^"]*)" (?:file|folder|entry) "([^"]*)" should contain a property "([^"]*)" with value "([^"]*)"$/
*
* @param string $user
* @param string $path
@@ -912,7 +923,26 @@ class WebDavPropertiesContext implements Context {
string $path,
string $property,
string $expectedValue,
string $altExpectedValue
?string $altExpectedValue = null
):void {
$this->checkPropertyOfAFolder($user, $path, $property, $expectedValue, $altExpectedValue);
}
/**
* @param string $user
* @param string $path
* @param string $property
* @param string $expectedValue
* @param string|null $altExpectedValue
*
* @return void
*/
public function checkPropertyOfAFolder(
string $user,
string $path,
string $property,
string $expectedValue,
?string $altExpectedValue = null
):void {
$response = $this->featureContext->listFolder(
$user,
@@ -920,6 +950,9 @@ class WebDavPropertiesContext implements Context {
'0',
[$property]
);
if ($altExpectedValue === null) {
$altExpectedValue = $expectedValue;
}
$this->checkResponseContainsAPropertyWithValue(
$response,
$property,
@@ -928,32 +961,6 @@ class WebDavPropertiesContext implements Context {
);
}
/**
* @Then /^as user "([^"]*)" (?:file|folder|entry) "([^"]*)" should contain a property "([^"]*)" with value "([^"]*)"$/
*
* @param string $user
* @param string $path
* @param string $property
* @param string $value
*
* @return void
* @throws Exception
*/
public function asUserFolderShouldContainAPropertyWithValue(
string $user,
string $path,
string $property,
string $value
):void {
$this->asUserFolderShouldContainAPropertyWithValueOrWithValue(
$user,
$path,
$property,
$value,
$value
);
}
/**
* @Then the single response should contain a property :key with value like :regex
*