Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,18 @@ public function userHasCreatedFolder(
continue;
}
$fullFolderString .= "/" . trim($folder);
// check if the file or folder already exists
if ($this->isElementExist($user, $fullFolderString)) {
continue;
}
$this->response = $this->makeDavRequest(
$user,
$this->regularUserPassword,
"MKCOL",
$fullFolderString
);
$this->theHTTPStatusCodeShouldBe(
["201","405"], // 405 is returned if the folder already exists
["201"],
"HTTP status code was not 201 while trying to create folder '$fullFolderString' for user '$user'"
);
}
Expand Down Expand Up @@ -692,8 +696,8 @@ public function verifyTableNodeColumns(TableNode $table, ?array $requiredHeader
}
}

public function getIdOfElement(string $user, string $element): int {
$propfindResponse = $this->makeDavRequest(
public function getElementResponse(string $user, string $element): ResponseInterface {
return $this->makeDavRequest(
$user,
$this->regularUserPassword,
"PROPFIND",
Expand All @@ -706,14 +710,23 @@ public function getIdOfElement(string $user, string $element): int {
</d:prop>
</d:propfind>'
);
$xmlBody = $propfindResponse->getBody()->getContents();
$responseXmlObject = new SimpleXMLElement($xmlBody);
}

public function getIdOfElement(string $user, string $element): int {
$propfindResponse = $this->getElementResponse($user, $element);
$this->theHTTPStatusCodeShouldBe(207, "", $propfindResponse);
$responseXmlObject = new SimpleXMLElement($propfindResponse->getBody()->getContents());
$responseXmlObject->registerXPathNamespace(
'oc',
'http://owncloud.org/ns'
);
return (int)(string)$responseXmlObject->xpath('//oc:fileid')[0];
}

public function isElementExist(string $user, string $element): bool {
return $this->getElementResponse($user, $element)->getStatusCode() === 207;
}

/**
* @param string $path
* @param string $method
Expand Down