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
@@ -252,7 +252,7 @@ class FavoritesContext implements Context {
*/ */
public function asUserFileOrFolderShouldBeFavorited(string $user, string $path, int $expectedValue = 1):void { public function asUserFileOrFolderShouldBeFavorited(string $user, string $path, int $expectedValue = 1):void {
$property = "oc:favorite"; $property = "oc:favorite";
$this->webDavPropertiesContext->asUserFolderShouldContainAPropertyWithValue( $this->webDavPropertiesContext->checkPropertyOfAFolder(
$user, $user,
$path, $path,
$property, $property,
@@ -3495,7 +3495,7 @@ class SpacesContext implements Context {
string $value string $value
):void { ):void {
$this->setSpaceIDByName($user, $spaceName); $this->setSpaceIDByName($user, $spaceName);
$this->webDavPropertiesContext->asUserFolderShouldContainAPropertyWithValue($user, $resourceName, $property, $value); $this->webDavPropertiesContext->checkPropertyOfAFolder($user, $resourceName, $property, $value);
} }
/** /**
@@ -25,7 +25,6 @@ use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\TableNode; use Behat\Gherkin\Node\TableNode;
use PHPUnit\Framework\Assert; use PHPUnit\Framework\Assert;
use TestHelpers\Asserts\WebDav as WebDavTest; use TestHelpers\Asserts\WebDav as WebDavTest;
use TestHelpers\HttpRequestHelper;
use TestHelpers\WebDavHelper; use TestHelpers\WebDavHelper;
use Psr\Http\Message\ResponseInterface; 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 * @Then the value of the item :xpath in the response about user :user should be :value
* *
* @param string $xpath * @param string $xpath
* @param string|null $user * @param string $user
* @param string $expectedValue * @param string $expectedValue
* *
* @return void * @return void
* @throws Exception * @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 { public function assertValueOfItemInResponseAboutUserIs(string $xpath, ?string $user, string $expectedValue):void {
$resXml = $this->featureContext->getResponseXml( $resXml = $this->featureContext->getResponseXml(
$this->featureContext->getResponse(), $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 "([^"]*)" or with value "([^"]*)"$/
* @Then /^as user "([^"]*)" (?:file|folder|entry) "([^"]*)" should contain a property "([^"]*)" with value "([^"]*)"$/
* *
* @param string $user * @param string $user
* @param string $path * @param string $path
@@ -912,7 +923,26 @@ class WebDavPropertiesContext implements Context {
string $path, string $path,
string $property, string $property,
string $expectedValue, 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 { ):void {
$response = $this->featureContext->listFolder( $response = $this->featureContext->listFolder(
$user, $user,
@@ -920,6 +950,9 @@ class WebDavPropertiesContext implements Context {
'0', '0',
[$property] [$property]
); );
if ($altExpectedValue === null) {
$altExpectedValue = $expectedValue;
}
$this->checkResponseContainsAPropertyWithValue( $this->checkResponseContainsAPropertyWithValue(
$response, $response,
$property, $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 * @Then the single response should contain a property :key with value like :regex
* *