Merge pull request #6123 from nextcloud/cleanup-shareItem

Cleanup usage of shareItem in internal code base
This commit is contained in:
Morris Jobke 2017-08-15 13:57:00 +02:00 committed by GitHub
commit cf7c4a4439
9 changed files with 33 additions and 51 deletions

View File

@ -1209,7 +1209,7 @@ class ApiTest extends TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1); self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$id = PHP_INT_MAX - 1; $id = PHP_INT_MAX - 1;
\OCP\Share::shareItem('file', $id, \OCP\Share::SHARE_TYPE_LINK, self::TEST_FILES_SHARING_API_USER2, 31); \OC\Share\Share::shareItem('file', $id, \OCP\Share::SHARE_TYPE_LINK, self::TEST_FILES_SHARING_API_USER2, 31);
} }
/** /**
@ -1222,7 +1222,7 @@ class ApiTest extends TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1); self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
\OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_LINK, self::TEST_FILES_SHARING_API_USER2, 31); \OC\Share\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_LINK, self::TEST_FILES_SHARING_API_USER2, 31);
} }
public function datesProvider() { public function datesProvider() {

View File

@ -74,9 +74,9 @@ class BackendTest extends TestCase {
$fileinfo2 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->subsubfolder); $fileinfo2 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->subsubfolder);
$fileinfo3 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->subsubfolder . $this->filename); $fileinfo3 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->subsubfolder . $this->filename);
$this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo1['fileid'], \OCP\Share::SHARE_TYPE_USER, $this->assertTrue(\OC\Share\Share::shareItem('folder', $fileinfo1['fileid'], \OCP\Share::SHARE_TYPE_USER,
self::TEST_FILES_SHARING_API_USER2, 31)); self::TEST_FILES_SHARING_API_USER2, 31));
$this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER, $this->assertTrue(\OC\Share\Share::shareItem('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER,
self::TEST_FILES_SHARING_API_USER3, 31)); self::TEST_FILES_SHARING_API_USER3, 31));
$backend = new \OCA\Files_Sharing\ShareBackend\Folder(); $backend = new \OCA\Files_Sharing\ShareBackend\Folder();

View File

@ -136,7 +136,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase {
$fileId = $fileInfo->getId(); $fileId = $fileInfo->getId();
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ), \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared "test/sub" with user 2.' 'Failed asserting that user 1 successfully shared "test/sub" with user 2.'
); );
@ -159,7 +159,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase {
\OC\Share\Share::registerBackend('test', 'Test\Share\Backend'); \OC\Share\Share::registerBackend('test', 'Test\Share\Backend');
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ), \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared something with user 2.' 'Failed asserting that user 1 successfully shared something with user 2.'
); );

View File

@ -138,7 +138,7 @@ class ExpireSharesJobTest extends \Test\TestCase {
$fileInfo = $view->getFileInfo('files/test'); $fileInfo = $view->getFileInfo('files/test');
$this->assertNotNull( $this->assertNotNull(
\OCP\Share::shareItem('folder', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ), \OC\Share\Share::shareItem('folder', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared "test" by link.' 'Failed asserting that user 1 successfully shared "test" by link.'
); );
@ -192,7 +192,7 @@ class ExpireSharesJobTest extends \Test\TestCase {
$fileInfo = $view->getFileInfo('files/test'); $fileInfo = $view->getFileInfo('files/test');
$this->assertNotNull( $this->assertNotNull(
\OCP\Share::shareItem('folder', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ), \OC\Share\Share::shareItem('folder', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared "test" by link with user2.' 'Failed asserting that user 1 successfully shared "test" by link with user2.'
); );

View File

@ -351,11 +351,12 @@ class Share extends Constants {
* @param string $shareWith User or group the item is being shared with * @param string $shareWith User or group the item is being shared with
* @param int $permissions CRUDS * @param int $permissions CRUDS
* @param string $itemSourceName * @param string $itemSourceName
* @param \DateTime $expirationDate * @param \DateTime|null $expirationDate
* @param bool $passwordChanged * @param bool|null $passwordChanged
* @return boolean|string Returns true on success or false on failure, Returns token on success for links * @return boolean|string Returns true on success or false on failure, Returns token on success for links
* @throws \OC\HintException when the share type is remote and the shareWith is invalid * @throws \OC\HintException when the share type is remote and the shareWith is invalid
* @throws \Exception * @throws \Exception
* @since 5.0.0 - parameter $itemSourceName was added in 6.0.0, parameter $expirationDate was added in 7.0.0, parameter $passwordChanged added in 9.0.0
*/ */
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null, \DateTime $expirationDate = null, $passwordChanged = null) { public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null, \DateTime $expirationDate = null, $passwordChanged = null) {

View File

@ -167,25 +167,6 @@ class Share extends \OC\Share\Constants {
return \OC\Share\Share::getItemShared($itemType, $itemSource, $format, $parameters, $includeCollections); return \OC\Share\Share::getItemShared($itemType, $itemSource, $format, $parameters, $includeCollections);
} }
/**
* Share an item with a user, group, or via private link
* @param string $itemType
* @param string $itemSource
* @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string $shareWith User or group the item is being shared with
* @param int $permissions CRUDS
* @param string $itemSourceName
* @param \DateTime|null $expirationDate
* @param bool|null $passwordChanged
* @return bool|string Returns true on success or false on failure, Returns token on success for links
* @throws \OC\HintException when the share type is remote and the shareWith is invalid
* @throws \Exception
* @since 5.0.0 - parameter $itemSourceName was added in 6.0.0, parameter $expirationDate was added in 7.0.0, parameter $passwordChanged added in 9.0.0
*/
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null, \DateTime $expirationDate = null, $passwordChanged = null) {
return \OC\Share\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName, $expirationDate, $passwordChanged);
}
/** /**
* Unshare an item from a user, group, or delete a private link * Unshare an item from a user, group, or delete a private link
* @param string $itemType * @param string $itemType

View File

@ -1666,7 +1666,7 @@ class ViewTest extends \Test\TestCase {
$fileId = $view->getFileInfo('shareddir')->getId(); $fileId = $view->getFileInfo('shareddir')->getId();
$userObject = \OC::$server->getUserManager()->createUser('test2', 'IHateNonMockableStaticClasses'); $userObject = \OC::$server->getUserManager()->createUser('test2', 'IHateNonMockableStaticClasses');
$this->assertTrue(Share::shareItem('folder', $fileId, Share::SHARE_TYPE_USER, 'test2', Constants::PERMISSION_READ)); $this->assertTrue(\OC\Share\Share::shareItem('folder', $fileId, Share::SHARE_TYPE_USER, 'test2', Constants::PERMISSION_READ));
$this->assertFalse($view->rename('mount1', 'shareddir'), 'Cannot overwrite shared folder'); $this->assertFalse($view->rename('mount1', 'shareddir'), 'Cannot overwrite shared folder');
$this->assertFalse($view->rename('mount1', 'shareddir/sub'), 'Cannot move mount point into shared folder'); $this->assertFalse($view->rename('mount1', 'shareddir/sub'), 'Cannot move mount point into shared folder');

View File

@ -137,7 +137,7 @@ class ShareTest extends \Test\TestCase {
public function testShareInvalidShareType() { public function testShareInvalidShareType() {
$message = 'Share type foobar is not valid for test.txt'; $message = 'Share type foobar is not valid for test.txt';
try { try {
\OCP\Share::shareItem('test', 'test.txt', 'foobar', $this->user2, \OCP\Constants::PERMISSION_READ); \OC\Share\Share::shareItem('test', 'test.txt', 'foobar', $this->user2, \OCP\Constants::PERMISSION_READ);
} catch (\Exception $exception) { } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage()); $this->assertEquals($message, $exception->getMessage());
} }
@ -157,7 +157,7 @@ class ShareTest extends \Test\TestCase {
$fileId = $fileInfo->getId(); $fileId = $fileInfo->getId();
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), \OCP\Constants::PERMISSION_READ), \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared "test/sub" with user 2.' 'Failed asserting that user 1 successfully shared "test/sub" with user 2.'
); );
@ -195,7 +195,7 @@ class ShareTest extends \Test\TestCase {
$fileId = $fileInfo->getId(); $fileId = $fileInfo->getId();
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_CREATE), \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_CREATE),
'Failed asserting that user 1 successfully shared "test/sub1" with group 1.' 'Failed asserting that user 1 successfully shared "test/sub1" with group 1.'
); );
@ -208,7 +208,7 @@ class ShareTest extends \Test\TestCase {
$fileId = $fileInfo->getId(); $fileId = $fileInfo->getId();
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user4->getUID(), \OCP\Constants::PERMISSION_READ), \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user4->getUID(), \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared "test/sub1/sub2" with user 4.' 'Failed asserting that user 1 successfully shared "test/sub1/sub2" with user 4.'
); );
@ -233,12 +233,12 @@ class ShareTest extends \Test\TestCase {
$fileId = $fileInfo->getId(); $fileId = $fileInfo->getId();
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('folder', $folderId, \OCP\Share::SHARE_TYPE_GROUP, $this->group2->getGID(), \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_UPDATE), \OC\Share\Share::shareItem('folder', $folderId, \OCP\Share::SHARE_TYPE_GROUP, $this->group2->getGID(), \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_UPDATE),
'Failed asserting that user 1 successfully shared "test/sub1" with group 2.' 'Failed asserting that user 1 successfully shared "test/sub1" with group 2.'
); );
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('file', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), \OCP\Constants::PERMISSION_READ), \OC\Share\Share::shareItem('file', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared "test/sub1/file.txt" with user 2.' 'Failed asserting that user 1 successfully shared "test/sub1/file.txt" with user 2.'
); );
@ -258,7 +258,7 @@ class ShareTest extends \Test\TestCase {
*/ */
public function testShareWithGroupThenUnshare() { public function testShareWithGroupThenUnshare() {
\OC_User::setUserId($this->user5->getUID()); \OC_User::setUserId($this->user5->getUID());
\OCP\Share::shareItem( \OC\Share\Share::shareItem(
'test', 'test',
'test.txt', 'test.txt',
\OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_GROUP,
@ -401,7 +401,7 @@ class ShareTest extends \Test\TestCase {
} }
public function testGetShareSubItemsWhenUserNotInGroup() { public function testGetShareSubItemsWhenUserNotInGroup() {
\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), \OCP\Constants::PERMISSION_READ); \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), \OCP\Constants::PERMISSION_READ);
$result = \OCP\Share::getItemsSharedWithUser('test', $this->user2->getUID()); $result = \OCP\Share::getItemsSharedWithUser('test', $this->user2->getUID());
$this->assertCount(1, $result); $this->assertCount(1, $result);
@ -445,7 +445,7 @@ class ShareTest extends \Test\TestCase {
$config->setAppValue('core', 'shareapi_default_expire_date', 'yes'); $config->setAppValue('core', 'shareapi_default_expire_date', 'yes');
$config->setAppValue('core', 'shareapi_expire_after_n_days', '2'); $config->setAppValue('core', 'shareapi_expire_after_n_days', '2');
$token = \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ); $token = \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
$this->assertInternalType( $this->assertInternalType(
'string', 'string',
$token, $token,
@ -491,7 +491,7 @@ class ShareTest extends \Test\TestCase {
*/ */
public function testShareWithRemoteUserAndRemoteIsInvalid($remoteId) { public function testShareWithRemoteUserAndRemoteIsInvalid($remoteId) {
\OC_User::setUserId($this->user1->getUID()); \OC_User::setUserId($this->user1->getUID());
\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $remoteId, \OCP\Constants::PERMISSION_ALL); \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $remoteId, \OCP\Constants::PERMISSION_ALL);
} }
/** /**
@ -572,7 +572,7 @@ class ShareTest extends \Test\TestCase {
->with($this->stringStartsWith('http://' . $urlHost . '/ocs/v2.php/cloud/shares'), $this->anything()) ->with($this->stringStartsWith('http://' . $urlHost . '/ocs/v2.php/cloud/shares'), $this->anything())
->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]); ->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]);
\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith, \OCP\Constants::PERMISSION_READ); \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith, \OCP\Constants::PERMISSION_READ);
$shares = \OCP\Share::getItemShared('test', 'test.txt'); $shares = \OCP\Share::getItemShared('test', 'test.txt');
$share = array_shift($shares); $share = array_shift($shares);
@ -680,13 +680,13 @@ class ShareTest extends \Test\TestCase {
->with($this->stringStartsWith('https://localhost/ocs/v2.php/cloud/shares'), $this->anything()) ->with($this->stringStartsWith('https://localhost/ocs/v2.php/cloud/shares'), $this->anything())
->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]); ->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]);
\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, 'foo@localhost', \OCP\Constants::PERMISSION_READ); \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, 'foo@localhost', \OCP\Constants::PERMISSION_READ);
$shares = \OCP\Share::getItemShared('test', 'test.txt'); $shares = \OCP\Share::getItemShared('test', 'test.txt');
$share = array_shift($shares); $share = array_shift($shares);
//Try share again //Try share again
try { try {
\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, 'foo@localhost', \OCP\Constants::PERMISSION_READ); \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, 'foo@localhost', \OCP\Constants::PERMISSION_READ);
$this->fail('Identical remote shares are not allowed'); $this->fail('Identical remote shares are not allowed');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertEquals('Sharing test.txt failed, because this item is already shared with foo@localhost', $e->getMessage()); $this->assertEquals('Sharing test.txt failed, because this item is already shared with foo@localhost', $e->getMessage());
@ -714,11 +714,11 @@ class ShareTest extends \Test\TestCase {
$fileId = $fileInfo->getId(); $fileId = $fileInfo->getId();
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), \OCP\Constants::PERMISSION_ALL), \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared "test" with user 2.' 'Failed asserting that user 1 successfully shared "test" with user 2.'
); );
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), \OCP\Constants::PERMISSION_ALL), \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared "test" with user 3.' 'Failed asserting that user 1 successfully shared "test" with user 3.'
); );
@ -729,7 +729,7 @@ class ShareTest extends \Test\TestCase {
$fileId = $fileInfo->getId(); $fileId = $fileInfo->getId();
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user4->getUID(), \OCP\Constants::PERMISSION_ALL), \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user4->getUID(), \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared "test" with user 4.' 'Failed asserting that user 1 successfully shared "test" with user 4.'
); );
@ -743,7 +743,7 @@ class ShareTest extends \Test\TestCase {
$this->assertCount(3, $res); $this->assertCount(3, $res);
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user5->getUID(), \OCP\Constants::PERMISSION_ALL), \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user5->getUID(), \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared "test" with user 5.' 'Failed asserting that user 1 successfully shared "test" with user 5.'
); );
@ -767,7 +767,7 @@ class ShareTest extends \Test\TestCase {
$fileId = $fileInfo->getId(); $fileId = $fileInfo->getId();
try { try {
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user1->getUID(), \OCP\Constants::PERMISSION_ALL); \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user1->getUID(), \OCP\Constants::PERMISSION_ALL);
$this->fail(); $this->fail();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertEquals('Sharing /folder1 failed, because you can not share with yourself', $e->getMessage()); $this->assertEquals('Sharing /folder1 failed, because you can not share with yourself', $e->getMessage());
@ -785,13 +785,13 @@ class ShareTest extends \Test\TestCase {
$fileId = $fileInfo->getId(); $fileId = $fileInfo->getId();
$this->assertTrue( $this->assertTrue(
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), \OCP\Constants::PERMISSION_ALL), \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared "test" with user 2.' 'Failed asserting that user 1 successfully shared "test" with user 2.'
); );
\OC_User::setUserId($this->user2->getUID()); \OC_User::setUserId($this->user2->getUID());
try { try {
\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user1->getUID(), \OCP\Constants::PERMISSION_ALL); \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user1->getUID(), \OCP\Constants::PERMISSION_ALL);
$this->fail(); $this->fail();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertEquals('Sharing failed, because the user ' . $this->user1->getUID() . ' is the original sharer', $e->getMessage()); $this->assertEquals('Sharing failed, because the user ' . $this->user1->getUID() . ' is the original sharer', $e->getMessage());

View File

@ -306,7 +306,7 @@ class TagsTest extends \Test\TestCase {
$this->assertFalse($otherTagger->hasTag($testTag)); $this->assertFalse($otherTagger->hasTag($testTag));
\OC_User::setUserId($this->user->getUID()); \OC_User::setUserId($this->user->getUID());
\OCP\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ); \OC\Share\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
\OC_User::setUserId($otherUserId); \OC_User::setUserId($otherUserId);
$otherTagger = $otherTagMgr->load('test', array(), true); // Update tags, load shared ones. $otherTagger = $otherTagMgr->load('test', array(), true); // Update tags, load shared ones.