mirror of
https://github.com/owncloud/ocis
synced 2026-04-25 17:25:21 +02:00
test: make remote.php configurable
test: build dav paths test: fix paths test: merge method args test: add issue tags test: add new expected failure file test: merge expected-failure files before running tests
This commit is contained in:
@@ -272,7 +272,7 @@ class WebDavPropertiesContext implements Context {
|
||||
'0',
|
||||
$properties,
|
||||
null,
|
||||
$this->featureContext->getDavPathVersion() === 1 ? "public-files" : "public-files-new"
|
||||
"public-files"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -727,6 +727,8 @@ class WebDavPropertiesContext implements Context {
|
||||
*/
|
||||
public function valueOfItemOfPathShouldBe(string $user, string $xpath, string $path, string $expectedValue):void {
|
||||
$path = $this->featureContext->substituteInLineCodes($path, $user);
|
||||
$path = \ltrim($path, '/');
|
||||
$path = "/" . WebdavHelper::withRemotePhp($path);
|
||||
$fullXpath = "//d:response/d:href[.='$path']/following-sibling::d:propstat$xpath";
|
||||
$this->assertValueOfItemInResponseAboutUserIs(
|
||||
$fullXpath,
|
||||
@@ -769,8 +771,8 @@ class WebDavPropertiesContext implements Context {
|
||||
);
|
||||
|
||||
// The expected value can contain /%base_path%/ which can be empty some time
|
||||
// This will result in urls such as //remote.php, so replace that
|
||||
$expectedValue = preg_replace("/\/\/remote\.php/i", "/remote.php", $expectedValue);
|
||||
// This will result in urls starting from '//', so replace that with single'/'
|
||||
$expectedValue = preg_replace("/^\/\//i", "/", $expectedValue);
|
||||
Assert::assertEquals(
|
||||
$expectedValue,
|
||||
$value,
|
||||
@@ -811,9 +813,9 @@ class WebDavPropertiesContext implements Context {
|
||||
);
|
||||
|
||||
// The expected value can contain /%base_path%/ which can be empty some time
|
||||
// This will result in urls such as //remote.php, so replace that
|
||||
$expectedValue1 = preg_replace("/\/\/remote\.php/i", "/remote.php", $expectedValue1);
|
||||
$expectedValue2 = preg_replace("/\/\/remote\.php/i", "/remote.php", $expectedValue2);
|
||||
// This will result in urls starting from '//', so replace that with single'/'
|
||||
$expectedValue1 = preg_replace("/^\/\//i", "/", $expectedValue1);
|
||||
$expectedValue2 = preg_replace("/^\/\//i", "/", $expectedValue2);
|
||||
$expectedValues = [$expectedValue1, $expectedValue2];
|
||||
$isExpectedValueInMessage = \in_array($value, $expectedValues);
|
||||
Assert::assertTrue($isExpectedValueInMessage, "The actual value \"$value\" is not one of the expected values: \"$expectedValue1\" or \"$expectedValue2\"");
|
||||
@@ -896,6 +898,7 @@ class WebDavPropertiesContext implements Context {
|
||||
$user,
|
||||
['preg_quote' => ['/']]
|
||||
);
|
||||
$expectedHref = WebdavHelper::withRemotePhp($expectedHref);
|
||||
|
||||
$index = 0;
|
||||
while (true) {
|
||||
@@ -909,16 +912,12 @@ class WebDavPropertiesContext implements Context {
|
||||
);
|
||||
$value = $xmlPart[0]->__toString();
|
||||
$decodedValue = \rawurldecode($value);
|
||||
// for folders, decoded value will be like: "/owncloud/core/remote.php/webdav/strängé folder/"
|
||||
// expected href should be like: "remote.php/webdav/strängé folder/"
|
||||
// for files, decoded value will be like: "/owncloud/core/remote.php/webdav/strängé folder/file.txt"
|
||||
// expected href should be like: "remote.php/webdav/strängé folder/file.txt"
|
||||
$explodeDecoded = \explode('/', $decodedValue);
|
||||
// get the first item of the expected href.
|
||||
// i.e. remote.php from "remote.php/webdav/strängé folder/file.txt"
|
||||
// or dav from "dav/spaces/%spaceid%/C++ file.cpp"
|
||||
$explodeExpected = \explode('/', $expectedHref);
|
||||
$remotePhpIndex = \array_search($explodeExpected[0], $explodeDecoded);
|
||||
// 'dav' from "dav/spaces/%spaceid%/C++ file.cpp"
|
||||
$explodeExpected = \explode('/', $expectedHref)[0];
|
||||
|
||||
$remotePhpIndex = \array_search($explodeExpected, $explodeDecoded);
|
||||
if ($remotePhpIndex) {
|
||||
$explodedHrefPartArray = \array_slice($explodeDecoded, $remotePhpIndex);
|
||||
$actualHrefPart = \implode('/', $explodedHrefPartArray);
|
||||
@@ -955,6 +954,14 @@ class WebDavPropertiesContext implements Context {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$value = $xmlPart[0]->__toString();
|
||||
$callback = ($this->featureContext->isUsingSharingNG()) ? "shareNgGetLastCreatedLinkShareToken" : "getLastCreatedPublicShareToken";
|
||||
|
||||
if (\str_ends_with($xpath, "d:href")) {
|
||||
$pattern = \preg_replace("/^\//", "", $pattern);
|
||||
$pattern = \preg_replace("/^\^/", "", $pattern);
|
||||
$pattern = \ltrim($pattern, "\/");
|
||||
$withRemotePhp = \rtrim(WebdavHelper::withRemotePhp(""), "/");
|
||||
$pattern = "/^\/{$withRemotePhp}\/{$pattern}";
|
||||
}
|
||||
$pattern = $this->featureContext->substituteInLineCodes(
|
||||
$pattern,
|
||||
$user,
|
||||
|
||||
Reference in New Issue
Block a user