Browse Source

make sure that files are shared correctly before each test and unshared again after the test

tags/v6.0.0alpha2
Bjoern Schiessle 10 years ago
parent
commit
7626540679
1 changed files with 43 additions and 2 deletions
  1. 43
    2
      apps/files_sharing/tests/api.php

+ 43
- 2
apps/files_sharing/tests/api.php View File

@@ -147,6 +147,15 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {

$this->assertTrue(!empty($items));

$fileinfo = $this->view->getFileInfo($this->filename);

\OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);

$fileinfo = $this->view->getFileInfo($this->folder);

\OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, null);



}
@@ -157,12 +166,20 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
*/
function testGetAllShares() {

$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);

$result = Share\Api::getAllShares(array());

$this->assertTrue($result->succeeded());

// test should return two shares created from testCreateShare()
$this->assertTrue(count($result->getData()) === 2);
$this->assertTrue(count($result->getData()) === 1);

\OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
}

/**
@@ -173,6 +190,12 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {

$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);

$params = array('itemSource' => $fileInfo['fileid']);

$result = Share\Api::getShare($params);
@@ -180,7 +203,12 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
$this->assertTrue($result->succeeded());

// test should return one share created from testCreateShare()
$this->assertTrue(count($result->getData()) === 1);
$this->assertTrue(count($result->getData()) === 2);

\OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);

\OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, null);

}

@@ -190,6 +218,14 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
*/
function testUpdateShare() {

$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);

$linkShare = null;
@@ -261,6 +297,11 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
$this->assertTrue(is_array($newLinkShare));
$this->assertTrue(!empty($newLinkShare['share_with']));

\OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);

\OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, null);

}

/**

Loading…
Cancel
Save