diff options
-rw-r--r-- | build/integration/features/bootstrap/TagsContext.php | 8 | ||||
-rw-r--r-- | build/integration/features/bootstrap/WebDav.php | 49 | ||||
-rw-r--r-- | build/integration/features/favorites.feature | 56 | ||||
-rw-r--r-- | build/integration/features/tags.feature | 9 |
4 files changed, 117 insertions, 5 deletions
diff --git a/build/integration/features/bootstrap/TagsContext.php b/build/integration/features/bootstrap/TagsContext.php index 91fb585d640..46ce869c86a 100644 --- a/build/integration/features/bootstrap/TagsContext.php +++ b/build/integration/features/bootstrap/TagsContext.php @@ -516,13 +516,13 @@ class TagsContext implements \Behat\Behat\Context\Context { } /** - * @When :taggingUser adds the tag :tagName to :fileName shared by :sharingUser + * @When /^"([^"]*)" adds the tag "([^"]*)" to "([^"]*)" (shared|owned) by "([^"]*)"$/ * @param string $taggingUser * @param string $tagName * @param string $fileName * @param string $sharingUser */ - public function addsTheTagToSharedBy($taggingUser, $tagName, $fileName, $sharingUser) { + public function addsTheTagToSharedBy($taggingUser, $tagName, $fileName, $sharedOrOwnedBy, $sharingUser) { $fileId = $this->getFileIdForPath($fileName, $sharingUser); $tagId = $this->findTagIdByName($tagName); @@ -542,13 +542,13 @@ class TagsContext implements \Behat\Behat\Context\Context { } /** - * @Then :fileName shared by :sharingUser has the following tags + * @Then /^"([^"]*)" (shared|owned) by "([^"]*)" has the following tags$/ * @param string $fileName * @param string $sharingUser * @param TableNode $table * @throws \Exception */ - public function sharedByHasTheFollowingTags($fileName, $sharingUser, TableNode $table) { + public function sharedByHasTheFollowingTags($fileName, $sharedOrOwnedBy, $sharingUser, TableNode $table) { $loadedExpectedTags = $table->getTable(); $expectedTags = []; foreach($loadedExpectedTags as $expected) { diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 6438a871fb1..57ca638ec7f 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -406,6 +406,30 @@ trait WebDav { return $response; } + /* Returns the elements of a report command + * @param string $user + * @param string $path + * @param string $properties properties which needs to be included in the report + * @param string $filterRules filter-rules to choose what needs to appear in the report + */ + public function reportFolder($user, $path, $properties, $filterRules){ + $client = $this->getSabreClient($user); + + $body = '<?xml version="1.0" encoding="utf-8" ?> + <oc:filter-files xmlns:a="DAV:" xmlns:oc="http://owncloud.org/ns" > + <a:prop> + ' . $properties . ' + </a:prop> + <oc:filter-rules> + ' . $filterRules . ' + </oc:filter-rules> + </oc:filter-files>'; + + $response = $client->request('REPORT', $this->makeSabrePath($user, $path), $body); + $parsedResponse = $client->parseMultistatus($response['body']); + return $parsedResponse; + } + public function makeSabrePath($user, $path) { return $this->encodePath($this->getDavFilesPath($user) . $path); } @@ -637,7 +661,6 @@ trait WebDav { $this->asGetsPropertiesOfFolderWith($user, 'entry', $path, $propertiesTable); $pathETAG[$path] = $this->response['{DAV:}getetag']; $this->storedETAG[$user]= $pathETAG; - print_r($this->storedETAG[$user][$path]); } /** @@ -681,4 +704,28 @@ trait WebDav { } } } + + /** + * @Then /^user "([^"]*)" in folder "([^"]*)" should have favorited the following elements$/ + * @param string $user + * @param string $folder + * @param \Behat\Gherkin\Node\TableNode|null $expectedElements + */ + public function checkFavoritedElements($user, $folder, $expectedElements){ + $elementList = $this->reportFolder($user, + $folder, + '<oc:favorite/>', + '<oc:favorite>1</oc:favorite>'); + if ($expectedElements instanceof \Behat\Gherkin\Node\TableNode) { + $elementRows = $expectedElements->getRows(); + $elementsSimplified = $this->simplifyArray($elementRows); + foreach($elementsSimplified as $expectedElement) { + $webdavPath = "/" . $this->getDavFilesPath($user) . $expectedElement; + if (!array_key_exists($webdavPath,$elementList)){ + PHPUnit_Framework_Assert::fail("$webdavPath" . " is not in report answer"); + } + } + } + } + } diff --git a/build/integration/features/favorites.feature b/build/integration/features/favorites.feature index 5e31e1902f8..ab6bf51f25c 100644 --- a/build/integration/features/favorites.feature +++ b/build/integration/features/favorites.feature @@ -78,3 +78,59 @@ Feature: favorite |{http://owncloud.org/ns}favorite| And the single response should contain a property "{http://owncloud.org/ns}favorite" with value "" + Scenario: Get favorited elements of a folder + Given using old dav path + And As an "admin" + And user "user0" exists + When user "user0" favorites element "/FOLDER" + And user "user0" favorites element "/textfile0.txt" + And user "user0" favorites element "/textfile1.txt" + Then user "user0" in folder "/" should have favorited the following elements + | /FOLDER | + | /textfile0.txt | + | /textfile1.txt | + + Scenario: Get favorited elements of a folder using new path + Given using new dav path + And As an "admin" + And user "user0" exists + When user "user0" favorites element "/FOLDER" + And user "user0" favorites element "/textfile0.txt" + And user "user0" favorites element "/textfile1.txt" + Then user "user0" in folder "/" should have favorited the following elements + | /FOLDER | + | /textfile0.txt | + | /textfile1.txt | + + Scenario: Get favorited elements of a subfolder + Given using old dav path + And As an "admin" + And user "user0" exists + And user "user0" created a folder "/subfolder" + And User "user0" moves file "/textfile0.txt" to "/subfolder/textfile0.txt" + And User "user0" moves file "/textfile1.txt" to "/subfolder/textfile1.txt" + And User "user0" moves file "/textfile2.txt" to "/subfolder/textfile2.txt" + When user "user0" favorites element "/subfolder/textfile0.txt" + And user "user0" favorites element "/subfolder/textfile1.txt" + And user "user0" favorites element "/subfolder/textfile2.txt" + And user "user0" unfavorites element "/subfolder/textfile1.txt" + Then user "user0" in folder "/subfolder" should have favorited the following elements + | /subfolder/textfile0.txt | + | /subfolder/textfile2.txt | + + Scenario: Get favorited elements of a subfolder using new path + Given using old dav path + And As an "admin" + And user "user0" exists + And user "user0" created a folder "/subfolder" + And User "user0" moves file "/textfile0.txt" to "/subfolder/textfile0.txt" + And User "user0" moves file "/textfile1.txt" to "/subfolder/textfile1.txt" + And User "user0" moves file "/textfile2.txt" to "/subfolder/textfile2.txt" + When user "user0" favorites element "/subfolder/textfile0.txt" + And user "user0" favorites element "/subfolder/textfile1.txt" + And user "user0" favorites element "/subfolder/textfile2.txt" + And user "user0" unfavorites element "/subfolder/textfile1.txt" + Then user "user0" in folder "/subfolder" should have favorited the following elements + | /subfolder/textfile0.txt | + | /subfolder/textfile2.txt | + diff --git a/build/integration/features/tags.feature b/build/integration/features/tags.feature index d793c0d3c61..35784419080 100644 --- a/build/integration/features/tags.feature +++ b/build/integration/features/tags.feature @@ -425,3 +425,12 @@ Feature: tags Then The response should have a status code "201" And the user "user0" cannot assign the "not user-assignable" tag with name "TagWithGroups" + Scenario: Assign a normal tag to a file + Given user "user0" exists + And "admin" creates a "normal" tag with name "Etiqueta" + And As an "user0" + When "user0" adds the tag "Etiqueta" to "/textfile0.txt" owned by "user0" + Then The response should have a status code "201" + And "textfile0.txt" owned by "user0" has the following tags + | Etiqueta | + |