mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-30 17:00:57 -06:00
remove getResponseXml
This commit is contained in:
@@ -29,6 +29,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use TestHelpers\OcsApiHelper;
|
||||
use TestHelpers\BehatHelper;
|
||||
use TestHelpers\HttpRequestHelper;
|
||||
|
||||
require_once 'bootstrap.php';
|
||||
|
||||
@@ -213,7 +214,7 @@ class CapabilitiesContext implements Context {
|
||||
|
||||
$response = $this->userGetsCapabilities($this->getAdminUsernameForCapabilitiesCheck());
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||
$responseXml = $this->featureContext->getResponseXml($response)->data->capabilities;
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__)->data->capabilities;
|
||||
$edition = $this->getParameterValueFromXml(
|
||||
$responseXml,
|
||||
'core',
|
||||
|
||||
@@ -1032,26 +1032,6 @@ class FeatureContext extends BehatVariablesContext {
|
||||
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
|
||||
*
|
||||
|
||||
@@ -26,6 +26,7 @@ use Behat\Gherkin\Node\PyStringNode;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use TestHelpers\HttpRequestHelper;
|
||||
use TestHelpers\OcsApiHelper;
|
||||
use TestHelpers\TranslationHelper;
|
||||
use TestHelpers\BehatHelper;
|
||||
@@ -564,7 +565,7 @@ class OCSContext implements Context {
|
||||
return (string) $jsonResponse->ocs->meta->statuscode;
|
||||
}
|
||||
// go to xml response when json response is null (it means not formatted and get status code)
|
||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
if (isset($responseXml->meta[0], $responseXml->meta[0]->statuscode)) {
|
||||
return (string) $responseXml->meta[0]->statuscode;
|
||||
}
|
||||
@@ -582,7 +583,7 @@ class OCSContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getOCSResponseData(ResponseInterface $response): SimpleXMLElement {
|
||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
if (isset($responseXml->data)) {
|
||||
return $responseXml->data;
|
||||
}
|
||||
@@ -600,7 +601,7 @@ class OCSContext implements Context {
|
||||
* @return 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ use Behat\Gherkin\Node\TableNode;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use TestHelpers\BehatHelper;
|
||||
use TestHelpers\HttpRequestHelper;
|
||||
|
||||
require_once 'bootstrap.php';
|
||||
|
||||
@@ -155,7 +156,7 @@ class ShareesContext implements Context {
|
||||
ResponseInterface $response,
|
||||
string $shareeType
|
||||
):array {
|
||||
$elements = $this->featureContext->getResponseXml($response, __METHOD__)->data;
|
||||
$elements = HttpRequestHelper::getResponseXml($response, __METHOD__)->data;
|
||||
$elements = \json_decode(\json_encode($elements), true);
|
||||
if (\strpos($shareeType, 'exact ') === 0) {
|
||||
$elements = $elements['exact'];
|
||||
|
||||
@@ -136,13 +136,6 @@ class SpacesContext implements Context {
|
||||
*/
|
||||
private array $responseXml = [];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getResponseXml(): array {
|
||||
return $this->responseXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $responseXml
|
||||
*
|
||||
@@ -369,7 +362,7 @@ class SpacesContext implements Context {
|
||||
);
|
||||
|
||||
$this->featureContext->theHttpStatusCodeShouldBe(207, '', $response);
|
||||
$xmlResponse = $this->featureContext->getResponseXml($response);
|
||||
$xmlResponse = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$fileId = $xmlResponse->xpath("//d:response/d:propstat/d:prop/oc:fileid")[0];
|
||||
return $fileId->__toString();
|
||||
}
|
||||
@@ -396,7 +389,7 @@ class SpacesContext implements Context {
|
||||
"files",
|
||||
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");
|
||||
return $responseArray[0][0];
|
||||
}
|
||||
@@ -2424,7 +2417,7 @@ class SpacesContext implements Context {
|
||||
$body,
|
||||
$this->featureContext->getStepLineRef()
|
||||
);
|
||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$sharer = (string) $responseXml->data->uid_owner;
|
||||
$this->featureContext->addToCreatedUserGroupshares($sharer, $responseXml->data);
|
||||
return $response;
|
||||
@@ -2587,7 +2580,7 @@ class SpacesContext implements Context {
|
||||
$this->featureContext->getStepLineRef()
|
||||
);
|
||||
|
||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$this->featureContext->addToCreatedPublicShares($responseXml->data);
|
||||
return $response;
|
||||
}
|
||||
@@ -3101,7 +3094,7 @@ class SpacesContext implements Context {
|
||||
$response
|
||||
);
|
||||
return $this->trashbinContext->getTrashbinContentFromResponseXml(
|
||||
$this->featureContext->getResponseXml($response)
|
||||
HttpRequestHelper::getResponseXml($response, __METHOD__)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3572,7 +3565,7 @@ class SpacesContext implements Context {
|
||||
$this->featureContext->getStepLineRef()
|
||||
);
|
||||
|
||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$this->featureContext->addToCreatedPublicShares($responseXml->data);
|
||||
return $response;
|
||||
}
|
||||
@@ -3663,7 +3656,7 @@ class SpacesContext implements Context {
|
||||
);
|
||||
|
||||
$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) {
|
||||
Assert::assertNotEmpty($responseArray, __METHOD__ . ' Response should contain a link, but it is empty');
|
||||
@@ -4032,7 +4025,7 @@ class SpacesContext implements Context {
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function theXMLResponseShouldContain(string $resource, array $properties): void {
|
||||
$xmlResponse = $this->featureContext->getResponseXml();
|
||||
$xmlResponse = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$hrefs = array_map(fn ($href) => $href->__toString(), $xmlResponse->xpath("//d:response/d:href"));
|
||||
|
||||
$currentHref = '';
|
||||
@@ -4151,7 +4144,7 @@ class SpacesContext implements Context {
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function asUserTheKeyFromPropfindResponseShouldMatchWithSharedwithmeDriveitemidOfShare(string $user, string $key, string $resource): void {
|
||||
$xmlResponse = $this->featureContext->getResponseXml();
|
||||
$xmlResponse = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$fileId = $xmlResponse->xpath("//oc:name[text()='$resource']/preceding-sibling::$key")[0]->__toString();
|
||||
|
||||
$jsonResponse = GraphHelper::getSharesSharedWithMe(
|
||||
|
||||
@@ -345,7 +345,7 @@ class TrashbinContext implements Context {
|
||||
*/
|
||||
public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $table):void {
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['name']);
|
||||
$responseXml = $this->featureContext->getResponseXml();
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$files = $this->getTrashbinContentFromResponseXml($responseXml);
|
||||
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -368,7 +368,7 @@ class TrashbinContext implements Context {
|
||||
*/
|
||||
public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table):void {
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['name']);
|
||||
$responseXml = $this->featureContext->getResponseXml();
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
|
||||
$files = $this->getTrashbinContentFromResponseXml($responseXml);
|
||||
|
||||
@@ -460,7 +460,7 @@ class TrashbinContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function theLastWebdavResponseShouldContainFollowingElements(TableNode $elements):void {
|
||||
$files = $this->getTrashbinContentFromResponseXml($this->featureContext->getResponseXml());
|
||||
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($response, __METHOD__));
|
||||
$elementRows = $elements->getHash();
|
||||
foreach ($elementRows as $expectedElement) {
|
||||
$found = false;
|
||||
|
||||
@@ -140,15 +140,6 @@ trait WebDav {
|
||||
return $this->lastUploadDeleteTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SimpleXMLElement $responseXmlObject
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setResponseXmlObject(SimpleXMLElement $responseXmlObject):void {
|
||||
$this->responseXmlObject = $responseXmlObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -123,7 +123,7 @@ class WebDavLockingContext implements Context {
|
||||
);
|
||||
}
|
||||
|
||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$xmlPart = $responseXml->xpath("//d:locktoken/d:href");
|
||||
if (isset($xmlPart[0])) {
|
||||
$this->tokenOfLastLock[$user][$file] = (string) $xmlPart[0];
|
||||
@@ -556,7 +556,7 @@ class WebDavLockingContext implements Context {
|
||||
$body,
|
||||
$this->featureContext->getDavPathVersion()
|
||||
);
|
||||
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$xmlPart = $responseXml->xpath("//d:response//d:lockdiscovery/d:activelock");
|
||||
if (\is_array($xmlPart)) {
|
||||
return \count($xmlPart);
|
||||
@@ -904,7 +904,7 @@ class WebDavLockingContext implements Context {
|
||||
public function numberOfLockShouldBeReportedInProjectSpace(int $count, string $file, string $spaceName, string $user) {
|
||||
$response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file, null, '0');
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response);
|
||||
$responseXml = $this->featureContext->getResponseXml($response);
|
||||
$responseXml = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$xmlPart = $responseXml->xpath("//d:response//d:lockdiscovery/d:activelock");
|
||||
if (\is_array($xmlPart)) {
|
||||
$lockCount = \count($xmlPart);
|
||||
|
||||
@@ -28,6 +28,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use TestHelpers\Asserts\WebDav as WebDavTest;
|
||||
use TestHelpers\WebDavHelper;
|
||||
use TestHelpers\BehatHelper;
|
||||
use TestHelpers\HttpRequestHelper;
|
||||
|
||||
require_once 'bootstrap.php';
|
||||
|
||||
@@ -636,7 +637,8 @@ class WebDavPropertiesContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkResponseContainsProperty(ResponseInterface $response, string $key, string $namespaceString = null): SimpleXMLElement {
|
||||
$xmlPart = $this->featureContext->getResponseXml($response);
|
||||
$xmlPart = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
;
|
||||
|
||||
if ($namespaceString !== null) {
|
||||
$ns = WebDavHelper::parseNamespace($namespaceString);
|
||||
@@ -871,7 +873,7 @@ class WebDavPropertiesContext implements Context {
|
||||
$response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe('207', "", $response);
|
||||
$this->assertXpathValueMatchesPattern(
|
||||
$this->featureContext->getResponseXml($response),
|
||||
HttpRequestHelper::getResponseXml($response, __METHOD__),
|
||||
$xpath,
|
||||
$pattern
|
||||
);
|
||||
@@ -1020,7 +1022,7 @@ class WebDavPropertiesContext implements Context {
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe('207', '', $response);
|
||||
$this->assertXpathValueMatchesPattern(
|
||||
$this->featureContext->getResponseXml($response),
|
||||
HttpRequestHelper::getResponseXml($response, __METHOD__),
|
||||
$xpath,
|
||||
$pattern,
|
||||
$user
|
||||
@@ -1189,7 +1191,7 @@ class WebDavPropertiesContext implements Context {
|
||||
$spaceId,
|
||||
$propertiesTable
|
||||
);
|
||||
$xmlObject = $this->featureContext->getResponseXml($response);
|
||||
$xmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$this->storedETAG[$user][$storePath]
|
||||
= $this->featureContext->getEtagFromResponseXmlObject($xmlObject);
|
||||
return $xmlObject;
|
||||
@@ -1339,7 +1341,7 @@ class WebDavPropertiesContext implements Context {
|
||||
null,
|
||||
$propertiesTable
|
||||
);
|
||||
return $this->featureContext->getEtagFromResponseXmlObject($this->featureContext->getResponseXml($response));
|
||||
return $this->featureContext->getEtagFromResponseXmlObject(HttpRequestHelper::getResponseXml($response, __METHOD__));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user