Exemplo n.º 1
0
 /**
  * test unshare of a reshared file
  */
 function testDeleteReshare()
 {
     // user 1 shares a folder with user2
     \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
     $fileInfo1 = $this->view->getFileInfo($this->folder);
     $fileInfo2 = $this->view->getFileInfo($this->folder . '/' . $this->filename);
     $result1 = \OCP\Share::shareItem('folder', $fileInfo1['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
     $this->assertTrue($result1);
     // user2 shares a file from the folder as link
     \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
     $result2 = \OCP\Share::shareItem('file', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_LINK, null, 1);
     $this->assertTrue(is_string($result2));
     // test if we can unshare the link again
     $items = \OCP\Share::getItemShared('file', null);
     $this->assertEquals(1, count($items));
     $item = reset($items);
     $result3 = Share\Api::deleteShare(array('id' => $item['id']));
     $this->assertTrue($result3->succeeded());
     // cleanup
     \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
     $result = \OCP\Share::unshare('folder', $fileInfo1['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue($result);
 }
Exemplo n.º 2
0
 /**
  * @medium
  * @depends testCreateShare
  */
 function testDeleteShare()
 {
     $fileInfo = $this->view->getFileInfo($this->filename);
     \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
     \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, null, 1);
     $items = \OCP\Share::getItemShared('file', null);
     $this->assertEquals(2, count($items));
     foreach ($items as $item) {
         $result = Share\Api::deleteShare(array('id' => $item['id']));
         $this->assertTrue($result->succeeded());
     }
     $itemsAfterDelete = \OCP\Share::getItemShared('file', null);
     $this->assertTrue(empty($itemsAfterDelete));
 }