Skip to content

Commit

Permalink
Merge pull request #38239 from saw-jan/sawjan
Browse files Browse the repository at this point in the history
[tests-only] Adds API tests to check the file deletion time
  • Loading branch information
phil-davis authored Dec 23, 2020
2 parents 588a1a8 + 25fd7ed commit 2d982b5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
12 changes: 12 additions & 0 deletions tests/acceptance/features/apiTrashbin/trashbinFilesFolders.feature
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,15 @@ Feature: files and folders exist in the trashbin after being deleted
| dav-path |
| old |
| new |

Scenario Outline: deleted file has appropriate deletion time information
Given using <dav-path> DAV path
And user "Alice" has deleted file "textfile0.txt"
When user "Alice" tries to list the trashbin content for user "Alice"
Then the last webdav response should contain the following elements
| path | mtime |
| /textfile0.txt | deleted_mtime |
Examples:
| dav-path |
| old |
| new |
22 changes: 17 additions & 5 deletions tests/acceptance/features/bootstrap/TrashbinContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,25 @@ public function theLastWebdavResponseShouldContainFollowingElements(TableNode $e
foreach ($elementRows as $expectedElement) {
$found = false;
$expectedPath = $expectedElement['path'];
foreach ($files as $file) {
if (\ltrim($expectedPath, "/") === \ltrim($file['original-location'], "/")) {
$found = true;
break;
$expectedMtime = $expectedElement['mtime'] === "deleted_mtime" ? $this->featureContext->getLastUploadDeleteTime() : $expectedElement['mtime'];

if (isset($expectedElement['mtime'])) {
foreach ($files as $file) {
if (\ltrim($expectedPath, "/") === \ltrim($file['original-location'], "/") && \ltrim($expectedMtime, "/") === \ltrim($file['mtime'], "/")) {
$found = true;
break;
}
}
Assert::assertTrue($found, "$expectedPath with mtime $expectedMtime expected to be listed in response but not found");
} else {
foreach ($files as $file) {
if (\ltrim($expectedPath, "/") === \ltrim($file['original-location'], "/")) {
$found = true;
break;
}
}
Assert::assertTrue($found, "$expectedPath expected to be listed in response but not found");
}
Assert::assertTrue($found, "$expectedPath expected to be listed in response but not found");
}
}

Expand Down
7 changes: 7 additions & 0 deletions tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ public function setLastUploadDeleteTime($lastUploadDeleteTime) {
$this->lastUploadDeleteTime = $lastUploadDeleteTime;
}

/**
* @return number
*/
public function getLastUploadDeleteTime() {
return $this->lastUploadDeleteTime;
}

/**
* @return SimpleXMLElement
*/
Expand Down

0 comments on commit 2d982b5

Please sign in to comment.