summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-06-16 12:52:51 +0200
committerGitHub <noreply@github.com>2016-06-16 12:52:51 +0200
commitc1729852e65b588893106ff3fdc2e88cb6ef9d89 (patch)
tree9af0829497b37277a0923b913b3a835dda461d8d
parentd36a1fed3e01bee25e9ed73fcf9a5ec881785ec6 (diff)
parent19b7ae673a8553621b3544aa57f153cf2b7c8ad4 (diff)
downloadnextcloud-server-c1729852e65b588893106ff3fdc2e88cb6ef9d89.tar.gz
nextcloud-server-c1729852e65b588893106ff3fdc2e88cb6ef9d89.zip
Merge pull request #24252 from owncloud/integration_test_favorites
Added favorites integration tests
-rw-r--r--build/integration/features/bootstrap/WebDav.php50
-rw-r--r--build/integration/features/favorites.feature42
2 files changed, 90 insertions, 2 deletions
diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php
index cd9584ad186..0abb8667739 100644
--- a/build/integration/features/bootstrap/WebDav.php
+++ b/build/integration/features/bootstrap/WebDav.php
@@ -214,7 +214,7 @@ trait WebDav {
}
$value = $keys[$key];
- if ($value !== $expectedValue) {
+ if ($value != $expectedValue) {
throw new \Exception("Property \"$key\" found with value \"$value\", expected \"$expectedValue\"");
}
}
@@ -434,5 +434,51 @@ trait WebDav {
$this->response = $ex->getResponse();
}
}
-}
+ /**
+ * @When user :user favorites element :path
+ */
+ public function userFavoritesElement($user, $path){
+ $this->response = $this->changeFavStateOfAnElement($user, $path, 1, 0, null);
+ }
+
+ /**
+ * @When user :user unfavorites element :path
+ */
+ public function userUnfavoritesElement($user, $path){
+ $this->response = $this->changeFavStateOfAnElement($user, $path, 0, 0, null);
+ }
+
+ /*Set the elements of a proppatch, $folderDepth requires 1 to see elements without children*/
+ public function changeFavStateOfAnElement($user, $path, $favOrUnfav, $folderDepth, $properties = null){
+ $fullUrl = substr($this->baseUrl, 0, -4);
+ $settings = array(
+ 'baseUri' => $fullUrl,
+ 'userName' => $user,
+ );
+ if ($user === 'admin') {
+ $settings['password'] = $this->adminUser[1];
+ } else {
+ $settings['password'] = $this->regularUser;
+ }
+ $client = new SClient($settings);
+ if (!$properties) {
+ $properties = [
+ '{http://owncloud.org/ns}favorite' => $favOrUnfav
+ ];
+ }
+
+ $response = $client->proppatch($this->davPath . '/' . ltrim($path, '/'), $properties, $folderDepth);
+ return $response;
+ }
+
+ /**
+ * @Then /^as "([^"]*)" gets properties of file "([^"]*)" with$/
+ * @param string $user
+ * @param string $path
+ * @param \Behat\Gherkin\Node\TableNode|null $propertiesTable
+ */
+ public function asGetsPropertiesOfFileWith($user, $path, $propertiesTable) {
+ $this->asGetsPropertiesOfFolderWith($user, $path, $propertiesTable);
+ }
+}
diff --git a/build/integration/features/favorites.feature b/build/integration/features/favorites.feature
new file mode 100644
index 00000000000..86643fdd1e2
--- /dev/null
+++ b/build/integration/features/favorites.feature
@@ -0,0 +1,42 @@
+Feature: favorite
+ Background:
+ Given using api version "1"
+
+ Scenario: Favorite a folder
+ Given using dav path "remote.php/webdav"
+ And As an "admin"
+ And user "user0" exists
+ When user "user0" favorites element "/FOLDER"
+ Then as "user0" gets properties of folder "/FOLDER" with
+ |{http://owncloud.org/ns}favorite|
+ And the single response should contain a property "{http://owncloud.org/ns}favorite" with value "1"
+
+ Scenario: Favorite and unfavorite a folder
+ Given using dav path "remote.php/webdav"
+ And As an "admin"
+ And user "user0" exists
+ When user "user0" favorites element "/FOLDER"
+ And user "user0" unfavorites element "/FOLDER"
+ Then as "user0" gets properties of folder "/FOLDER" with
+ |{http://owncloud.org/ns}favorite|
+ And the single response should contain a property "{http://owncloud.org/ns}favorite" with value ""
+
+ Scenario: Favorite a file
+ Given using dav path "remote.php/webdav"
+ And As an "admin"
+ And user "user0" exists
+ When user "user0" favorites element "/textfile0.txt"
+ Then as "user0" gets properties of file "/textfile0.txt" with
+ |{http://owncloud.org/ns}favorite|
+ And the single response should contain a property "{http://owncloud.org/ns}favorite" with value "1"
+
+ Scenario: Favorite and unfavorite a file
+ Given using dav path "remote.php/webdav"
+ And As an "admin"
+ And user "user0" exists
+ When user "user0" favorites element "/textfile0.txt"
+ And user "user0" unfavorites element "/textfile0.txt"
+ Then as "user0" gets properties of file "/textfile0.txt" with
+ |{http://owncloud.org/ns}favorite|
+ And the single response should contain a property "{http://owncloud.org/ns}favorite" with value ""
+