Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-10-05 13:36:16 +0300
committerJoas Schilling <nickvergessen@owncloud.com>2015-10-05 13:36:16 +0300
commitac5b3161e44729b746e3a365b1011156a63e8fb6 (patch)
treed03ac4eb7146747c71198b9cb717b775f441534f /tests
parent3bbb65998fed43728f3e67822d81a289a8886e17 (diff)
Add a unit test for "share a file inside a folder that is already shared"
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share/share.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 58a76470afa..f0dc921e969 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -533,6 +533,39 @@ class Test_Share extends \Test\TestCase {
$this->assertEquals(\OCP\Constants::PERMISSION_READ, $result['permissions']);
}
+ public function testSharingAFileInsideAFolderThatIsAlreadyShared() {
+ OC_User::setUserId($this->user1);
+ $view = new \OC\Files\View('/' . $this->user1 . '/');
+ $view->mkdir('files/test');
+ $view->mkdir('files/test/sub1');
+ $view->file_put_contents('files/test/sub1/file.txt', 'abc');
+
+ $folderInfo = $view->getFileInfo('files/test/sub1');
+ $folderId = $folderInfo->getId();
+
+ $fileInfo = $view->getFileInfo('files/test/sub1/file.txt');
+ $fileId = $fileInfo->getId();
+
+ $this->assertTrue(
+ OCP\Share::shareItem('folder', $folderId, OCP\Share::SHARE_TYPE_GROUP, $this->group2, \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_UPDATE),
+ 'Failed asserting that user 1 successfully shared "test/sub1" with group 2.'
+ );
+
+ $this->assertTrue(
+ OCP\Share::shareItem('file', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
+ 'Failed asserting that user 1 successfully shared "test/sub1/file.txt" with user 2.'
+ );
+
+ $result = \OCP\Share::getItemsSharedWithUser('file', $this->user2);
+ $this->assertCount(2, $result);
+
+ foreach ($result as $share) {
+ $itemName = substr($share['path'], strrpos($share['path'], '/'));
+ $this->assertSame($itemName, $share['file_target'], 'Asserting that the file_target is the last segment of the path');
+ $this->assertSame($share['item_target'], '/' . $share['item_source'], 'Asserting that the item is the item that was shared');
+ }
+ }
+
protected function shareUserOneTestFileWithGroupOne() {
OC_User::setUserId($this->user1);
$this->assertTrue(