Skip to content

Commit 27450c9

Browse files
committed
test: proper resource existence check
Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com>
1 parent ac072be commit 27450c9

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

tests/acceptance/bootstrap/WebDav.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,20 +1264,18 @@ public function checkFileOrFolderDoesNotExistsForUser(
12641264
$type
12651265
);
12661266
$statusCode = $response->getStatusCode();
1267-
if ($statusCode < 400 || $statusCode > 499) {
1268-
try {
1269-
$responseXmlObject = HttpRequestHelper::getResponseXml(
1270-
$response,
1271-
__METHOD__
1272-
);
1273-
} catch (Exception $e) {
1274-
Assert::fail(
1275-
"$entry '$path' should not exist. But API returned $statusCode without XML in the body"
1276-
);
1277-
}
1267+
// when checking path with '..' it may return 405 Method Not Allowed
1268+
if ($statusCode === 404 || $statusCode === 405) {
1269+
return;
1270+
}
1271+
if ($statusCode === 207) {
1272+
$responseXmlObject = HttpRequestHelper::getResponseXml(
1273+
$response,
1274+
__METHOD__
1275+
);
12781276
Assert::assertTrue(
12791277
$this->isEtagValid($this->getEtagFromResponseXmlObject($responseXmlObject)),
1280-
"$entry '$path' should not exist. But API returned $statusCode without an etag in the body"
1278+
"$entry '$path' should not exist but found with invalid etag."
12811279
);
12821280
$isCollection = $responseXmlObject->xpath("//d:prop/d:resourcetype/d:collection");
12831281
if (\count($isCollection) === 0) {
@@ -1291,7 +1289,11 @@ public function checkFileOrFolderDoesNotExistsForUser(
12911289
"$entry '$path' should not exist. But it does."
12921290
);
12931291
}
1292+
return;
12941293
}
1294+
Assert::fail(
1295+
"$entry '$path' should not exist. But API returned $statusCode without XML in the body"
1296+
);
12951297
}
12961298

12971299
/**

0 commit comments

Comments
 (0)