diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 6438a871fb..f19ae1a86e 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -406,6 +406,40 @@ trait WebDav { return $response; } + /*Returns the elements of a report command*/ + public function reportFolder($user, $path, $properties = null){ + $client = $this->getSabreClient($user); + + $body = [ 'body' => ' + + + + + + + + + + + + + + + + + + + + + 1 + + ']; + + $response = $client->request('REPORT', $this->makeSabrePath($user, $path), $body); + + return $response; + } + public function makeSabrePath($user, $path) { return $this->encodePath($this->getDavFilesPath($user) . $path); } @@ -637,7 +671,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 +714,25 @@ 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); + 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 5e31e1902f..a2ee579436 100644 --- a/build/integration/features/favorites.feature +++ b/build/integration/features/favorites.feature @@ -78,3 +78,15 @@ 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 | +