Added unfavoriting tests and some rewording

This commit is contained in:
Sergio Bertolín 2016-06-15 10:16:27 +00:00 committed by Thomas Müller
parent 4232458652
commit 19b7ae673a
No known key found for this signature in database
GPG Key ID: A943788A3BBEC44C
2 changed files with 36 additions and 8 deletions

View File

@ -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\"");
}
}
@ -438,12 +438,19 @@ trait WebDav {
/**
* @When user :user favorites element :path
*/
public function userFavoritesFolder($user, $path){
$this->response = $this->favFolder($user, $path, 0, null);
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 favFolder($user, $path, $folderDepth, $properties = null){
public function changeFavStateOfAnElement($user, $path, $favOrUnfav, $folderDepth, $properties = null){
$fullUrl = substr($this->baseUrl, 0, -4);
$settings = array(
'baseUri' => $fullUrl,
@ -457,7 +464,7 @@ trait WebDav {
$client = new SClient($settings);
if (!$properties) {
$properties = [
'{http://owncloud.org/ns}favorite' => 1
'{http://owncloud.org/ns}favorite' => $favOrUnfav
];
}

View File

@ -2,7 +2,7 @@ Feature: favorite
Background:
Given using api version "1"
Scenario: Retrieving favorite info of a folder
Scenario: Favorite a folder
Given using dav path "remote.php/webdav"
And As an "admin"
And user "user0" exists
@ -11,11 +11,32 @@ Feature: favorite
|{http://owncloud.org/ns}favorite|
And the single response should contain a property "{http://owncloud.org/ns}favorite" with value "1"
Scenario: Retrieving favorite info of a file
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"
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 ""