summaryrefslogtreecommitdiffstats
path: root/build/integration/features/bootstrap/Sharing.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-07-11 17:33:24 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-08-03 10:16:28 +0200
commit573f6de6a038f830b45d09c36061ac44a9018660 (patch)
tree733990c2e972b9a6edb5f2d4812a74f25a00a6e1 /build/integration/features/bootstrap/Sharing.php
parent04d546522876de430ffe02c12f8aa3f2ef4455fd (diff)
downloadnextcloud-server-573f6de6a038f830b45d09c36061ac44a9018660.tar.gz
nextcloud-server-573f6de6a038f830b45d09c36061ac44a9018660.zip
Add integration tests for merging received shares
Diffstat (limited to 'build/integration/features/bootstrap/Sharing.php')
-rw-r--r--build/integration/features/bootstrap/Sharing.php24
1 files changed, 12 insertions, 12 deletions
diff --git a/build/integration/features/bootstrap/Sharing.php b/build/integration/features/bootstrap/Sharing.php
index 9d230e35ac6..954c273bfc2 100644
--- a/build/integration/features/bootstrap/Sharing.php
+++ b/build/integration/features/bootstrap/Sharing.php
@@ -309,10 +309,10 @@ trait Sharing {
PHPUnit_Framework_Assert::assertEquals(False, $this->isFieldInResponse('share_with', "$user"));
}
- public function isUserOrGroupInSharedData($userOrGroup){
+ public function isUserOrGroupInSharedData($userOrGroup, $permissions = null){
$data = $this->response->xml()->data[0];
foreach($data as $element) {
- if ($element->share_with == $userOrGroup){
+ if ($element->share_with == $userOrGroup && ($permissions === null || $permissions == $element->permissions)){
return True;
}
}
@@ -320,13 +320,13 @@ trait Sharing {
}
/**
- * @Given /^file "([^"]*)" of user "([^"]*)" is shared with user "([^"]*)"$/
+ * @Given /^(file|folder|entry) "([^"]*)" of user "([^"]*)" is shared with user "([^"]*)"( with permissions ([\d]*))?$/
*
* @param string $filepath
* @param string $user1
* @param string $user2
*/
- public function assureFileIsShared($filepath, $user1, $user2){
+ public function assureFileIsShared($entry, $filepath, $user1, $user2, $withPerms = null, $permissions = null){
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares" . "?path=$filepath";
$client = new Client();
$options = [];
@@ -336,23 +336,23 @@ trait Sharing {
$options['auth'] = [$user1, $this->regularUser];
}
$this->response = $client->get($fullUrl, $options);
- if ($this->isUserOrGroupInSharedData($user2)){
+ if ($this->isUserOrGroupInSharedData($user2, $permissions)){
return;
} else {
- $this->createShare($user1, $filepath, 0, $user2, null, null, null);
+ $this->createShare($user1, $filepath, 0, $user2, null, null, $permissions);
}
$this->response = $client->get($fullUrl, $options);
- PHPUnit_Framework_Assert::assertEquals(True, $this->isUserOrGroupInSharedData($user2));
+ PHPUnit_Framework_Assert::assertEquals(True, $this->isUserOrGroupInSharedData($user2, $permissions));
}
/**
- * @Given /^file "([^"]*)" of user "([^"]*)" is shared with group "([^"]*)"$/
+ * @Given /^(file|folder|entry) "([^"]*)" of user "([^"]*)" is shared with group "([^"]*)"( with permissions ([\d]*))?$/
*
* @param string $filepath
* @param string $user
* @param string $group
*/
- public function assureFileIsSharedWithGroup($filepath, $user, $group){
+ public function assureFileIsSharedWithGroup($entry, $filepath, $user, $group, $withPerms = null, $permissions = null){
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares" . "?path=$filepath";
$client = new Client();
$options = [];
@@ -362,13 +362,13 @@ trait Sharing {
$options['auth'] = [$user, $this->regularUser];
}
$this->response = $client->get($fullUrl, $options);
- if ($this->isUserOrGroupInSharedData($group)){
+ if ($this->isUserOrGroupInSharedData($group, $permissions)){
return;
} else {
- $this->createShare($user, $filepath, 1, $group, null, null, null);
+ $this->createShare($user, $filepath, 1, $group, null, null, $permissions);
}
$this->response = $client->get($fullUrl, $options);
- PHPUnit_Framework_Assert::assertEquals(True, $this->isUserOrGroupInSharedData($group));
+ PHPUnit_Framework_Assert::assertEquals(True, $this->isUserOrGroupInSharedData($group, $permissions));
}
/**