Merge pull request #10680 from owncloud/remove-duplicated-method
[tests-only][full-ci]Remove duplicate function
This commit is contained in:
@@ -32,7 +32,7 @@ class WebDav extends Assert {
|
|||||||
*
|
*
|
||||||
* @param string|null $element exception|message|reason
|
* @param string|null $element exception|message|reason
|
||||||
* @param string|null $expectedValue
|
* @param string|null $expectedValue
|
||||||
* @param array|null $responseXml
|
* @param array|null $responseXmlArray
|
||||||
* @param string|null $extraErrorText
|
* @param string|null $extraErrorText
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -40,7 +40,7 @@ class WebDav extends Assert {
|
|||||||
public static function assertDavResponseElementIs(
|
public static function assertDavResponseElementIs(
|
||||||
?string $element,
|
?string $element,
|
||||||
?string $expectedValue,
|
?string $expectedValue,
|
||||||
?array $responseXml,
|
?array $responseXmlArray,
|
||||||
?string $extraErrorText = ''
|
?string $extraErrorText = ''
|
||||||
):void {
|
):void {
|
||||||
if ($extraErrorText !== '') {
|
if ($extraErrorText !== '') {
|
||||||
@@ -48,15 +48,15 @@ class WebDav extends Assert {
|
|||||||
}
|
}
|
||||||
self::assertArrayHasKey(
|
self::assertArrayHasKey(
|
||||||
'value',
|
'value',
|
||||||
$responseXml,
|
$responseXmlArray,
|
||||||
$extraErrorText . "responseXml does not have key 'value'"
|
$extraErrorText . "responseXml does not have key 'value'"
|
||||||
);
|
);
|
||||||
if ($element === "exception") {
|
if ($element === "exception") {
|
||||||
$result = $responseXml['value'][0]['value'];
|
$result = $responseXmlArray['value'][0]['value'];
|
||||||
} elseif ($element === "message") {
|
} elseif ($element === "message") {
|
||||||
$result = $responseXml['value'][1]['value'];
|
$result = $responseXmlArray['value'][1]['value'];
|
||||||
} elseif ($element === "reason") {
|
} elseif ($element === "reason") {
|
||||||
$result = $responseXml['value'][3]['value'];
|
$result = $responseXmlArray['value'][3]['value'];
|
||||||
} else {
|
} else {
|
||||||
self::fail(__METHOD__ . " element must be one of exception, response or reason. But '$element' was passed in.");
|
self::fail(__METHOD__ . " element must be one of exception, response or reason. But '$element' was passed in.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ use Psr\Http\Message\ResponseInterface;
|
|||||||
use PHPUnit\Framework\Assert;
|
use PHPUnit\Framework\Assert;
|
||||||
use TestHelpers\OcsApiHelper;
|
use TestHelpers\OcsApiHelper;
|
||||||
use TestHelpers\BehatHelper;
|
use TestHelpers\BehatHelper;
|
||||||
|
use TestHelpers\HttpRequestHelper;
|
||||||
|
|
||||||
require_once 'bootstrap.php';
|
require_once 'bootstrap.php';
|
||||||
|
|
||||||
@@ -213,9 +214,10 @@ class CapabilitiesContext implements Context {
|
|||||||
|
|
||||||
$response = $this->userGetsCapabilities($this->getAdminUsernameForCapabilitiesCheck());
|
$response = $this->userGetsCapabilities($this->getAdminUsernameForCapabilitiesCheck());
|
||||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
|
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||||
$responseXml = $this->featureContext->getResponseXml($response)->data->capabilities;
|
|
||||||
|
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__)->data->capabilities;
|
||||||
$edition = $this->getParameterValueFromXml(
|
$edition = $this->getParameterValueFromXml(
|
||||||
$responseXml,
|
$responseXmlObject,
|
||||||
'core',
|
'core',
|
||||||
'status@@@edition'
|
'status@@@edition'
|
||||||
);
|
);
|
||||||
@@ -227,7 +229,7 @@ class CapabilitiesContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$product = $this->getParameterValueFromXml(
|
$product = $this->getParameterValueFromXml(
|
||||||
$responseXml,
|
$responseXmlObject,
|
||||||
'core',
|
'core',
|
||||||
'status@@@product'
|
'status@@@product'
|
||||||
);
|
);
|
||||||
@@ -238,7 +240,7 @@ class CapabilitiesContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$productName = $this->getParameterValueFromXml(
|
$productName = $this->getParameterValueFromXml(
|
||||||
$responseXml,
|
$responseXmlObject,
|
||||||
'core',
|
'core',
|
||||||
'status@@@productname'
|
'status@@@productname'
|
||||||
);
|
);
|
||||||
@@ -256,7 +258,7 @@ class CapabilitiesContext implements Context {
|
|||||||
// We are on oCIS or reva or some other implementation. We cannot do "occ status".
|
// We are on oCIS or reva or some other implementation. We cannot do "occ status".
|
||||||
// So get the expected version values by looking in the capabilities response.
|
// So get the expected version values by looking in the capabilities response.
|
||||||
$version = $this->getParameterValueFromXml(
|
$version = $this->getParameterValueFromXml(
|
||||||
$responseXml,
|
$responseXmlObject,
|
||||||
'core',
|
'core',
|
||||||
'status@@@version'
|
'status@@@version'
|
||||||
);
|
);
|
||||||
@@ -268,7 +270,7 @@ class CapabilitiesContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$versionString = $this->getParameterValueFromXml(
|
$versionString = $this->getParameterValueFromXml(
|
||||||
$responseXml,
|
$responseXmlObject,
|
||||||
'core',
|
'core',
|
||||||
'status@@@versionstring'
|
'status@@@versionstring'
|
||||||
);
|
);
|
||||||
@@ -322,7 +324,7 @@ class CapabilitiesContext implements Context {
|
|||||||
Assert::assertStringStartsWith(
|
Assert::assertStringStartsWith(
|
||||||
$majorMinorPatchVersion,
|
$majorMinorPatchVersion,
|
||||||
$versionString,
|
$versionString,
|
||||||
"versionstring should start with $majorMinorPatchVersion but is $versionString"
|
"version string should start with $majorMinorPatchVersion but is $versionString"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,23 +148,23 @@ class CollaborationContext implements Context {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function createFile(string $file, string $password, string $folder = ""): void {
|
public function createFile(string $file, string $password, string $folder = ""): void {
|
||||||
$token = $this->featureContext->shareNgGetLastCreatedLinkShareToken();
|
$token = $this->featureContext->shareNgGetLastCreatedLinkShareToken();
|
||||||
$baseUrl = $this->featureContext->getBaseUrl();
|
$baseUrl = $this->featureContext->getBaseUrl();
|
||||||
$davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_NEW, $token, "public-files");
|
$davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_NEW, $token, "public-files");
|
||||||
$response = HttpRequestHelper::sendRequest(
|
|
||||||
"$baseUrl/$davPath/$folder",
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$this->featureContext->getStepLineRef(),
|
HttpRequestHelper::sendRequest(
|
||||||
"PROPFIND",
|
"$baseUrl/$davPath/$folder",
|
||||||
"public",
|
$this->featureContext->getStepLineRef(),
|
||||||
$this->featureContext->getActualPassword($password)
|
"PROPFIND",
|
||||||
|
"public",
|
||||||
|
$this->featureContext->getActualPassword($password)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$responseXml = HttpRequestHelper::getResponseXml(
|
$xmlPart = $responseXmlObject->xpath("//d:prop/oc:fileid");
|
||||||
$response,
|
|
||||||
__METHOD__
|
|
||||||
);
|
|
||||||
$xmlPart = $responseXml->xpath("//d:prop/oc:fileid");
|
|
||||||
$parentContainerId = (string) $xmlPart[0];
|
$parentContainerId = (string) $xmlPart[0];
|
||||||
|
|
||||||
$headers = [
|
$headers = [
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ use Swaggest\JsonSchema\Exception\NumericException;
|
|||||||
use Swaggest\JsonSchema\Exception\ObjectException;
|
use Swaggest\JsonSchema\Exception\ObjectException;
|
||||||
use Swaggest\JsonSchema\Exception\StringException;
|
use Swaggest\JsonSchema\Exception\StringException;
|
||||||
use Swaggest\JsonSchema\Exception\TypeException;
|
use Swaggest\JsonSchema\Exception\TypeException;
|
||||||
use Swaggest\JsonSchema\Exception\Error as JsonSchemaError;
|
|
||||||
|
|
||||||
require_once 'bootstrap.php';
|
require_once 'bootstrap.php';
|
||||||
|
|
||||||
@@ -998,11 +997,6 @@ class FeatureContext extends BehatVariablesContext {
|
|||||||
string $username = ""
|
string $username = ""
|
||||||
): void {
|
): void {
|
||||||
$this->response = $response;
|
$this->response = $response;
|
||||||
//after a new response reset the response xml
|
|
||||||
$this->responseXml = [];
|
|
||||||
//after a new response reset the response xml object
|
|
||||||
$this->responseXmlObject = null;
|
|
||||||
// remember the user that received the response
|
|
||||||
$this->responseUser = $username;
|
$this->responseUser = $username;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1032,26 +1026,6 @@ class FeatureContext extends BehatVariablesContext {
|
|||||||
return $previousServer;
|
return $previousServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses the response as XML
|
|
||||||
*
|
|
||||||
* @param ResponseInterface|null $response
|
|
||||||
* @param string|null $exceptionText text to put at the front of exception messages
|
|
||||||
*
|
|
||||||
* @return SimpleXMLElement
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function getResponseXml(?ResponseInterface $response = null, ?string $exceptionText = ''): SimpleXMLElement {
|
|
||||||
if ($response === null) {
|
|
||||||
$response = $this->response;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($exceptionText === '') {
|
|
||||||
$exceptionText = __METHOD__;
|
|
||||||
}
|
|
||||||
return HttpRequestHelper::getResponseXml($response, $exceptionText);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param JsonSchema $schemaObj
|
* @param JsonSchema $schemaObj
|
||||||
*
|
*
|
||||||
@@ -2611,30 +2585,6 @@ class FeatureContext extends BehatVariablesContext {
|
|||||||
return $this->acceptanceTestsDirLocation() . $this->temporaryStorageSubfolderName() . "/";
|
return $this->acceptanceTestsDirLocation() . $this->temporaryStorageSubfolderName() . "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse list of config keys from the given XML response
|
|
||||||
*
|
|
||||||
* @param SimpleXMLElement $responseXml
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function parseConfigListFromResponseXml(SimpleXMLElement $responseXml): array {
|
|
||||||
$configkeyData = \json_decode(\json_encode($responseXml->data), true);
|
|
||||||
if (isset($configkeyData['element'])) {
|
|
||||||
$configkeyData = $configkeyData['element'];
|
|
||||||
} else {
|
|
||||||
// There are no keys for the app
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
if (isset($configkeyData[0])) {
|
|
||||||
$configkeyValues = $configkeyData;
|
|
||||||
} else {
|
|
||||||
// There is just 1 key for the app
|
|
||||||
$configkeyValues[0] = $configkeyData;
|
|
||||||
}
|
|
||||||
return $configkeyValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will run before EVERY scenario.
|
* This will run before EVERY scenario.
|
||||||
* It will set the properties for this object.
|
* It will set the properties for this object.
|
||||||
|
|||||||
@@ -219,11 +219,11 @@ class FilesVersionsContext implements Context {
|
|||||||
$fileId = $this->featureContext->getFileIdForPath($user, $path);
|
$fileId = $this->featureContext->getFileIdForPath($user, $path);
|
||||||
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)");
|
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)");
|
||||||
$response = $this->listVersionFolder($user, $fileId, 1);
|
$response = $this->listVersionFolder($user, $fileId, 1);
|
||||||
$responseXml = HttpRequestHelper::getResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$response,
|
$response,
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
$xmlPart = $responseXml->xpath("//d:response/d:href");
|
$xmlPart = $responseXmlObject->xpath("//d:response/d:href");
|
||||||
//restoring the version only works with DAV path v2
|
//restoring the version only works with DAV path v2
|
||||||
$destinationUrl = $this->featureContext->getBaseUrl() . "/" .
|
$destinationUrl = $this->featureContext->getBaseUrl() . "/" .
|
||||||
WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_NEW, $user) . \trim($path, "/");
|
WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_NEW, $user) . \trim($path, "/");
|
||||||
@@ -281,18 +281,18 @@ class FilesVersionsContext implements Context {
|
|||||||
*/
|
*/
|
||||||
public function assertFileVersionsCount(string $user, string $fileId, int $expectedCount):void {
|
public function assertFileVersionsCount(string $user, string $fileId, int $expectedCount):void {
|
||||||
$response = $this->listVersionFolder($user, $fileId, 1);
|
$response = $this->listVersionFolder($user, $fileId, 1);
|
||||||
$responseXml = HttpRequestHelper::getResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$response,
|
$response,
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
$actualCount = \count($responseXml->xpath("//d:prop/d:getetag")) - 1;
|
$actualCount = \count($responseXmlObject->xpath("//d:prop/d:getetag")) - 1;
|
||||||
if ($actualCount === -1) {
|
if ($actualCount === -1) {
|
||||||
$actualCount = 0;
|
$actualCount = 0;
|
||||||
}
|
}
|
||||||
Assert::assertEquals(
|
Assert::assertEquals(
|
||||||
$expectedCount,
|
$expectedCount,
|
||||||
$actualCount,
|
$actualCount,
|
||||||
"Expected $expectedCount versions but found $actualCount in \n" . $responseXml->asXML()
|
"Expected $expectedCount versions but found $actualCount in \n" . $responseXmlObject->asXML()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,11 +356,11 @@ class FilesVersionsContext implements Context {
|
|||||||
$fileId = $this->featureContext->getFileIdForPath($user, $path);
|
$fileId = $this->featureContext->getFileIdForPath($user, $path);
|
||||||
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)");
|
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)");
|
||||||
$response = $this->listVersionFolder($user, $fileId, 1, ['d:getcontentlength']);
|
$response = $this->listVersionFolder($user, $fileId, 1, ['d:getcontentlength']);
|
||||||
$responseXml = HttpRequestHelper::getResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$response,
|
$response,
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
$xmlPart = $responseXml->xpath("//d:prop/d:getcontentlength");
|
$xmlPart = $responseXmlObject->xpath("//d:prop/d:getcontentlength");
|
||||||
Assert::assertEquals(
|
Assert::assertEquals(
|
||||||
$length,
|
$length,
|
||||||
(int) $xmlPart[$index],
|
(int) $xmlPart[$index],
|
||||||
@@ -422,8 +422,8 @@ class FilesVersionsContext implements Context {
|
|||||||
if ($response->getStatusCode() === 403) {
|
if ($response->getStatusCode() === 403) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$responseXml = new SimpleXMLElement($response->getBody()->getContents());
|
$responseXmlObject = new SimpleXMLElement($response->getBody()->getContents());
|
||||||
$xmlPart = $responseXml->xpath("//d:response/d:href");
|
$xmlPart = $responseXmlObject->xpath("//d:response/d:href");
|
||||||
if (!isset($xmlPart[$index])) {
|
if (!isset($xmlPart[$index])) {
|
||||||
Assert::fail(
|
Assert::fail(
|
||||||
'could not find version of path "' . $path . '" with index "' . $index . '"'
|
'could not find version of path "' . $path . '" with index "' . $index . '"'
|
||||||
@@ -519,11 +519,6 @@ class FilesVersionsContext implements Context {
|
|||||||
null
|
null
|
||||||
);
|
);
|
||||||
$this->featureContext->setResponse($response);
|
$this->featureContext->setResponse($response);
|
||||||
$responseXml = HttpRequestHelper::getResponseXml(
|
|
||||||
$response,
|
|
||||||
__METHOD__
|
|
||||||
);
|
|
||||||
$this->featureContext->setResponseXmlObject($responseXml);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ use Behat\Gherkin\Node\PyStringNode;
|
|||||||
use Behat\Gherkin\Node\TableNode;
|
use Behat\Gherkin\Node\TableNode;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use PHPUnit\Framework\Assert;
|
use PHPUnit\Framework\Assert;
|
||||||
|
use TestHelpers\HttpRequestHelper;
|
||||||
use TestHelpers\OcsApiHelper;
|
use TestHelpers\OcsApiHelper;
|
||||||
use TestHelpers\TranslationHelper;
|
use TestHelpers\TranslationHelper;
|
||||||
use TestHelpers\BehatHelper;
|
use TestHelpers\BehatHelper;
|
||||||
@@ -564,13 +565,11 @@ class OCSContext implements Context {
|
|||||||
return (string) $jsonResponse->ocs->meta->statuscode;
|
return (string) $jsonResponse->ocs->meta->statuscode;
|
||||||
}
|
}
|
||||||
// go to xml response when json response is null (it means not formatted and get status code)
|
// go to xml response when json response is null (it means not formatted and get status code)
|
||||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||||
if (isset($responseXml->meta[0], $responseXml->meta[0]->statuscode)) {
|
if (isset($responseXmlObject->meta[0], $responseXmlObject->meta[0]->statuscode)) {
|
||||||
return (string) $responseXml->meta[0]->statuscode;
|
return (string) $responseXmlObject->meta[0]->statuscode;
|
||||||
}
|
}
|
||||||
throw new Exception(
|
Assert::fail("No OCS status code found in response");
|
||||||
"No OCS status code found in response"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -582,13 +581,11 @@ class OCSContext implements Context {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function getOCSResponseData(ResponseInterface $response): SimpleXMLElement {
|
public function getOCSResponseData(ResponseInterface $response): SimpleXMLElement {
|
||||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||||
if (isset($responseXml->data)) {
|
if (isset($responseXmlObject->data)) {
|
||||||
return $responseXml->data;
|
return $responseXmlObject->data;
|
||||||
}
|
}
|
||||||
throw new Exception(
|
Assert::fail("No OCS data items found in response");
|
||||||
"No OCS data items found in responseXml"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -600,7 +597,7 @@ class OCSContext implements Context {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getOCSResponseStatusMessage(ResponseInterface $response):string {
|
public function getOCSResponseStatusMessage(ResponseInterface $response):string {
|
||||||
return (string) $this->featureContext->getResponseXml($response, __METHOD__)->meta[0]->message;
|
return (string) HttpRequestHelper::getResponseXml($response, __METHOD__)->meta[0]->message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1905,8 +1905,7 @@ trait Provisioning {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function getArrayOfUsersResponded(ResponseInterface $resp):array {
|
public function getArrayOfUsersResponded(ResponseInterface $resp):array {
|
||||||
$listCheckedElements
|
$listCheckedElements = HttpRequestHelper::getResponseXml($resp, __METHOD__)->data[0]->users[0]->element;
|
||||||
= $this->getResponseXml($resp, __METHOD__)->data[0]->users[0]->element;
|
|
||||||
return \json_decode(\json_encode($listCheckedElements), true);
|
return \json_decode(\json_encode($listCheckedElements), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1920,7 +1919,7 @@ trait Provisioning {
|
|||||||
*/
|
*/
|
||||||
public function getArrayOfGroupsResponded(ResponseInterface $resp):array {
|
public function getArrayOfGroupsResponded(ResponseInterface $resp):array {
|
||||||
$listCheckedElements
|
$listCheckedElements
|
||||||
= $this->getResponseXml($resp, __METHOD__)->data[0]->groups[0]->element;
|
= HttpRequestHelper::getResponseXml($resp, __METHOD__)->data[0]->groups[0]->element;
|
||||||
return \json_decode(\json_encode($listCheckedElements), true);
|
return \json_decode(\json_encode($listCheckedElements), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1933,8 +1932,7 @@ trait Provisioning {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function getArrayOfAppsResponded(ResponseInterface $resp):array {
|
public function getArrayOfAppsResponded(ResponseInterface $resp):array {
|
||||||
$listCheckedElements
|
$listCheckedElements = HttpRequestHelper::getResponseXml($resp, __METHOD__)->data[0]->apps[0]->element;
|
||||||
= $this->getResponseXml($resp, __METHOD__)->data[0]->apps[0]->element;
|
|
||||||
return \json_decode(\json_encode($listCheckedElements), true);
|
return \json_decode(\json_encode($listCheckedElements), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1945,7 +1943,7 @@ trait Provisioning {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function theApiShouldNotReturnAnyData():void {
|
public function theApiShouldNotReturnAnyData():void {
|
||||||
$responseData = $this->getResponseXml(null, __METHOD__)->data[0];
|
$responseData = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0];
|
||||||
Assert::assertEmpty(
|
Assert::assertEmpty(
|
||||||
$responseData,
|
$responseData,
|
||||||
"Response data is not empty but it should be empty"
|
"Response data is not empty but it should be empty"
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use Behat\Gherkin\Node\TableNode;
|
|||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use PHPUnit\Framework\Assert;
|
use PHPUnit\Framework\Assert;
|
||||||
use TestHelpers\BehatHelper;
|
use TestHelpers\BehatHelper;
|
||||||
|
use TestHelpers\HttpRequestHelper;
|
||||||
|
|
||||||
require_once 'bootstrap.php';
|
require_once 'bootstrap.php';
|
||||||
|
|
||||||
@@ -155,7 +156,7 @@ class ShareesContext implements Context {
|
|||||||
ResponseInterface $response,
|
ResponseInterface $response,
|
||||||
string $shareeType
|
string $shareeType
|
||||||
):array {
|
):array {
|
||||||
$elements = $this->featureContext->getResponseXml($response, __METHOD__)->data;
|
$elements = HttpRequestHelper::getResponseXml($response, __METHOD__)->data;
|
||||||
$elements = \json_decode(\json_encode($elements), true);
|
$elements = \json_decode(\json_encode($elements), true);
|
||||||
if (\strpos($shareeType, 'exact ') === 0) {
|
if (\strpos($shareeType, 'exact ') === 0) {
|
||||||
$elements = $elements['exact'];
|
$elements = $elements['exact'];
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ trait Sharing {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function getServerShareTimeFromLastResponse():int {
|
public function getServerShareTimeFromLastResponse():int {
|
||||||
$stime = $this->getResponseXml(null, __METHOD__)->xpath("//stime");
|
$stime = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->xpath("//stime");
|
||||||
if ($stime) {
|
if ($stime) {
|
||||||
return (int) $stime[0];
|
return (int) $stime[0];
|
||||||
}
|
}
|
||||||
@@ -921,13 +921,13 @@ trait Sharing {
|
|||||||
if (($response->getStatusCode() === 200)
|
if (($response->getStatusCode() === 200)
|
||||||
&& \in_array($this->ocsContext->getOCSResponseStatusCode($response), ['100', '200'])
|
&& \in_array($this->ocsContext->getOCSResponseStatusCode($response), ['100', '200'])
|
||||||
) {
|
) {
|
||||||
$xmlResponse = $this->getResponseXml($response);
|
$responseXmlObject = HttpRequestHelper::getResponseXml($response);
|
||||||
if (isset($xmlResponse->data)) {
|
if (isset($responseXmlObject->data)) {
|
||||||
$shareData = $xmlResponse->data;
|
$shareData = $responseXmlObject->data;
|
||||||
if ($shareType === 'public_link') {
|
if ($shareType === 'public_link') {
|
||||||
$this->addToCreatedPublicShares($shareData);
|
$this->addToCreatedPublicShares($shareData);
|
||||||
} else {
|
} else {
|
||||||
$sharer = (string) $xmlResponse->data->uid_owner;
|
$sharer = (string) $responseXmlObject->data->uid_owner;
|
||||||
$this->addToCreatedUserGroupshares($sharer, $shareData);
|
$this->addToCreatedUserGroupshares($sharer, $shareData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -981,7 +981,7 @@ trait Sharing {
|
|||||||
*/
|
*/
|
||||||
public function isFieldInResponse(string $field, ?string $contentExpected, bool $expectSuccess = true, ?SimpleXMLElement $data = null):bool {
|
public function isFieldInResponse(string $field, ?string $contentExpected, bool $expectSuccess = true, ?SimpleXMLElement $data = null):bool {
|
||||||
if ($data === null) {
|
if ($data === null) {
|
||||||
$data = $this->getResponseXml(null, __METHOD__)->data[0];
|
$data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0];
|
||||||
}
|
}
|
||||||
Assert::assertIsObject($data, __METHOD__ . " data not found in response XML");
|
Assert::assertIsObject($data, __METHOD__ . " data not found in response XML");
|
||||||
|
|
||||||
@@ -1053,7 +1053,7 @@ trait Sharing {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function checkNoFilesFoldersInResponse():void {
|
public function checkNoFilesFoldersInResponse():void {
|
||||||
$data = $this->getResponseXml(null, __METHOD__)->data[0];
|
$data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0];
|
||||||
Assert::assertIsObject($data, __METHOD__ . " data not found in response XML");
|
Assert::assertIsObject($data, __METHOD__ . " data not found in response XML");
|
||||||
Assert::assertCount(0, $data);
|
Assert::assertCount(0, $data);
|
||||||
}
|
}
|
||||||
@@ -1067,7 +1067,7 @@ trait Sharing {
|
|||||||
*/
|
*/
|
||||||
public function checkCountFilesFoldersInResponse(string $count):void {
|
public function checkCountFilesFoldersInResponse(string $count):void {
|
||||||
$count = (int) $count;
|
$count = (int) $count;
|
||||||
$data = $this->getResponseXml(null, __METHOD__)->data[0];
|
$data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0];
|
||||||
Assert::assertIsObject($data, __METHOD__ . " data not found in response XML");
|
Assert::assertIsObject($data, __METHOD__ . " data not found in response XML");
|
||||||
Assert::assertCount($count, $data, __METHOD__ . " the response does not contain $count entries");
|
Assert::assertCount($count, $data, __METHOD__ . " the response does not contain $count entries");
|
||||||
}
|
}
|
||||||
@@ -2212,7 +2212,7 @@ trait Sharing {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function responseShouldNotContainAnyShareIds(ResponseInterface $response):void {
|
public function responseShouldNotContainAnyShareIds(ResponseInterface $response):void {
|
||||||
$data = $this->getResponseXml($response, __METHOD__)->data[0];
|
$data = HttpRequestHelper::getResponseXml($response, __METHOD__)->data[0];
|
||||||
$fieldIsSet = false;
|
$fieldIsSet = false;
|
||||||
$receivedShareCount = 0;
|
$receivedShareCount = 0;
|
||||||
|
|
||||||
@@ -2275,7 +2275,7 @@ trait Sharing {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function checkingTheResponseEntriesCount(int $count):void {
|
public function checkingTheResponseEntriesCount(int $count):void {
|
||||||
$actualCount = \count($this->getResponseXml(null, __METHOD__)->data[0]);
|
$actualCount = \count(HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0]);
|
||||||
Assert::assertEquals(
|
Assert::assertEquals(
|
||||||
$count,
|
$count,
|
||||||
$actualCount,
|
$actualCount,
|
||||||
@@ -2305,7 +2305,7 @@ trait Sharing {
|
|||||||
*/
|
*/
|
||||||
public function checkTheFields(string $user, ?TableNode $body, ?ResponseInterface $response = null):void {
|
public function checkTheFields(string $user, ?TableNode $body, ?ResponseInterface $response = null):void {
|
||||||
$response = $response ?? $this->getResponse();
|
$response = $response ?? $this->getResponse();
|
||||||
$data = $this->getResponseXml($response, __METHOD__)->data[0];
|
$data = HttpRequestHelper::getResponseXml($response, __METHOD__)->data[0];
|
||||||
$this->verifyTableNodeColumnsCount($body, 2);
|
$this->verifyTableNodeColumnsCount($body, 2);
|
||||||
$bodyRows = $body->getRowsHash();
|
$bodyRows = $body->getRowsHash();
|
||||||
$userRelatedFieldNames = [
|
$userRelatedFieldNames = [
|
||||||
@@ -2359,7 +2359,7 @@ trait Sharing {
|
|||||||
"space_id"
|
"space_id"
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->getResponseXml(null, __METHOD__);
|
$response = HttpRequestHelper::getResponseXml($this->response, __METHOD__);
|
||||||
$this->addToCreatedPublicShares($response->data);
|
$this->addToCreatedPublicShares($response->data);
|
||||||
foreach ($bodyRows as $field => $value) {
|
foreach ($bodyRows as $field => $value) {
|
||||||
if (\in_array($field, $userRelatedFieldNames)) {
|
if (\in_array($field, $userRelatedFieldNames)) {
|
||||||
@@ -2440,7 +2440,7 @@ trait Sharing {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function theFieldsOfTheLastResponseShouldBeEmpty():void {
|
public function theFieldsOfTheLastResponseShouldBeEmpty():void {
|
||||||
$data = $this->getResponseXml(null, __METHOD__)->data[0];
|
$data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0];
|
||||||
Assert::assertEquals(
|
Assert::assertEquals(
|
||||||
\count($data->element),
|
\count($data->element),
|
||||||
0,
|
0,
|
||||||
@@ -2455,8 +2455,8 @@ trait Sharing {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function getSharingAttributesFromLastResponse():string {
|
public function getSharingAttributesFromLastResponse():string {
|
||||||
$responseXml = $this->getResponseXml(null, __METHOD__)->data[0];
|
$responseXmlObject = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0];
|
||||||
$actualAttributesElement = $responseXml->xpath('//attributes');
|
$actualAttributesElement = $responseXmlObject->xpath('//attributes');
|
||||||
|
|
||||||
if ($actualAttributesElement) {
|
if ($actualAttributesElement) {
|
||||||
$actualAttributes = (array) $actualAttributesElement[0];
|
$actualAttributes = (array) $actualAttributesElement[0];
|
||||||
@@ -2543,7 +2543,7 @@ trait Sharing {
|
|||||||
public function userDownloadsFailWithMessage(string $fileName, string $user, PyStringNode $errorMessage):void {
|
public function userDownloadsFailWithMessage(string $fileName, string $user, PyStringNode $errorMessage):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$response = $this->downloadFileAsUserUsingPassword($user, $fileName);
|
$response = $this->downloadFileAsUserUsingPassword($user, $fileName);
|
||||||
$receivedErrorMessage = $this->getResponseXml($response, __METHOD__)->xpath('//s:message');
|
$receivedErrorMessage = HttpRequestHelper::getResponseXml($response, __METHOD__)->xpath('//s:message');
|
||||||
Assert::assertEquals(
|
Assert::assertEquals(
|
||||||
$errorMessage,
|
$errorMessage,
|
||||||
(string) $receivedErrorMessage[0],
|
(string) $receivedErrorMessage[0],
|
||||||
@@ -2600,7 +2600,7 @@ trait Sharing {
|
|||||||
[],
|
[],
|
||||||
$this->ocsApiVersion
|
$this->ocsApiVersion
|
||||||
);
|
);
|
||||||
return $this->getResponseXml($response, __METHOD__)->data->element;
|
return HttpRequestHelper::getResponseXml($response, __METHOD__)->data->element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -129,29 +129,6 @@ class SpacesContext implements Context {
|
|||||||
$this->availableSpaces = $availableSpaces;
|
$this->availableSpaces = $availableSpaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* response content parsed from XML to an array
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private array $responseXml = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getResponseXml(): array {
|
|
||||||
return $this->responseXml;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $responseXml
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setResponseXml(array $responseXml): void {
|
|
||||||
$this->responseXml = $responseXml;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get SpaceId by Name
|
* Get SpaceId by Name
|
||||||
*
|
*
|
||||||
@@ -369,8 +346,8 @@ class SpacesContext implements Context {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->featureContext->theHttpStatusCodeShouldBe(207, '', $response);
|
$this->featureContext->theHttpStatusCodeShouldBe(207, '', $response);
|
||||||
$xmlResponse = $this->featureContext->getResponseXml($response);
|
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||||
$fileId = $xmlResponse->xpath("//d:response/d:propstat/d:prop/oc:fileid")[0];
|
$fileId = $responseXmlObject->xpath("//d:response/d:propstat/d:prop/oc:fileid")[0];
|
||||||
return $fileId->__toString();
|
return $fileId->__toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,7 +373,7 @@ class SpacesContext implements Context {
|
|||||||
"files",
|
"files",
|
||||||
WebDavHelper::DAV_VERSION_SPACES
|
WebDavHelper::DAV_VERSION_SPACES
|
||||||
);
|
);
|
||||||
$responseArray = json_decode(json_encode($this->featureContext->getResponseXml($response)->xpath("//d:response/d:propstat/d:prop/oc:privatelink")), true, 512, JSON_THROW_ON_ERROR);
|
$responseArray = json_decode(json_encode(HttpRequestHelper::getResponseXml($response, __METHOD__)->xpath("//d:response/d:propstat/d:prop/oc:privatelink")), true, 512, JSON_THROW_ON_ERROR);
|
||||||
Assert::assertNotEmpty($responseArray, "the PROPFIND response for $spaceName is empty");
|
Assert::assertNotEmpty($responseArray, "the PROPFIND response for $spaceName is empty");
|
||||||
return $responseArray[0][0];
|
return $responseArray[0][0];
|
||||||
}
|
}
|
||||||
@@ -2424,9 +2401,9 @@ class SpacesContext implements Context {
|
|||||||
$body,
|
$body,
|
||||||
$this->featureContext->getStepLineRef()
|
$this->featureContext->getStepLineRef()
|
||||||
);
|
);
|
||||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||||
$sharer = (string) $responseXml->data->uid_owner;
|
$sharer = (string) $responseXmlObject->data->uid_owner;
|
||||||
$this->featureContext->addToCreatedUserGroupshares($sharer, $responseXml->data);
|
$this->featureContext->addToCreatedUserGroupshares($sharer, $responseXmlObject->data);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2587,8 +2564,8 @@ class SpacesContext implements Context {
|
|||||||
$this->featureContext->getStepLineRef()
|
$this->featureContext->getStepLineRef()
|
||||||
);
|
);
|
||||||
|
|
||||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||||
$this->featureContext->addToCreatedPublicShares($responseXml->data);
|
$this->featureContext->addToCreatedPublicShares($responseXmlObject->data);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3101,7 +3078,7 @@ class SpacesContext implements Context {
|
|||||||
$response
|
$response
|
||||||
);
|
);
|
||||||
return $this->trashbinContext->getTrashbinContentFromResponseXml(
|
return $this->trashbinContext->getTrashbinContentFromResponseXml(
|
||||||
$this->featureContext->getResponseXml($response)
|
HttpRequestHelper::getResponseXml($response, __METHOD__)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3572,8 +3549,7 @@ class SpacesContext implements Context {
|
|||||||
$this->featureContext->getStepLineRef()
|
$this->featureContext->getStepLineRef()
|
||||||
);
|
);
|
||||||
|
|
||||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
$this->featureContext->addToCreatedPublicShares(HttpRequestHelper::getResponseXml($response, __METHOD__)->data);
|
||||||
$this->featureContext->addToCreatedPublicShares($responseXml->data);
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3663,7 +3639,7 @@ class SpacesContext implements Context {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$should = ($shouldOrNot !== "not");
|
$should = ($shouldOrNot !== "not");
|
||||||
$responseArray = json_decode(json_encode($this->featureContext->getResponseXml($response)->data), true, 512, JSON_THROW_ON_ERROR);
|
$responseArray = json_decode(json_encode(HttpRequestHelper::getResponseXml($response, __METHOD__)->data), true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
|
||||||
if ($should) {
|
if ($should) {
|
||||||
Assert::assertNotEmpty($responseArray, __METHOD__ . ' Response should contain a link, but it is empty');
|
Assert::assertNotEmpty($responseArray, __METHOD__ . ' Response should contain a link, but it is empty');
|
||||||
@@ -3837,7 +3813,7 @@ class SpacesContext implements Context {
|
|||||||
*/
|
*/
|
||||||
public function searchResultShouldContainSpace(string $user, string $spaceName): void {
|
public function searchResultShouldContainSpace(string $user, string $spaceName): void {
|
||||||
// get a response after a Report request (called in the core)
|
// get a response after a Report request (called in the core)
|
||||||
$responseArray = json_decode(json_encode($this->featureContext->getResponseXml()->xpath("//d:response/d:href")), true, 512, JSON_THROW_ON_ERROR);
|
$responseArray = json_decode(json_encode(HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath("//d:response/d:href")), true, 512, JSON_THROW_ON_ERROR);
|
||||||
Assert::assertNotEmpty($responseArray, "search result is empty");
|
Assert::assertNotEmpty($responseArray, "search result is empty");
|
||||||
|
|
||||||
// for mountpoint, id looks a little different than for project space
|
// for mountpoint, id looks a little different than for project space
|
||||||
@@ -4024,16 +4000,16 @@ class SpacesContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $resource // can be resource name, space id or file id
|
* @param string $resource // can be resource name, space id or file id
|
||||||
* @param array $properties // ["key" => "value"]
|
* @param array $properties // ["key" => "value"]
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function theXMLResponseShouldContain(string $resource, array $properties): void {
|
public function theXMLResponseShouldContain(string $resource, array $properties): void {
|
||||||
$xmlResponse = $this->featureContext->getResponseXml();
|
$responseXmlObject = HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__);
|
||||||
$hrefs = array_map(fn ($href) => $href->__toString(), $xmlResponse->xpath("//d:response/d:href"));
|
$hrefs = array_map(fn ($href) => $href->__toString(), $responseXmlObject->xpath("//d:response/d:href"));
|
||||||
|
|
||||||
$currentHref = '';
|
$currentHref = '';
|
||||||
foreach ($hrefs as $href) {
|
foreach ($hrefs as $href) {
|
||||||
@@ -4069,14 +4045,14 @@ class SpacesContext implements Context {
|
|||||||
// check every xpath
|
// check every xpath
|
||||||
foreach ($xpaths as $key => $path) {
|
foreach ($xpaths as $key => $path) {
|
||||||
$xpath = "{$path}{$itemToFind}";
|
$xpath = "{$path}{$itemToFind}";
|
||||||
$foundXmlItem = $xmlResponse->xpath($xpath);
|
$foundXmlItem = $responseXmlObject->xpath($xpath);
|
||||||
$xpaths[$key] = $xpath;
|
$xpaths[$key] = $xpath;
|
||||||
if (\count($foundXmlItem)) {
|
if (\count($foundXmlItem)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$foundXmlItem = $xmlResponse->xpath($xpath);
|
$foundXmlItem = $responseXmlObject->xpath($xpath);
|
||||||
$xpaths[] = $xpath;
|
$xpaths[] = $xpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4086,7 +4062,7 @@ class SpacesContext implements Context {
|
|||||||
"Using xpaths:\n\t- " . \join("\n\t- ", $xpaths)
|
"Using xpaths:\n\t- " . \join("\n\t- ", $xpaths)
|
||||||
. "\n"
|
. "\n"
|
||||||
. "Could not find '<$itemToFind>' element in the XML response\n\t"
|
. "Could not find '<$itemToFind>' element in the XML response\n\t"
|
||||||
. "'" . \trim($xmlResponse->asXML()) . "'"
|
. "'" . \trim($responseXmlObject->asXML()) . "'"
|
||||||
);
|
);
|
||||||
|
|
||||||
$actualValue = $foundXmlItem[0]->__toString();
|
$actualValue = $foundXmlItem[0]->__toString();
|
||||||
@@ -4151,8 +4127,8 @@ class SpacesContext implements Context {
|
|||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function asUserTheKeyFromPropfindResponseShouldMatchWithSharedwithmeDriveitemidOfShare(string $user, string $key, string $resource): void {
|
public function asUserTheKeyFromPropfindResponseShouldMatchWithSharedwithmeDriveitemidOfShare(string $user, string $key, string $resource): void {
|
||||||
$xmlResponse = $this->featureContext->getResponseXml();
|
$responseXmlObject = HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__);
|
||||||
$fileId = $xmlResponse->xpath("//oc:name[text()='$resource']/preceding-sibling::$key")[0]->__toString();
|
$fileId = $responseXmlObject->xpath("//oc:name[text()='$resource']/preceding-sibling::$key")[0]->__toString();
|
||||||
|
|
||||||
$jsonResponse = GraphHelper::getSharesSharedWithMe(
|
$jsonResponse = GraphHelper::getSharesSharedWithMe(
|
||||||
$this->featureContext->getBaseUrl(),
|
$this->featureContext->getBaseUrl(),
|
||||||
@@ -4179,25 +4155,30 @@ class SpacesContext implements Context {
|
|||||||
* @param string $resource
|
* @param string $resource
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws GuzzleException|JsonException
|
* @throws GuzzleException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function publicDownloadsTheFolderFromTheLastCreatedPublicLink(string $resource) {
|
public function publicDownloadsTheFolderFromTheLastCreatedPublicLink(string $resource) {
|
||||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||||
$response = $this->featureContext->listFolderAndReturnResponseXml(
|
|
||||||
$token,
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$resource,
|
$this->featureContext->listFolder(
|
||||||
'0',
|
$token,
|
||||||
['oc:fileid'],
|
$resource,
|
||||||
"public-files"
|
'0',
|
||||||
|
['oc:fileid'],
|
||||||
|
null,
|
||||||
|
"public-files"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$resourceId = json_decode(json_encode($response->xpath("//d:response/d:propstat/d:prop/oc:fileid")), true, 512, JSON_THROW_ON_ERROR);
|
$resourceId = $responseXmlObject->xpath("//d:response/d:propstat/d:prop/oc:fileid");
|
||||||
$queryString = 'public-token=' . $token . '&id=' . $resourceId[0][0];
|
$queryString = 'public-token=' . $token . '&id=' . $resourceId[0][0];
|
||||||
$this->featureContext->setResponse(
|
$this->featureContext->setResponse(
|
||||||
HttpRequestHelper::get(
|
HttpRequestHelper::get(
|
||||||
$this->archiverContext->getArchiverUrl($queryString),
|
$this->archiverContext->getArchiverUrl($queryString),
|
||||||
$this->featureContext->getStepLineRef(),
|
$this->featureContext->getStepLineRef(),
|
||||||
'',
|
'',
|
||||||
'',
|
''
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -4218,11 +4199,9 @@ class SpacesContext implements Context {
|
|||||||
$quotaAmount,
|
$quotaAmount,
|
||||||
"Expected relative quota amount to be $quotaAmount but found to be $data->quota->relative"
|
"Expected relative quota amount to be $quotaAmount but found to be $data->quota->relative"
|
||||||
);
|
);
|
||||||
} else {
|
return;
|
||||||
throw new Exception(
|
|
||||||
"No relative quota amount found in responseXml"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
Assert::fail("No relative quota amount found in response");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,12 +85,12 @@ class TrashbinContext implements Context {
|
|||||||
/**
|
/**
|
||||||
* Get files list from the response from trashbin api
|
* Get files list from the response from trashbin api
|
||||||
*
|
*
|
||||||
* @param SimpleXMLElement|null $responseXml
|
* @param SimpleXMLElement|null $responseXmlObject
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getTrashbinContentFromResponseXml(?SimpleXMLElement $responseXml): array {
|
public function getTrashbinContentFromResponseXml(?SimpleXMLElement $responseXmlObject): array {
|
||||||
$xmlElements = $responseXml->xpath('//d:response');
|
$xmlElements = $responseXmlObject->xpath('//d:response');
|
||||||
$files = \array_map(
|
$files = \array_map(
|
||||||
static function (SimpleXMLElement $element) {
|
static function (SimpleXMLElement $element) {
|
||||||
$href = $element->xpath('./d:href')[0];
|
$href = $element->xpath('./d:href')[0];
|
||||||
@@ -178,13 +178,13 @@ class TrashbinContext implements Context {
|
|||||||
$davPathVersion
|
$davPathVersion
|
||||||
);
|
);
|
||||||
$this->featureContext->setResponse($response);
|
$this->featureContext->setResponse($response);
|
||||||
$responseXml = HttpRequestHelper::getResponseXml(
|
|
||||||
$response,
|
|
||||||
__METHOD__
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->featureContext->setResponseXmlObject($responseXml);
|
$files = $this->getTrashbinContentFromResponseXml(
|
||||||
$files = $this->getTrashbinContentFromResponseXml($responseXml);
|
HttpRequestHelper::getResponseXml(
|
||||||
|
$response,
|
||||||
|
__METHOD__
|
||||||
|
)
|
||||||
|
);
|
||||||
// filter root element
|
// filter root element
|
||||||
$files = \array_filter(
|
$files = \array_filter(
|
||||||
$files,
|
$files,
|
||||||
@@ -253,13 +253,13 @@ class TrashbinContext implements Context {
|
|||||||
$respBody = $response->getBody()->getContents();
|
$respBody = $response->getBody()->getContents();
|
||||||
Assert::assertEquals("207", $statusCode, "Expected status code to be '207' but got $statusCode \nResponse\n$respBody");
|
Assert::assertEquals("207", $statusCode, "Expected status code to be '207' but got $statusCode \nResponse\n$respBody");
|
||||||
|
|
||||||
$responseXml = HttpRequestHelper::getResponseXml(
|
$files = $this->getTrashbinContentFromResponseXml(
|
||||||
$response,
|
HttpRequestHelper::getResponseXml(
|
||||||
__METHOD__ . " $collectionPath"
|
$response,
|
||||||
|
__METHOD__ . " $collectionPath"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$files = $this->getTrashbinContentFromResponseXml($responseXml);
|
|
||||||
|
|
||||||
$suffixPath = $user;
|
$suffixPath = $user;
|
||||||
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
|
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
|
||||||
$suffixPath = WebDavHelper::getPersonalSpaceIdForUser(
|
$suffixPath = WebDavHelper::getPersonalSpaceIdForUser(
|
||||||
@@ -345,8 +345,7 @@ class TrashbinContext implements Context {
|
|||||||
*/
|
*/
|
||||||
public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $table):void {
|
public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $table):void {
|
||||||
$this->featureContext->verifyTableNodeColumns($table, ['name']);
|
$this->featureContext->verifyTableNodeColumns($table, ['name']);
|
||||||
$responseXml = $this->featureContext->getResponseXml();
|
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__));
|
||||||
$files = $this->getTrashbinContentFromResponseXml($responseXml);
|
|
||||||
|
|
||||||
foreach ($table->getHash() as $row) {
|
foreach ($table->getHash() as $row) {
|
||||||
$path = trim((string)$row['name'], "/");
|
$path = trim((string)$row['name'], "/");
|
||||||
@@ -368,9 +367,8 @@ class TrashbinContext implements Context {
|
|||||||
*/
|
*/
|
||||||
public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table):void {
|
public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table):void {
|
||||||
$this->featureContext->verifyTableNodeColumns($table, ['name']);
|
$this->featureContext->verifyTableNodeColumns($table, ['name']);
|
||||||
$responseXml = $this->featureContext->getResponseXml();
|
|
||||||
|
|
||||||
$files = $this->getTrashbinContentFromResponseXml($responseXml);
|
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__));
|
||||||
|
|
||||||
foreach ($table->getHash() as $row) {
|
foreach ($table->getHash() as $row) {
|
||||||
$path = trim($row['name'], "/");
|
$path = trim($row['name'], "/");
|
||||||
@@ -460,7 +458,7 @@ class TrashbinContext implements Context {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function theLastWebdavResponseShouldContainFollowingElements(TableNode $elements):void {
|
public function theLastWebdavResponseShouldContainFollowingElements(TableNode $elements):void {
|
||||||
$files = $this->getTrashbinContentFromResponseXml($this->featureContext->getResponseXml());
|
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($response, __METHOD__));
|
||||||
$elementRows = $elements->getHash();
|
$elementRows = $elements->getHash();
|
||||||
foreach ($elementRows as $expectedElement) {
|
foreach ($elementRows as $expectedElement) {
|
||||||
$found = false;
|
$found = false;
|
||||||
@@ -484,7 +482,7 @@ class TrashbinContext implements Context {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function theLastWebdavResponseShouldNotContainFollowingElements(TableNode $elements):void {
|
public function theLastWebdavResponseShouldNotContainFollowingElements(TableNode $elements):void {
|
||||||
$files = $this->getTrashbinContentFromResponseXml($this->featureContext->getResponseXml());
|
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse()));
|
||||||
|
|
||||||
// 'user' is also allowed in the table even though it is not used anywhere
|
// 'user' is also allowed in the table even though it is not used anywhere
|
||||||
// This for better readability in feature files
|
// This for better readability in feature files
|
||||||
@@ -869,44 +867,29 @@ class TrashbinContext implements Context {
|
|||||||
* @param $user string
|
* @param $user string
|
||||||
* @param $originalPath string
|
* @param $originalPath string
|
||||||
*
|
*
|
||||||
* @return ResponseInterface
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function userRestoresResourceWithOriginalPathWithoutSpecifyingDestinationUsingTrashbinApi(string $user, string $originalPath):ResponseInterface {
|
public function userRestoresResourceWithOriginalPathWithoutSpecifyingDestinationUsingTrashbinApi(string $user, string $originalPath):void {
|
||||||
$asUser = $asUser ?? $user;
|
|
||||||
$listing = $this->listTrashbinFolder($user);
|
$listing = $this->listTrashbinFolder($user);
|
||||||
$originalPath = \trim($originalPath, '/');
|
$originalPath = \trim($originalPath, '/');
|
||||||
|
|
||||||
foreach ($listing as $entry) {
|
foreach ($listing as $entry) {
|
||||||
if ($entry['original-location'] === $originalPath) {
|
if ($entry['original-location'] === $originalPath) {
|
||||||
$trashItemHRef = $this->convertTrashbinHref($entry['href']);
|
$trashItemHRef = $this->convertTrashbinHref($entry['href']);
|
||||||
$response = $this->featureContext->makeDavRequest(
|
$this->featureContext->setResponse(
|
||||||
$asUser,
|
$this->featureContext->makeDavRequest(
|
||||||
'MOVE',
|
$user,
|
||||||
$trashItemHRef,
|
'MOVE',
|
||||||
[],
|
$trashItemHRef,
|
||||||
null,
|
[],
|
||||||
null,
|
null,
|
||||||
'trash-bin'
|
null,
|
||||||
|
'trash-bin'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$this->featureContext->setResponse($response);
|
|
||||||
// this gives empty response in ocis
|
|
||||||
try {
|
|
||||||
$responseXml = HttpRequestHelper::getResponseXml(
|
|
||||||
$response,
|
|
||||||
__METHOD__
|
|
||||||
);
|
|
||||||
$this->featureContext->setResponseXmlObject($responseXml);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new \Exception(
|
|
||||||
__METHOD__
|
|
||||||
. " cannot restore from trashbin because no element was found for user $user at original path $originalPath"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1150,7 +1133,7 @@ class TrashbinContext implements Context {
|
|||||||
*/
|
*/
|
||||||
public function theDeletedFileFolderShouldHaveCorrectDeletionMtimeInTheResponse(string $resource):void {
|
public function theDeletedFileFolderShouldHaveCorrectDeletionMtimeInTheResponse(string $resource):void {
|
||||||
$files = $this->getTrashbinContentFromResponseXml(
|
$files = $this->getTrashbinContentFromResponseXml(
|
||||||
$this->featureContext->getResponseXml()
|
HttpRequestHelper::getResponseXml($this->featureContext->getResponse())
|
||||||
);
|
);
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|||||||
@@ -53,11 +53,6 @@ trait WebDav {
|
|||||||
|
|
||||||
private ?int $lastUploadDeleteTime = null;
|
private ?int $lastUploadDeleteTime = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* response content parsed from XML to an array
|
|
||||||
*/
|
|
||||||
private array $responseXml = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add resource created by admin in an array
|
* add resource created by admin in an array
|
||||||
* This array is used while cleaning up the resource created by admin during test run
|
* This array is used while cleaning up the resource created by admin during test run
|
||||||
@@ -140,22 +135,6 @@ trait WebDav {
|
|||||||
return $this->lastUploadDeleteTime;
|
return $this->lastUploadDeleteTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SimpleXMLElement $responseXmlObject
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setResponseXmlObject(SimpleXMLElement $responseXmlObject):void {
|
|
||||||
$this->responseXmlObject = $responseXmlObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function clearResponseXmlObject():void {
|
|
||||||
$this->responseXmlObject = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $fileID
|
* @param string $fileID
|
||||||
*
|
*
|
||||||
@@ -178,7 +157,7 @@ trait WebDav {
|
|||||||
* @return string the etag or an empty string if the getetag property does not exist
|
* @return string the etag or an empty string if the getetag property does not exist
|
||||||
*/
|
*/
|
||||||
public function getEtagFromResponseXmlObject(?SimpleXMLElement $xmlObject = null): string {
|
public function getEtagFromResponseXmlObject(?SimpleXMLElement $xmlObject = null): string {
|
||||||
$xmlObject = $xmlObject ?? $this->getResponseXml();
|
$xmlObject = $xmlObject ?? HttpRequestHelper::getResponseXml($this->getResponse());
|
||||||
$xmlPart = $xmlObject->xpath("//d:prop/d:getetag");
|
$xmlPart = $xmlObject->xpath("//d:prop/d:getetag");
|
||||||
if (!\is_array($xmlPart) || (\count($xmlPart) === 0)) {
|
if (!\is_array($xmlPart) || (\count($xmlPart) === 0)) {
|
||||||
return '';
|
return '';
|
||||||
@@ -201,15 +180,6 @@ trait WebDav {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $responseXml
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setResponseXml(array $responseXml):void {
|
|
||||||
$this->responseXml = $responseXml;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^using (old|new|spaces) DAV path$/
|
* @Given /^using (old|new|spaces) DAV path$/
|
||||||
*
|
*
|
||||||
@@ -444,15 +414,8 @@ trait WebDav {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function theNumberOfVersionsShouldBe(int $number):void {
|
public function theNumberOfVersionsShouldBe(int $number):void {
|
||||||
$resXml = $this->getResponseXml();
|
$responseXmlObject = HttpRequestHelper::getResponseXml($this->getResponse(), __METHOD__);
|
||||||
if ($resXml === null) {
|
$xmlPart = $responseXmlObject->xpath("//d:getlastmodified");
|
||||||
$resXml = HttpRequestHelper::getResponseXml(
|
|
||||||
$this->getResponse(),
|
|
||||||
__METHOD__
|
|
||||||
);
|
|
||||||
$this->setResponseXmlObject($resXml);
|
|
||||||
}
|
|
||||||
$xmlPart = $resXml->xpath("//d:getlastmodified");
|
|
||||||
$actualNumber = \count($xmlPart);
|
$actualNumber = \count($xmlPart);
|
||||||
Assert::assertEquals(
|
Assert::assertEquals(
|
||||||
$number,
|
$number,
|
||||||
@@ -470,14 +433,8 @@ trait WebDav {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function theNumberOfEtagElementInTheResponseShouldBe(int $number):void {
|
public function theNumberOfEtagElementInTheResponseShouldBe(int $number):void {
|
||||||
$resXml = $this->getResponseXml();
|
$responseXmlObject = HttpRequestHelper::getResponseXml($this->getResponse());
|
||||||
if ($resXml === null) {
|
$xmlPart = $responseXmlObject->xpath("//d:getetag");
|
||||||
$resXml = HttpRequestHelper::getResponseXml(
|
|
||||||
$this->getResponse(),
|
|
||||||
__METHOD__
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$xmlPart = $resXml->xpath("//d:getetag");
|
|
||||||
$actualNumber = \count($xmlPart);
|
$actualNumber = \count($xmlPart);
|
||||||
Assert::assertEquals(
|
Assert::assertEquals(
|
||||||
$number,
|
$number,
|
||||||
@@ -974,8 +931,7 @@ trait WebDav {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function contentOfFileForUserShouldBe(string $fileName, string $user, string $content):void {
|
public function contentOfFileForUserShouldBe(string $fileName, string $user, string $content):void {
|
||||||
$user = $this->getActualUsername($user);
|
$response = $this->downloadFileAsUserUsingPassword($this->getActualUsername($user), $fileName);
|
||||||
$response = $this->downloadFileAsUserUsingPassword($user, $fileName);
|
|
||||||
$actualStatus = $response->getStatusCode();
|
$actualStatus = $response->getStatusCode();
|
||||||
if ($actualStatus !== 200) {
|
if ($actualStatus !== 200) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
@@ -1159,11 +1115,11 @@ trait WebDav {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function theSizeOfTheFileShouldBe(string $size):void {
|
public function theSizeOfTheFileShouldBe(string $size):void {
|
||||||
$responseXml = HttpRequestHelper::getResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$this->response,
|
$this->response,
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
$xmlPart = $responseXml->xpath("//d:prop/d:getcontentlength");
|
$xmlPart = $responseXmlObject->xpath("//d:prop/d:getcontentlength");
|
||||||
$actualSize = (string) $xmlPart[0];
|
$actualSize = (string) $xmlPart[0];
|
||||||
Assert::assertEquals(
|
Assert::assertEquals(
|
||||||
$size,
|
$size,
|
||||||
@@ -1277,7 +1233,7 @@ trait WebDav {
|
|||||||
$statusCode = $response->getStatusCode();
|
$statusCode = $response->getStatusCode();
|
||||||
if ($statusCode < 400 || $statusCode > 499) {
|
if ($statusCode < 400 || $statusCode > 499) {
|
||||||
try {
|
try {
|
||||||
$responseXml = HttpRequestHelper::getResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$response,
|
$response,
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
@@ -1287,10 +1243,10 @@ trait WebDav {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
Assert::assertTrue(
|
Assert::assertTrue(
|
||||||
$this->isEtagValid($this->getEtagFromResponseXmlObject($responseXml)),
|
$this->isEtagValid($this->getEtagFromResponseXmlObject($responseXmlObject)),
|
||||||
"$entry '$path' should not exist. But API returned $statusCode without an etag in the body"
|
"$entry '$path' should not exist. But API returned $statusCode without an etag in the body"
|
||||||
);
|
);
|
||||||
$isCollection = $responseXml->xpath("//d:prop/d:resourcetype/d:collection");
|
$isCollection = $responseXmlObject->xpath("//d:prop/d:resourcetype/d:collection");
|
||||||
if (\count($isCollection) === 0) {
|
if (\count($isCollection) === 0) {
|
||||||
$actualResourceType = "file";
|
$actualResourceType = "file";
|
||||||
} else {
|
} else {
|
||||||
@@ -1354,6 +1310,7 @@ trait WebDav {
|
|||||||
* @param string|null $type
|
* @param string|null $type
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function checkFileOrFolderExistsForUser(
|
public function checkFileOrFolderExistsForUser(
|
||||||
string $user,
|
string $user,
|
||||||
@@ -1363,18 +1320,22 @@ trait WebDav {
|
|||||||
):void {
|
):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$path = $this->substituteInLineCodes($path);
|
$path = $this->substituteInLineCodes($path);
|
||||||
$responseXml = $this->listFolderAndReturnResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$user,
|
$this->listFolder(
|
||||||
$path,
|
$user,
|
||||||
'0',
|
$path,
|
||||||
null,
|
'0',
|
||||||
$type
|
null,
|
||||||
|
null,
|
||||||
|
$type
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert::assertTrue(
|
Assert::assertTrue(
|
||||||
$this->isEtagValid($this->getEtagFromResponseXmlObject($responseXml)),
|
$this->isEtagValid($this->getEtagFromResponseXmlObject($responseXmlObject)),
|
||||||
"$entry '$path' expected to exist for user $user but not found"
|
"$entry '$path' expected to exist for user $user but not found"
|
||||||
);
|
);
|
||||||
$isCollection = $responseXml->xpath("//d:prop/d:resourcetype/d:collection");
|
$isCollection = $responseXmlObject->xpath("//d:prop/d:resourcetype/d:collection");
|
||||||
if ($entry === "folder") {
|
if ($entry === "folder") {
|
||||||
Assert::assertEquals(\count($isCollection), 1, "Unexpectedly, `$path` is not a folder");
|
Assert::assertEquals(\count($isCollection), 1, "Unexpectedly, `$path` is not a folder");
|
||||||
} elseif ($entry === "file") {
|
} elseif ($entry === "file") {
|
||||||
@@ -1463,37 +1424,6 @@ trait WebDav {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param string $user
|
|
||||||
* @param string $path
|
|
||||||
* @param string $folderDepth requires 1 to see elements without children
|
|
||||||
* @param array|null $properties
|
|
||||||
* @param string $type
|
|
||||||
*
|
|
||||||
* @return SimpleXMLElement
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function listFolderAndReturnResponseXml(
|
|
||||||
string $user,
|
|
||||||
string $path,
|
|
||||||
string $folderDepth,
|
|
||||||
?array $properties = null,
|
|
||||||
string $type = "files"
|
|
||||||
):SimpleXMLElement {
|
|
||||||
return HttpRequestHelper::getResponseXml(
|
|
||||||
$this->listFolder(
|
|
||||||
$user,
|
|
||||||
$path,
|
|
||||||
$folderDepth,
|
|
||||||
$properties,
|
|
||||||
null,
|
|
||||||
$type
|
|
||||||
),
|
|
||||||
__METHOD__
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then /^user "([^"]*)" should (not|)\s?see the following elements$/
|
* @Then /^user "([^"]*)" should (not|)\s?see the following elements$/
|
||||||
*
|
*
|
||||||
@@ -1534,10 +1464,12 @@ trait WebDav {
|
|||||||
if ($this->davPropfindDepthInfinityIsEnabled()) {
|
if ($this->davPropfindDepthInfinityIsEnabled()) {
|
||||||
// get a full "infinite" list of the user's root folder in one request
|
// get a full "infinite" list of the user's root folder in one request
|
||||||
// and process that to check the elements (resources)
|
// and process that to check the elements (resources)
|
||||||
$responseXmlObject = $this->listFolderAndReturnResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$user,
|
$this->listFolder(
|
||||||
"/",
|
$user,
|
||||||
"infinity"
|
"/",
|
||||||
|
"infinity"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
foreach ($elementsSimplified as $expectedElement) {
|
foreach ($elementsSimplified as $expectedElement) {
|
||||||
// Allow the table of expected elements to have entries that do
|
// Allow the table of expected elements to have entries that do
|
||||||
@@ -1575,10 +1507,12 @@ trait WebDav {
|
|||||||
// /some-folder%20with%20spaces/sub-folder
|
// /some-folder%20with%20spaces/sub-folder
|
||||||
// So we need both $elementToRequest and $expectedElement
|
// So we need both $elementToRequest and $expectedElement
|
||||||
$expectedElement = $this->encodePath($elementToRequest);
|
$expectedElement = $this->encodePath($elementToRequest);
|
||||||
$responseXmlObject = $this->listFolderAndReturnResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$user,
|
$this->listFolder(
|
||||||
$elementToRequest,
|
$user,
|
||||||
"1"
|
$elementToRequest,
|
||||||
|
'1'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$webdavPath = "/" . $this->getFullDavFilesPath($user) . $expectedElement;
|
$webdavPath = "/" . $this->getFullDavFilesPath($user) . $expectedElement;
|
||||||
@@ -1659,11 +1593,8 @@ trait WebDav {
|
|||||||
):void {
|
):void {
|
||||||
$response = $this->uploadFile($user, $source, $destination);
|
$response = $this->uploadFile($user, $source, $destination);
|
||||||
$this->setResponse($response);
|
$this->setResponse($response);
|
||||||
$this->setResponseXml(
|
|
||||||
HttpRequestHelper::parseResponseAsXml($response)
|
|
||||||
);
|
|
||||||
$this->pushToLastHttpStatusCodesArray(
|
$this->pushToLastHttpStatusCodesArray(
|
||||||
(string) $this->getResponse()->getStatusCode()
|
(string) $response->getStatusCode()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1710,7 +1641,6 @@ trait WebDav {
|
|||||||
$chunkingVersion = null;
|
$chunkingVersion = null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$this->responseXml = [];
|
|
||||||
$this->pauseUploadDelete();
|
$this->pauseUploadDelete();
|
||||||
$this->response = UploadHelper::upload(
|
$this->response = UploadHelper::upload(
|
||||||
$this->getBaseUrl(),
|
$this->getBaseUrl(),
|
||||||
@@ -3571,6 +3501,7 @@ trait WebDav {
|
|||||||
* @param boolean $checkEachDelete
|
* @param boolean $checkEachDelete
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function deleteEverythingInFolder(
|
public function deleteEverythingInFolder(
|
||||||
string $user,
|
string $user,
|
||||||
@@ -3578,10 +3509,12 @@ trait WebDav {
|
|||||||
bool $checkEachDelete = false
|
bool $checkEachDelete = false
|
||||||
):void {
|
):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$responseXmlObject = $this->listFolderAndReturnResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$user,
|
$this->listFolder(
|
||||||
$folder,
|
$user,
|
||||||
'1'
|
$folder,
|
||||||
|
'1'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$elementList = $responseXmlObject->xpath("//d:response/d:href");
|
$elementList = $responseXmlObject->xpath("//d:response/d:href");
|
||||||
if (\is_array($elementList) && \count($elementList)) {
|
if (\is_array($elementList) && \count($elementList)) {
|
||||||
@@ -3953,9 +3886,8 @@ trait WebDav {
|
|||||||
*/
|
*/
|
||||||
public function theDownloadedPreviewContentShouldMatchWithFixturesPreviewContentFor(string $filename):void {
|
public function theDownloadedPreviewContentShouldMatchWithFixturesPreviewContentFor(string $filename):void {
|
||||||
$expectedPreview = \file_get_contents(__DIR__ . "/../fixtures/" . $filename);
|
$expectedPreview = \file_get_contents(__DIR__ . "/../fixtures/" . $filename);
|
||||||
$response = $response ?? $this->getResponse();
|
$this->getResponse()->getBody()->rewind();
|
||||||
$response->getBody()->rewind();
|
$responseBodyContent = $this->getResponse()->getBody()->getContents();
|
||||||
$responseBodyContent = $response->getBody()->getContents();
|
|
||||||
Assert::assertEquals($expectedPreview, $responseBodyContent);
|
Assert::assertEquals($expectedPreview, $responseBodyContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4081,11 +4013,11 @@ trait WebDav {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function theDavElementShouldBe(string $element, string $message):void {
|
public function theDavElementShouldBe(string $element, string $message):void {
|
||||||
$resXmlArray = HttpRequestHelper::parseResponseAsXml($this->getResponse());
|
$responseXmlArray = HttpRequestHelper::parseResponseAsXml($this->getResponse());
|
||||||
WebDavAssert::assertDavResponseElementIs(
|
WebDavAssert::assertDavResponseElementIs(
|
||||||
$element,
|
$element,
|
||||||
$message,
|
$message,
|
||||||
$resXmlArray,
|
$responseXmlArray,
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -4220,23 +4152,18 @@ trait WebDav {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function checkIFResponseContainsNumberEntries(int $numFiles):void {
|
public function checkIFResponseContainsNumberEntries(int $numFiles):void {
|
||||||
//if we are using that step the second time in a scenario e.g. 'But ... should not'
|
$responseXmlArray = HttpRequestHelper::parseResponseAsXml($this->response);
|
||||||
//then don't parse the result again, because the result in a ResponseInterface
|
|
||||||
if (empty($this->responseXml)) {
|
|
||||||
$this->setResponseXml(
|
|
||||||
HttpRequestHelper::parseResponseAsXml($this->response)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Assert::assertIsArray(
|
Assert::assertIsArray(
|
||||||
$this->responseXml,
|
$responseXmlArray,
|
||||||
__METHOD__ . " responseXml is not an array"
|
__METHOD__ . " is not an array"
|
||||||
);
|
);
|
||||||
Assert::assertArrayHasKey(
|
Assert::assertArrayHasKey(
|
||||||
"value",
|
"value",
|
||||||
$this->responseXml,
|
$responseXmlArray,
|
||||||
__METHOD__ . " responseXml does not have key 'value'"
|
__METHOD__ . " does not have key 'value'"
|
||||||
);
|
);
|
||||||
$multistatusResults = $this->responseXml["value"];
|
$multistatusResults = $responseXmlArray["value"];
|
||||||
if ($multistatusResults === null) {
|
if ($multistatusResults === null) {
|
||||||
$multistatusResults = [];
|
$multistatusResults = [];
|
||||||
}
|
}
|
||||||
@@ -4342,7 +4269,6 @@ trait WebDav {
|
|||||||
$depth
|
$depth
|
||||||
);
|
);
|
||||||
$this->setResponse($response);
|
$this->setResponse($response);
|
||||||
$this->setResponseXml(HttpRequestHelper::parseResponseAsXml($this->response));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4429,16 +4355,16 @@ trait WebDav {
|
|||||||
*/
|
*/
|
||||||
public function thePublicListsTheResourcesInTheLastCreatedPublicLinkWithDepthUsingTheWebdavApi(string $depth):void {
|
public function thePublicListsTheResourcesInTheLastCreatedPublicLinkWithDepthUsingTheWebdavApi(string $depth):void {
|
||||||
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||||
$response = $this->listFolder(
|
$this->setResponse(
|
||||||
$token,
|
$this->listFolder(
|
||||||
'/',
|
$token,
|
||||||
$depth,
|
'/',
|
||||||
null,
|
$depth,
|
||||||
null,
|
null,
|
||||||
"public-files"
|
null,
|
||||||
|
"public-files"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$this->setResponse($response);
|
|
||||||
$this->setResponseXml(HttpRequestHelper::parseResponseAsXml($this->response));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4447,7 +4373,7 @@ trait WebDav {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function findEntryFromReportResponse(?string $user):array {
|
public function findEntryFromReportResponse(?string $user):array {
|
||||||
$responseXmlObj = $this->getResponseXml();
|
$responseXmlObj = HttpRequestHelper::getResponseXml($this->getResponse());
|
||||||
$responseResources = [];
|
$responseResources = [];
|
||||||
$hrefs = $responseXmlObj->xpath('//d:href');
|
$hrefs = $responseXmlObj->xpath('//d:href');
|
||||||
foreach ($hrefs as $href) {
|
foreach ($hrefs as $href) {
|
||||||
@@ -4488,28 +4414,22 @@ trait WebDav {
|
|||||||
public function getMultiStatusResultFromPropfindResult(
|
public function getMultiStatusResultFromPropfindResult(
|
||||||
?string $user = null
|
?string $user = null
|
||||||
):array {
|
):array {
|
||||||
//if we are using that step the second time in a scenario e.g. 'But ... should not'
|
$responseXmlArray = HttpRequestHelper::parseResponseAsXml($this->response);
|
||||||
//then don't parse the result again, because the result in a ResponseInterface
|
|
||||||
if (empty($this->responseXml)) {
|
Assert::assertNotEmpty($responseXmlArray, __METHOD__ . ' Response is empty');
|
||||||
$this->setResponseXml(
|
|
||||||
HttpRequestHelper::parseResponseAsXml($this->response)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Assert::assertNotEmpty($this->responseXml, __METHOD__ . ' Response is empty');
|
|
||||||
if ($user === null) {
|
if ($user === null) {
|
||||||
$user = $this->getCurrentUser();
|
$user = $this->getCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert::assertIsArray(
|
Assert::assertIsArray(
|
||||||
$this->responseXml,
|
$responseXmlArray,
|
||||||
__METHOD__ . " responseXml for user $user is not an array"
|
__METHOD__ . " response for user $user is not an array"
|
||||||
);
|
);
|
||||||
Assert::assertArrayHasKey(
|
Assert::assertArrayHasKey(
|
||||||
"value",
|
"value",
|
||||||
$this->responseXml,
|
$responseXmlArray,
|
||||||
__METHOD__ . " responseXml for user $user does not have key 'value'"
|
__METHOD__ . " response for user $user does not have key 'value'"
|
||||||
);
|
);
|
||||||
$multistatus = $this->responseXml["value"];
|
$multistatus = $responseXmlArray["value"];
|
||||||
if ($multistatus == null) {
|
if ($multistatus == null) {
|
||||||
$multistatus = [];
|
$multistatus = [];
|
||||||
}
|
}
|
||||||
@@ -4573,7 +4493,9 @@ trait WebDav {
|
|||||||
default:
|
default:
|
||||||
throw new Exception("error");
|
throw new Exception("error");
|
||||||
}
|
}
|
||||||
|
|
||||||
$multistatusResults = $this->getMultiStatusResultFromPropfindResult($user);
|
$multistatusResults = $this->getMultiStatusResultFromPropfindResult($user);
|
||||||
|
|
||||||
$results = [];
|
$results = [];
|
||||||
foreach ($multistatusResults as $multistatusResult) {
|
foreach ($multistatusResults as $multistatusResult) {
|
||||||
$entryPath = $multistatusResult['value'][0]['value'];
|
$entryPath = $multistatusResult['value'][0]['value'];
|
||||||
@@ -4627,7 +4549,8 @@ trait WebDav {
|
|||||||
}
|
}
|
||||||
$hrefRegex = "/^" . $hrefRegex . "/";
|
$hrefRegex = "/^" . $hrefRegex . "/";
|
||||||
|
|
||||||
$searchResults = $this->getResponseXml()->xpath("//d:multistatus/d:response");
|
$searchResults = HttpRequestHelper::getResponseXml($this->getResponse())->xpath("//d:multistatus/d:response");
|
||||||
|
|
||||||
$results = [];
|
$results = [];
|
||||||
foreach ($searchResults as $item) {
|
foreach ($searchResults as $item) {
|
||||||
$href = (string)$item->xpath("d:href")[0];
|
$href = (string)$item->xpath("d:href")[0];
|
||||||
@@ -4707,17 +4630,13 @@ trait WebDav {
|
|||||||
*/
|
*/
|
||||||
public function checkAuthorOfAVersionOfFile(string $index, string $expectedUsername):void {
|
public function checkAuthorOfAVersionOfFile(string $index, string $expectedUsername):void {
|
||||||
$expectedUserDisplayName = $this->getUserDisplayName($expectedUsername);
|
$expectedUserDisplayName = $this->getUserDisplayName($expectedUsername);
|
||||||
$resXml = $this->getResponseXml();
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
if ($resXml === null) {
|
$this->getResponse(),
|
||||||
$resXml = HttpRequestHelper::getResponseXml(
|
__METHOD__
|
||||||
$this->getResponse(),
|
);
|
||||||
__METHOD__
|
|
||||||
);
|
|
||||||
$this->setResponseXmlObject($resXml);
|
|
||||||
}
|
|
||||||
|
|
||||||
// the username should be in oc:meta-version-edited-by
|
// the username should be in oc:meta-version-edited-by
|
||||||
$xmlPart = $resXml->xpath("//oc:meta-version-edited-by");
|
$xmlPart = $responseXmlObject->xpath("//oc:meta-version-edited-by");
|
||||||
$authors = [];
|
$authors = [];
|
||||||
foreach ($xmlPart as $idx => $author) {
|
foreach ($xmlPart as $idx => $author) {
|
||||||
// The first element is the root path element which is not a version
|
// The first element is the root path element which is not a version
|
||||||
@@ -4739,7 +4658,7 @@ trait WebDav {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// the user's display name should be in oc:meta-version-edited-by-name
|
// the user's display name should be in oc:meta-version-edited-by-name
|
||||||
$xmlPart = $resXml->xpath("//oc:meta-version-edited-by-name");
|
$xmlPart = $responseXmlObject->xpath("//oc:meta-version-edited-by-name");
|
||||||
$displaynames = [];
|
$displaynames = [];
|
||||||
foreach ($xmlPart as $idx => $displayname) {
|
foreach ($xmlPart as $idx => $displayname) {
|
||||||
// The first element is the root path element which is not a version
|
// The first element is the root path element which is not a version
|
||||||
|
|||||||
@@ -123,8 +123,8 @@ class WebDavLockingContext implements Context {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||||
$xmlPart = $responseXml->xpath("//d:locktoken/d:href");
|
$xmlPart = $responseXmlObject->xpath("//d:locktoken/d:href");
|
||||||
if (isset($xmlPart[0])) {
|
if (isset($xmlPart[0])) {
|
||||||
$this->tokenOfLastLock[$user][$file] = (string) $xmlPart[0];
|
$this->tokenOfLastLock[$user][$file] = (string) $xmlPart[0];
|
||||||
} else {
|
} else {
|
||||||
@@ -556,8 +556,8 @@ class WebDavLockingContext implements Context {
|
|||||||
$body,
|
$body,
|
||||||
$this->featureContext->getDavPathVersion()
|
$this->featureContext->getDavPathVersion()
|
||||||
);
|
);
|
||||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||||
$xmlPart = $responseXml->xpath("//d:response//d:lockdiscovery/d:activelock");
|
$xmlPart = $responseXmlObject->xpath("//d:response//d:lockdiscovery/d:activelock");
|
||||||
if (\is_array($xmlPart)) {
|
if (\is_array($xmlPart)) {
|
||||||
return \count($xmlPart);
|
return \count($xmlPart);
|
||||||
} else {
|
} else {
|
||||||
@@ -904,8 +904,8 @@ class WebDavLockingContext implements Context {
|
|||||||
public function numberOfLockShouldBeReportedInProjectSpace(int $count, string $file, string $spaceName, string $user) {
|
public function numberOfLockShouldBeReportedInProjectSpace(int $count, string $file, string $spaceName, string $user) {
|
||||||
$response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file, null, '0');
|
$response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file, null, '0');
|
||||||
$this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response);
|
$this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response);
|
||||||
$responseXml = $this->featureContext->getResponseXml($response);
|
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||||
$xmlPart = $responseXml->xpath("//d:response//d:lockdiscovery/d:activelock");
|
$xmlPart = $responseXmlObject->xpath("//d:response//d:lockdiscovery/d:activelock");
|
||||||
if (\is_array($xmlPart)) {
|
if (\is_array($xmlPart)) {
|
||||||
$lockCount = \count($xmlPart);
|
$lockCount = \count($xmlPart);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use Psr\Http\Message\ResponseInterface;
|
|||||||
use TestHelpers\Asserts\WebDav as WebDavTest;
|
use TestHelpers\Asserts\WebDav as WebDavTest;
|
||||||
use TestHelpers\WebDavHelper;
|
use TestHelpers\WebDavHelper;
|
||||||
use TestHelpers\BehatHelper;
|
use TestHelpers\BehatHelper;
|
||||||
|
use TestHelpers\HttpRequestHelper;
|
||||||
|
|
||||||
require_once 'bootstrap.php';
|
require_once 'bootstrap.php';
|
||||||
|
|
||||||
@@ -442,7 +443,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
*/
|
*/
|
||||||
public function theResponseShouldContainCustomPropertyWithValue(string $propertyName, string $propertyValue): void {
|
public function theResponseShouldContainCustomPropertyWithValue(string $propertyName, string $propertyValue): void {
|
||||||
$propertyValue = \str_replace('\"', '"', $propertyValue);
|
$propertyValue = \str_replace('\"', '"', $propertyValue);
|
||||||
$responseXmlObject = $this->featureContext->getResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$this->featureContext->getResponse(),
|
$this->featureContext->getResponse(),
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
@@ -479,7 +480,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
):void {
|
):void {
|
||||||
// let's unescape quotes first
|
// let's unescape quotes first
|
||||||
$propertyValue = \str_replace('\"', '"', $propertyValue);
|
$propertyValue = \str_replace('\"', '"', $propertyValue);
|
||||||
$responseXmlObject = $this->featureContext->getResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$this->featureContext->getResponse(),
|
$this->featureContext->getResponse(),
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
@@ -518,7 +519,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
string $property,
|
string $property,
|
||||||
string $childProperty
|
string $childProperty
|
||||||
):void {
|
):void {
|
||||||
$xmlPart = $this->featureContext->getResponseXml()->xpath(
|
$xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath(
|
||||||
"//d:prop/$property/$childProperty"
|
"//d:prop/$property/$childProperty"
|
||||||
);
|
);
|
||||||
Assert::assertTrue(
|
Assert::assertTrue(
|
||||||
@@ -636,7 +637,8 @@ class WebDavPropertiesContext implements Context {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function checkResponseContainsProperty(ResponseInterface $response, string $key, string $namespaceString = null): SimpleXMLElement {
|
public function checkResponseContainsProperty(ResponseInterface $response, string $key, string $namespaceString = null): SimpleXMLElement {
|
||||||
$xmlPart = $this->featureContext->getResponseXml($response);
|
$xmlPart = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||||
|
;
|
||||||
|
|
||||||
if ($namespaceString !== null) {
|
if ($namespaceString !== null) {
|
||||||
$ns = WebDavHelper::parseNamespace($namespaceString);
|
$ns = WebDavHelper::parseNamespace($namespaceString);
|
||||||
@@ -759,11 +761,11 @@ class WebDavPropertiesContext implements Context {
|
|||||||
* @return void
|
* @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(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$this->featureContext->getResponse(),
|
$this->featureContext->getResponse(),
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
$value = $this->getXmlItemByXpath($resXml, $xpath);
|
$value = $this->getXmlItemByXpath($responseXmlObject, $xpath);
|
||||||
$user = $this->featureContext->getActualUsername($user);
|
$user = $this->featureContext->getActualUsername($user);
|
||||||
$expectedValue = $this->featureContext->substituteInLineCodes(
|
$expectedValue = $this->featureContext->substituteInLineCodes(
|
||||||
$expectedValue,
|
$expectedValue,
|
||||||
@@ -796,11 +798,11 @@ class WebDavPropertiesContext implements Context {
|
|||||||
if (!$expectedValue2) {
|
if (!$expectedValue2) {
|
||||||
$expectedValue2 = $expectedValue1;
|
$expectedValue2 = $expectedValue1;
|
||||||
}
|
}
|
||||||
$resXml = $this->featureContext->getResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$this->featureContext->getResponse(),
|
$this->featureContext->getResponse(),
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
$value = $this->getXmlItemByXpath($resXml, $xpath);
|
$value = $this->getXmlItemByXpath($responseXmlObject, $xpath);
|
||||||
$user = $this->featureContext->getActualUsername($user);
|
$user = $this->featureContext->getActualUsername($user);
|
||||||
$expectedValue1 = $this->featureContext->substituteInLineCodes(
|
$expectedValue1 = $this->featureContext->substituteInLineCodes(
|
||||||
$expectedValue1,
|
$expectedValue1,
|
||||||
@@ -822,16 +824,16 @@ class WebDavPropertiesContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SimpleXMLElement $xmlResponse
|
* @param SimpleXMLElement $responseXmlObject
|
||||||
* @param string $xpath
|
* @param string $xpath
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getXmlItemByXpath(
|
public function getXmlItemByXpath(
|
||||||
SimpleXMLElement $xmlResponse,
|
SimpleXMLElement $responseXmlObject,
|
||||||
string $xpath
|
string $xpath
|
||||||
): string {
|
): string {
|
||||||
$xmlPart = $xmlResponse->xpath($xpath);
|
$xmlPart = $responseXmlObject->xpath($xpath);
|
||||||
Assert::assertTrue(
|
Assert::assertTrue(
|
||||||
isset($xmlPart[0]),
|
isset($xmlPart[0]),
|
||||||
"Cannot find item with xpath \"$xpath\""
|
"Cannot find item with xpath \"$xpath\""
|
||||||
@@ -850,7 +852,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
*/
|
*/
|
||||||
public function assertValueOfItemInResponseRegExp(string $xpath, string $pattern):void {
|
public function assertValueOfItemInResponseRegExp(string $xpath, string $pattern):void {
|
||||||
$this->assertXpathValueMatchesPattern(
|
$this->assertXpathValueMatchesPattern(
|
||||||
$this->featureContext->getResponseXml(),
|
HttpRequestHelper::getResponseXml($this->featureContext->getResponse()),
|
||||||
$xpath,
|
$xpath,
|
||||||
$pattern
|
$pattern
|
||||||
);
|
);
|
||||||
@@ -871,7 +873,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
$response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable);
|
$response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable);
|
||||||
$this->featureContext->theHTTPStatusCodeShouldBe('207', "", $response);
|
$this->featureContext->theHTTPStatusCodeShouldBe('207', "", $response);
|
||||||
$this->assertXpathValueMatchesPattern(
|
$this->assertXpathValueMatchesPattern(
|
||||||
$this->featureContext->getResponseXml($response),
|
HttpRequestHelper::getResponseXml($response, __METHOD__),
|
||||||
$xpath,
|
$xpath,
|
||||||
$pattern
|
$pattern
|
||||||
);
|
);
|
||||||
@@ -887,7 +889,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function assertEntryWithHrefMatchingRegExpInResponseToUser(string $expectedHref, string $user):void {
|
public function assertEntryWithHrefMatchingRegExpInResponseToUser(string $expectedHref, string $user):void {
|
||||||
$resXml = $this->featureContext->getResponseXml(
|
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||||
$this->featureContext->getResponse(),
|
$this->featureContext->getResponse(),
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
@@ -904,7 +906,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
while (true) {
|
while (true) {
|
||||||
$index++;
|
$index++;
|
||||||
$xpath = "//d:response[$index]/d:href";
|
$xpath = "//d:response[$index]/d:href";
|
||||||
$xmlPart = $resXml->xpath($xpath);
|
$xmlPart = $responseXmlObject->xpath($xpath);
|
||||||
// If we have run out of entries in the response, then fail the test
|
// If we have run out of entries in the response, then fail the test
|
||||||
Assert::assertTrue(
|
Assert::assertTrue(
|
||||||
isset($xmlPart[0]),
|
isset($xmlPart[0]),
|
||||||
@@ -937,16 +939,16 @@ class WebDavPropertiesContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SimpleXMLElement $responseXml
|
* @param SimpleXMLElement $responseXmlObject
|
||||||
* @param string $xpath
|
* @param string $xpath
|
||||||
* @param string $pattern
|
* @param string $pattern
|
||||||
* @param string|null $user
|
* @param string|null $user
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function assertXpathValueMatchesPattern(SimpleXMLElement $responseXml, string $xpath, string $pattern, ?string $user = null): void {
|
public function assertXpathValueMatchesPattern(SimpleXMLElement $responseXmlObject, string $xpath, string $pattern, ?string $user = null): void {
|
||||||
$xmlPart = $responseXml->xpath($xpath);
|
$xmlPart = $responseXmlObject->xpath($xpath);
|
||||||
Assert::assertTrue(
|
Assert::assertTrue(
|
||||||
isset($xmlPart[0]),
|
isset($xmlPart[0]),
|
||||||
"Cannot find item with xpath \"$xpath\""
|
"Cannot find item with xpath \"$xpath\""
|
||||||
@@ -983,22 +985,6 @@ class WebDavPropertiesContext implements Context {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Then the value of the item :xpath in the response to user :user should match :value
|
|
||||||
*
|
|
||||||
* @param string $xpath
|
|
||||||
* @param string|null $user
|
|
||||||
* @param string $pattern
|
|
||||||
* @param SimpleXMLElement|null $responseXml
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function theValueOfItemInResponseToUserShouldMatch(string $xpath, ?string $user, string $pattern, ?SimpleXMLElement $responseXml = null):void {
|
|
||||||
$resXml = $this->featureContext->getResponseXml();
|
|
||||||
$this->assertXpathValueMatchesPattern($resXml, $xpath, $pattern, $user);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then /^as user "([^"]*)" the lock discovery property "([^"]*)" of the (?:file|folder|entry) "([^"]*)" should match "([^"]*)"$/
|
* @Then /^as user "([^"]*)" the lock discovery property "([^"]*)" of the (?:file|folder|entry) "([^"]*)" should match "([^"]*)"$/
|
||||||
*
|
*
|
||||||
@@ -1020,7 +1006,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
);
|
);
|
||||||
$this->featureContext->theHTTPStatusCodeShouldBe('207', '', $response);
|
$this->featureContext->theHTTPStatusCodeShouldBe('207', '', $response);
|
||||||
$this->assertXpathValueMatchesPattern(
|
$this->assertXpathValueMatchesPattern(
|
||||||
$this->featureContext->getResponseXml($response),
|
HttpRequestHelper::getResponseXml($response, __METHOD__),
|
||||||
$xpath,
|
$xpath,
|
||||||
$pattern,
|
$pattern,
|
||||||
$user
|
$user
|
||||||
@@ -1036,7 +1022,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function assertItemInResponseDoesNotExist(string $xpath):void {
|
public function assertItemInResponseDoesNotExist(string $xpath):void {
|
||||||
$xmlPart = $this->featureContext->getResponseXml()->xpath($xpath);
|
$xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath($xpath);
|
||||||
Assert::assertFalse(
|
Assert::assertFalse(
|
||||||
isset($xmlPart[0]),
|
isset($xmlPart[0]),
|
||||||
"Found item with xpath \"$xpath\" but it should not exist"
|
"Found item with xpath \"$xpath\" but it should not exist"
|
||||||
@@ -1114,7 +1100,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
string $key,
|
string $key,
|
||||||
string $regex
|
string $regex
|
||||||
):void {
|
):void {
|
||||||
$xmlPart = $this->featureContext->getResponseXml()->xpath(
|
$xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath(
|
||||||
"//d:prop/$key"
|
"//d:prop/$key"
|
||||||
);
|
);
|
||||||
Assert::assertTrue(
|
Assert::assertTrue(
|
||||||
@@ -1140,7 +1126,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
public function theResponseShouldContainAShareTypesPropertyWith(TableNode $table):void {
|
public function theResponseShouldContainAShareTypesPropertyWith(TableNode $table):void {
|
||||||
$this->featureContext->verifyTableNodeColumnsCount($table, 1);
|
$this->featureContext->verifyTableNodeColumnsCount($table, 1);
|
||||||
WebdavTest::assertResponseContainsShareTypes(
|
WebdavTest::assertResponseContainsShareTypes(
|
||||||
$this->featureContext->getResponseXml(),
|
HttpRequestHelper::getResponseXml($this->featureContext->getResponse()),
|
||||||
$table->getRows()
|
$table->getRows()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1154,7 +1140,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function theResponseShouldContainAnEmptyProperty(string $property):void {
|
public function theResponseShouldContainAnEmptyProperty(string $property):void {
|
||||||
$xmlPart = $this->featureContext->getResponseXml()->xpath(
|
$xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath(
|
||||||
"//d:prop/$property"
|
"//d:prop/$property"
|
||||||
);
|
);
|
||||||
Assert::assertCount(
|
Assert::assertCount(
|
||||||
@@ -1189,7 +1175,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
$spaceId,
|
$spaceId,
|
||||||
$propertiesTable
|
$propertiesTable
|
||||||
);
|
);
|
||||||
$xmlObject = $this->featureContext->getResponseXml($response);
|
$xmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||||
$this->storedETAG[$user][$storePath]
|
$this->storedETAG[$user][$storePath]
|
||||||
= $this->featureContext->getEtagFromResponseXmlObject($xmlObject);
|
= $this->featureContext->getEtagFromResponseXmlObject($xmlObject);
|
||||||
return $xmlObject;
|
return $xmlObject;
|
||||||
@@ -1302,9 +1288,8 @@ class WebDavPropertiesContext implements Context {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function theResponseShouldHavePropertyWithValue(string $username, TableNode $expectedPropTable):void {
|
public function theResponseShouldHavePropertyWithValue(string $username, TableNode $expectedPropTable):void {
|
||||||
$username = $this->featureContext->getActualUsername($username);
|
|
||||||
$this->featureContext->verifyTableNodeColumns($expectedPropTable, ['resource', 'propertyName', 'propertyValue']);
|
$this->featureContext->verifyTableNodeColumns($expectedPropTable, ['resource', 'propertyName', 'propertyValue']);
|
||||||
$responseXmlObject = $this->featureContext->getResponseXml();
|
$responseXmlObject = HttpRequestHelper::getResponseXml($this->featureContext->getResponse());
|
||||||
|
|
||||||
$href = (string)$responseXmlObject->xpath("//d:href")[0];
|
$href = (string)$responseXmlObject->xpath("//d:href")[0];
|
||||||
$hrefBase = $this->parseBaseDavPathFromXMLHref($href);
|
$hrefBase = $this->parseBaseDavPathFromXMLHref($href);
|
||||||
@@ -1339,7 +1324,7 @@ class WebDavPropertiesContext implements Context {
|
|||||||
null,
|
null,
|
||||||
$propertiesTable
|
$propertiesTable
|
||||||
);
|
);
|
||||||
return $this->featureContext->getEtagFromResponseXmlObject($this->featureContext->getResponseXml($response));
|
return $this->featureContext->getEtagFromResponseXmlObject(HttpRequestHelper::getResponseXml($response, __METHOD__));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user