diff options
author | Joas Schilling <coding@schilljs.com> | 2020-06-24 17:49:16 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-06-24 17:49:16 +0300 |
commit | 89ed2c37bf656ceb772bb6759c8977a7dc78b3fb (patch) | |
tree | 4a467f829fcc748531cad54e7c08e06dd98d1b7d | |
parent | 654cd18864c943d9ff93c2e6151bb6529fa44513 (diff) |
Update share type constant usage
Signed-off-by: Joas Schilling <coding@schilljs.com>
74 files changed, 1028 insertions, 996 deletions
diff --git a/apps/admin_audit/lib/Actions/Sharing.php b/apps/admin_audit/lib/Actions/Sharing.php index 1384d6f2350..8652ff7d195 100644 --- a/apps/admin_audit/lib/Actions/Sharing.php +++ b/apps/admin_audit/lib/Actions/Sharing.php @@ -30,7 +30,7 @@ declare(strict_types=1); namespace OCA\AdminAudit\Actions; -use OCP\Share; +use OCP\Share\IShare; /** * Class Sharing logs the sharing actions @@ -44,7 +44,7 @@ class Sharing extends Action { * @param array $params */ public function shared(array $params) { - if ($params['shareType'] === Share::SHARE_TYPE_LINK) { + if ($params['shareType'] === IShare::TYPE_LINK) { $this->log( 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', $params, @@ -56,7 +56,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_USER) { + } elseif ($params['shareType'] === IShare::TYPE_USER) { $this->log( 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', $params, @@ -69,7 +69,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) { + } elseif ($params['shareType'] === IShare::TYPE_GROUP) { $this->log( 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', $params, @@ -82,7 +82,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_ROOM) { + } elseif ($params['shareType'] === IShare::TYPE_ROOM) { $this->log( 'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)', $params, @@ -95,7 +95,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_EMAIL) { + } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { $this->log( 'The %s "%s" with ID "%s" has been shared to the email recipient "%s" with permissions "%s" (Share ID: %s)', $params, @@ -108,7 +108,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_CIRCLE) { + } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { $this->log( 'The %s "%s" with ID "%s" has been shared to the circle "%s" with permissions "%s" (Share ID: %s)', $params, @@ -121,7 +121,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE) { + } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { $this->log( 'The %s "%s" with ID "%s" has been shared to the remote user "%s" with permissions "%s" (Share ID: %s)', $params, @@ -134,7 +134,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) { + } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { $this->log( 'The %s "%s" with ID "%s" has been shared to the remote group "%s" with permissions "%s" (Share ID: %s)', $params, @@ -156,7 +156,7 @@ class Sharing extends Action { * @param array $params */ public function unshare(array $params) { - if ($params['shareType'] === Share::SHARE_TYPE_LINK) { + if ($params['shareType'] === IShare::TYPE_LINK) { $this->log( 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', $params, @@ -167,7 +167,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_USER) { + } elseif ($params['shareType'] === IShare::TYPE_USER) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', $params, @@ -179,7 +179,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) { + } elseif ($params['shareType'] === IShare::TYPE_GROUP) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', $params, @@ -191,7 +191,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_ROOM) { + } elseif ($params['shareType'] === IShare::TYPE_ROOM) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)', $params, @@ -203,7 +203,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_EMAIL) { + } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the email recipient "%s" (Share ID: %s)', $params, @@ -215,7 +215,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_CIRCLE) { + } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the circle "%s" (Share ID: %s)', $params, @@ -227,7 +227,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE) { + } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the remote user "%s" (Share ID: %s)', $params, @@ -239,7 +239,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) { + } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the remote group "%s" (Share ID: %s)', $params, diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index 83f90fa4ba2..9d7052b5c2d 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -42,7 +42,7 @@ use OC\Files\View; use OCA\DAV\Connector\Sabre\Exception\InvalidPath; use OCP\Files\FileInfo; use OCP\Files\StorageNotAvailableException; -use OCP\Share; +use OCP\Share\IShare; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; @@ -313,10 +313,10 @@ abstract class Node implements \Sabre\DAV\INode { } $types = [ - Share::SHARE_TYPE_USER, - Share::SHARE_TYPE_GROUP, - Share::SHARE_TYPE_CIRCLE, - Share::SHARE_TYPE_ROOM + IShare::TYPE_USER, + IShare::TYPE_GROUP, + IShare::TYPE_CIRCLE, + IShare::TYPE_ROOM ]; foreach ($types as $shareType) { diff --git a/apps/dav/lib/Connector/Sabre/SharesPlugin.php b/apps/dav/lib/Connector/Sabre/SharesPlugin.php index 63c204fda4e..3d80d8674ba 100644 --- a/apps/dav/lib/Connector/Sabre/SharesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/SharesPlugin.php @@ -113,13 +113,13 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin { private function getShare(\OCP\Files\Node $node): array { $result = []; $requestedShareTypes = [ - \OCP\Share::SHARE_TYPE_USER, - \OCP\Share::SHARE_TYPE_GROUP, - \OCP\Share::SHARE_TYPE_LINK, - \OCP\Share::SHARE_TYPE_REMOTE, - \OCP\Share::SHARE_TYPE_EMAIL, - \OCP\Share::SHARE_TYPE_ROOM, - \OCP\Share::SHARE_TYPE_CIRCLE, + IShare::TYPE_USER, + IShare::TYPE_GROUP, + IShare::TYPE_LINK, + IShare::TYPE_REMOTE, + IShare::TYPE_EMAIL, + IShare::TYPE_ROOM, + IShare::TYPE_CIRCLE, ]; foreach ($requestedShareTypes as $requestedShareType) { $shares = $this->shareManager->getSharesBy( diff --git a/apps/dav/tests/unit/Connector/PublicAuthTest.php b/apps/dav/tests/unit/Connector/PublicAuthTest.php index bcec84d414c..d3d17b03673 100644 --- a/apps/dav/tests/unit/Connector/PublicAuthTest.php +++ b/apps/dav/tests/unit/Connector/PublicAuthTest.php @@ -134,7 +134,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_REMOTE); + $share->method('getShareType')->willReturn(IShare::TYPE_REMOTE); $this->shareManager->expects($this->once()) ->method('getShareByToken') @@ -150,7 +150,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $this->shareManager->expects($this->once()) ->method('getShareByToken') @@ -172,7 +172,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_EMAIL); + $share->method('getShareType')->willReturn(IShare::TYPE_EMAIL); $this->shareManager->expects($this->once()) ->method('getShareByToken') @@ -194,7 +194,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $share->method('getId')->willReturn('42'); $this->shareManager->expects($this->once()) @@ -220,7 +220,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $share->method('getId')->willReturn('42'); $this->shareManager->expects($this->once()) @@ -247,7 +247,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_EMAIL); + $share->method('getShareType')->willReturn(IShare::TYPE_EMAIL); $share->method('getId')->willReturn('42'); $this->shareManager->expects($this->once()) diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php index 8a24c1ae4bb..b1fb8d97f74 100644 --- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php @@ -272,16 +272,16 @@ class SharesPluginTest extends \Test\TestCase { public function sharesGetPropertiesDataProvider() { return [ [[]], - [[\OCP\Share::SHARE_TYPE_USER]], - [[\OCP\Share::SHARE_TYPE_GROUP]], - [[\OCP\Share::SHARE_TYPE_LINK]], - [[\OCP\Share::SHARE_TYPE_REMOTE]], - [[\OCP\Share::SHARE_TYPE_ROOM]], - [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP]], - [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK]], - [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_LINK]], - [[\OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK]], - [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_REMOTE]], + [[IShare::TYPE_USER]], + [[IShare::TYPE_GROUP]], + [[IShare::TYPE_LINK]], + [[IShare::TYPE_REMOTE]], + [[IShare::TYPE_ROOM]], + [[IShare::TYPE_USER, IShare::TYPE_GROUP]], + [[IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK]], + [[IShare::TYPE_USER, IShare::TYPE_LINK]], + [[IShare::TYPE_GROUP, IShare::TYPE_LINK]], + [[IShare::TYPE_USER, IShare::TYPE_REMOTE]], ]; } diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 228fab305b9..3cc9c8e58c1 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -171,7 +171,7 @@ class FederatedShareProvider implements IShareProvider { $sharedBy = $share->getSharedBy(); $shareType = $share->getShareType(); - if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP && + if ($shareType === IShare::TYPE_REMOTE_GROUP && !$this->isOutgoingServer2serverGroupShareEnabled() ) { $message = 'It is not allowed to send federated group shares from this server.'; @@ -183,8 +183,8 @@ class FederatedShareProvider implements IShareProvider { /* * Check if file is not already shared with the remote user */ - $alreadyShared = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_REMOTE, $share->getNode(), 1, 0); - $alreadySharedGroup = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_REMOTE_GROUP, $share->getNode(), 1, 0); + $alreadyShared = $this->getSharedWith($shareWith, IShare::TYPE_REMOTE, $share->getNode(), 1, 0); + $alreadySharedGroup = $this->getSharedWith($shareWith, IShare::TYPE_REMOTE_GROUP, $share->getNode(), 1, 0); if (!empty($alreadyShared) || !empty($alreadySharedGroup)) { $message = 'Sharing %1$s failed, because this item is already shared with %2$s'; $message_t = $this->l->t('Sharing %1$s failed, because this item is already shared with %2$s', [$share->getNode()->getName(), $shareWith]); @@ -628,7 +628,7 @@ class FederatedShareProvider implements IShareProvider { $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->andWhere( - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE)) + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE)) ); /** @@ -945,7 +945,7 @@ class FederatedShareProvider implements IShareProvider { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE))) ->andWhere($qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid))) ->execute(); } @@ -1072,7 +1072,7 @@ class FederatedShareProvider implements IShareProvider { $qb = $this->dbConnection->getQueryBuilder(); $qb->select('share_with', 'token', 'file_source') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE))) ->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php index 0e9b9dbed62..d427e324e1f 100644 --- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php @@ -209,7 +209,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { } // FIXME this should be a method in the user management instead - if ($shareType === Share::SHARE_TYPE_USER) { + if ($shareType === IShare::TYPE_USER) { $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); Util::emitHook( '\OCA\Files_Sharing\API\Server2Server', @@ -225,7 +225,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { \OC_Util::setupFS($shareWith); } - if ($shareType === Share::SHARE_TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) { + if ($shareType === IShare::TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) { throw new ProviderCouldNotAddShareException('Group does not exists', '',Http::STATUS_BAD_REQUEST); } @@ -247,7 +247,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { $externalManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId); $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); - if ($shareType === Share::SHARE_TYPE_USER) { + if ($shareType === IShare::TYPE_USER) { $event = $this->activityManager->generateEvent(); $event->setApp('files_sharing') ->setType('remote_share') @@ -324,9 +324,9 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @return int */ private function mapShareTypeToNextcloud($shareType) { - $result = Share::SHARE_TYPE_USER; + $result = IShare::TYPE_USER; if ($shareType === 'group') { - $result = Share::SHARE_TYPE_GROUP; + $result = IShare::TYPE_GROUP; } return $result; @@ -585,7 +585,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { ->where($qb->expr()->eq('parent', $qb->createNamedParameter((int)$share['id']))); $qb->execute(); - if ((int)$share['share_type'] === Share::SHARE_TYPE_USER) { + if ((int)$share['share_type'] === IShare::TYPE_USER) { if ($share['accepted']) { $path = trim($mountpoint, '/'); } else { @@ -792,7 +792,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { */ protected function verifyShare(IShare $share, $token) { if ( - $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE && + $share->getShareType() === IShare::TYPE_REMOTE && $share->getToken() === $token ) { return true; diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 825b8382d1e..2b04428848a 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -45,6 +45,7 @@ use OCP\IL10N; use OCP\ILogger; use OCP\IUserManager; use OCP\Share\IManager; +use OCP\Share\IShare; /** * Class FederatedShareProviderTest @@ -149,7 +150,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->tokenHandler->method('generateToken')->willReturn('token'); @@ -186,7 +187,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $stmt->closeCursor(); $expected = [ - 'share_type' => \OCP\Share::SHARE_TYPE_REMOTE, + 'share_type' => IShare::TYPE_REMOTE, 'share_with' => 'user@server.com', 'uid_owner' => 'shareOwner', 'uid_initiator' => 'sharedBy', @@ -200,7 +201,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->assertArraySubset($expected, $data); $this->assertEquals($data['id'], $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_REMOTE, $share->getShareType()); + $this->assertEquals(IShare::TYPE_REMOTE, $share->getShareType()); $this->assertEquals('user@server.com', $share->getSharedWith()); $this->assertEquals('sharedBy', $share->getSharedBy()); $this->assertEquals('shareOwner', $share->getShareOwner()); @@ -221,7 +222,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->tokenHandler->method('generateToken')->willReturn('token'); @@ -278,7 +279,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->tokenHandler->method('generateToken')->willReturn('token'); @@ -378,7 +379,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->tokenHandler->method('generateToken')->willReturn('token'); @@ -447,7 +448,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy($sharedBy) ->setShareOwner($owner) ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->tokenHandler->method('generateToken')->willReturn('token'); @@ -518,7 +519,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share); @@ -527,11 +528,11 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy2') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share2); - $shares = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_REMOTE, null, false, -1, 0); + $shares = $this->provider->getSharesBy('sharedBy', IShare::TYPE_REMOTE, null, false, -1, 0); $this->assertCount(1, $shares); $this->assertEquals('user@server.com', $shares[0]->getSharedWith()); @@ -558,7 +559,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share); @@ -571,11 +572,11 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node2); $this->provider->create($share2); - $shares = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_REMOTE, $node2, false, -1, 0); + $shares = $this->provider->getSharesBy('sharedBy', IShare::TYPE_REMOTE, $node2, false, -1, 0); $this->assertCount(1, $shares); $this->assertEquals(43, $shares[0]->getNodeId()); @@ -601,7 +602,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('shareOwner') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share); @@ -610,11 +611,11 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share2); - $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_REMOTE, null, true, -1, 0); + $shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_REMOTE, null, true, -1, 0); $this->assertCount(2, $shares); } @@ -647,7 +648,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share); @@ -656,11 +657,11 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share2); - $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_REMOTE, null, true, 1, 1); + $shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_REMOTE, null, true, 1, 1); $this->assertCount(1, $shares); $this->assertEquals('user2@server.com', $shares[0]->getSharedWith()); @@ -688,7 +689,7 @@ class FederatedShareProviderTest extends \Test\TestCase { public function testDeleteUser($owner, $initiator, $recipient, $deletedUser, $rowDeleted) { $qb = $this->connection->getQueryBuilder(); $qb->insert('share') - ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE)) + ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE)) ->setValue('uid_owner', $qb->createNamedParameter($owner)) ->setValue('uid_initiator', $qb->createNamedParameter($initiator)) ->setValue('share_with', $qb->createNamedParameter($recipient)) @@ -699,7 +700,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $id = $qb->getLastInsertId(); - $this->provider->userDeleted($deletedUser, \OCP\Share::SHARE_TYPE_REMOTE); + $this->provider->userDeleted($deletedUser, IShare::TYPE_REMOTE); $qb = $this->connection->getQueryBuilder(); $qb->select('*') @@ -847,7 +848,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy($u1->getUID()) ->setShareOwner($u1->getUID()) ->setPermissions(\OCP\Constants::PERMISSION_READ) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($file1); $this->provider->create($share1); @@ -856,7 +857,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy($u2->getUID()) ->setShareOwner($u1->getUID()) ->setPermissions(\OCP\Constants::PERMISSION_READ) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($file2); $this->provider->create($share2); @@ -903,7 +904,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy($u1->getUID()) ->setShareOwner($u1->getUID()) ->setPermissions(\OCP\Constants::PERMISSION_READ) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($file1); $this->provider->create($share1); @@ -912,7 +913,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy($u1->getUID()) ->setShareOwner($u1->getUID()) ->setPermissions(\OCP\Constants::PERMISSION_READ) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($file1); $this->provider->create($share2); diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 2aa3b777225..2add685133e 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -52,6 +52,7 @@ use OCP\IPreview; use OCP\IRequest; use OCP\IUserSession; use OCP\Share\IManager; +use OCP\Share\IShare; /** * Class ApiController @@ -216,12 +217,12 @@ class ApiController extends Controller { $userId = $this->userSession->getUser()->getUID(); $shareTypes = []; $requestedShareTypes = [ - \OCP\Share::SHARE_TYPE_USER, - \OCP\Share::SHARE_TYPE_GROUP, - \OCP\Share::SHARE_TYPE_LINK, - \OCP\Share::SHARE_TYPE_REMOTE, - \OCP\Share::SHARE_TYPE_EMAIL, - \OCP\Share::SHARE_TYPE_ROOM + IShare::TYPE_USER, + IShare::TYPE_GROUP, + IShare::TYPE_LINK, + IShare::TYPE_REMOTE, + IShare::TYPE_EMAIL, + IShare::TYPE_ROOM ]; foreach ($requestedShareTypes as $requestedShareType) { // one of each type is enough to find out about the types diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index 5bec5200b63..535822b999c 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -41,6 +41,7 @@ use OCP\Files\InvalidPathException; use OCP\Files\Mount\IMountManager; use OCP\IUser; use OCP\Share\IManager as IShareManager; +use OCP\Share\IShare; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Output\OutputInterface; @@ -238,7 +239,7 @@ class OwnershipTransferService { $shares = []; $progress = new ProgressBar($output); - foreach ([\OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_LINK, \OCP\Share::SHARE_TYPE_REMOTE, \OCP\Share::SHARE_TYPE_ROOM] as $shareType) { + foreach ([IShare::TYPE_GROUP, IShare::TYPE_USER, IShare::TYPE_LINK, IShare::TYPE_REMOTE, IShare::TYPE_ROOM] as $shareType) { $offset = 0; while (true) { $sharePage = $this->shareManager->getSharesBy($sourceUid, $shareType, null, true, 50, $offset); @@ -290,7 +291,7 @@ class OwnershipTransferService { foreach ($shares as $share) { try { - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && + if ($share->getShareType() === IShare::TYPE_USER && $share->getSharedWith() === $destinationUid) { // Unmount the shares before deleting, so we don't try to get the storage later on. $shareMountPoint = $this->mountManager->find('/' . $destinationUid . '/files' . $share->getTarget()); diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php index bb33711c757..9b367e06544 100644 --- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php +++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php @@ -139,11 +139,11 @@ class DeletedShareAPIController extends OCSController { $result['expiration'] = $expiration->format('Y-m-d 00:00:00'); } - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + if ($share->getShareType() === IShare::TYPE_GROUP) { $group = $this->groupManager->get($share->getSharedWith()); $result['share_with'] = $share->getSharedWith(); $result['share_with_displayname'] = $group !== null ? $group->getDisplayName() : $share->getSharedWith(); - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM) { + } elseif ($share->getShareType() === IShare::TYPE_ROOM) { $result['share_with'] = $share->getSharedWith(); $result['share_with_displayname'] = ''; @@ -160,8 +160,8 @@ class DeletedShareAPIController extends OCSController { * @NoAdminRequired */ public function index(): DataResponse { - $groupShares = $this->shareManager->getDeletedSharedWith($this->userId, \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0); - $roomShares = $this->shareManager->getDeletedSharedWith($this->userId, \OCP\Share::SHARE_TYPE_ROOM, null, -1, 0); + $groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0); + $roomShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_ROOM, null, -1, 0); $shares = array_merge($groupShares, $roomShares); diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 2c6b043c028..9e4e591e40d 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -73,6 +73,7 @@ use OCP\IUserManager; use OCP\Share; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager as ShareManager; +use OCP\Share\IShare; use OCP\Template; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -701,7 +702,7 @@ class ShareController extends AuthPublicShareController { $parameters = [$userPath]; - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { + if ($share->getShareType() === IShare::TYPE_EMAIL) { if ($node instanceof \OCP\Files\File) { $subject = Downloads::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED; } else { diff --git a/apps/files_sharing/lib/ExpireSharesJob.php b/apps/files_sharing/lib/ExpireSharesJob.php index 4ca3b80e343..c2916d260b3 100644 --- a/apps/files_sharing/lib/ExpireSharesJob.php +++ b/apps/files_sharing/lib/ExpireSharesJob.php @@ -25,6 +25,7 @@ namespace OCA\Files_Sharing; use OC\BackgroundJob\TimedJob; +use OCP\Share\IShare; /** * Delete all shares that are expired @@ -59,7 +60,7 @@ class ExpireSharesJob extends TimedJob { ->from('share') ->where( $qb->expr()->andX( - $qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)), + $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_LINK)), $qb->expr()->lte('expiration', $qb->expr()->literal($now)), $qb->expr()->orX( $qb->expr()->eq('item_type', $qb->expr()->literal('file')), @@ -70,7 +71,7 @@ class ExpireSharesJob extends TimedJob { $shares = $qb->execute(); while ($share = $shares->fetch()) { - \OC\Share\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); + \OC\Share\Share::unshare($share['item_type'], $share['file_source'], IShare::TYPE_LINK, null, $share['uid_owner']); } $shares->closeCursor(); } diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index e7ddf6c3a74..943b5abfe01 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -247,9 +247,9 @@ class Manager { $validShare = is_array($share) && isset($share['share_type']) && isset($share['user']); // check if the user is allowed to access it - if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_USER && $share['user'] === $this->uid) { + if ($validShare && (int)$share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) { return $share; - } elseif ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { + } elseif ($validShare && (int)$share['share_type'] === IShare::TYPE_GROUP) { $user = $this->userManager->get($this->uid); if ($this->groupManager->get($share['user'])->inGroup($user)) { return $share; @@ -277,7 +277,7 @@ class Manager { $hash = md5($mountPoint); $userShareAccepted = false; - if ((int)$share['share_type'] === Share::SHARE_TYPE_USER) { + if ((int)$share['share_type'] === IShare::TYPE_USER) { $acceptShare = $this->connection->prepare(' UPDATE `*PREFIX*share_external` SET `accepted` = ?, @@ -321,7 +321,7 @@ class Manager { $share = $this->getShare($id); $result = false; - if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_USER) { + if ($share && (int)$share['share_type'] === IShare::TYPE_USER) { $removeShare = $this->connection->prepare(' DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?'); $removeShare->execute([$id, $this->uid]); @@ -329,7 +329,7 @@ class Manager { $this->processNotification($id); $result = true; - } elseif ($share && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { + } elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) { $result = $this->writeShareToDb( $share['remote'], $share['share_token'], @@ -517,7 +517,7 @@ class Manager { $share = $getShare->fetch(); $getShare->closeCursor(); - if ($result && $share !== false && (int)$share['share_type'] === Share::SHARE_TYPE_USER) { + if ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_USER) { try { $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); } catch (\Throwable $e) { @@ -530,7 +530,7 @@ class Manager { WHERE `id` = ? '); $result = (bool)$query->execute([(int)$share['id']]); - } elseif ($result && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { + } elseif ($result && (int)$share['share_type'] === IShare::TYPE_GROUP) { $query = $this->connection->prepare(' UPDATE `*PREFIX*share_external` SET `accepted` = ? diff --git a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php index 237c6aca243..a4eaa5b3989 100644 --- a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php +++ b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php @@ -28,7 +28,7 @@ use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; -use OCP\Share; +use OCP\Share\IShare; /** * Class OwncloudGuestShareType @@ -69,8 +69,8 @@ class OwncloudGuestShareType implements IRepairStep { $query = $this->connection->getQueryBuilder(); $query->update('share') - ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) - ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL))); + ->set('share_type', $query->createNamedParameter(IShare::TYPE_GUEST)) + ->where($query->expr()->eq('share_type', $query->createNamedParameter(IShare::TYPE_EMAIL))); $query->execute(); } diff --git a/apps/files_sharing/lib/Migration/SetPasswordColumn.php b/apps/files_sharing/lib/Migration/SetPasswordColumn.php index 5580bd46a5b..859c49f2991 100644 --- a/apps/files_sharing/lib/Migration/SetPasswordColumn.php +++ b/apps/files_sharing/lib/Migration/SetPasswordColumn.php @@ -27,7 +27,7 @@ use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; -use OCP\Share; +use OCP\Share\IShare; /** * Class SetPasswordColumn @@ -70,7 +70,7 @@ class SetPasswordColumn implements IRepairStep { $query ->update('share') ->set('password', 'share_with') - ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK))) + ->where($query->expr()->eq('share_type', $query->createNamedParameter(IShare::TYPE_LINK))) ->andWhere($query->expr()->isNotNull('share_with')); $result = $query->execute(); @@ -83,7 +83,7 @@ class SetPasswordColumn implements IRepairStep { $clearQuery ->update('share') ->set('share_with', $clearQuery->createNamedParameter(null)) - ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK))); + ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(IShare::TYPE_LINK))); $clearQuery->execute(); } diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index 82d74479d4b..bbb9da3a775 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -75,10 +75,10 @@ class MountProvider implements IMountProvider { * @return \OCP\Files\Mount\IMountPoint[] */ public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) { - $shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1); - $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1)); - $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)); - $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_ROOM, null, -1)); + $shares = $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_USER, null, -1); + $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_GROUP, null, -1)); + $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_CIRCLE, null, -1)); + $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_ROOM, null, -1)); // filter out excluded shares and group shares that includes self $shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) { diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php index a0d7e448be4..60deebc5c01 100644 --- a/apps/files_sharing/lib/ShareBackend/File.php +++ b/apps/files_sharing/lib/ShareBackend/File.php @@ -36,6 +36,7 @@ namespace OCA\Files_Sharing\ShareBackend; use OCA\FederatedFileSharing\AppInfo\Application; use OCA\FederatedFileSharing\FederatedShareProvider; +use OCP\Share\IShare; class File implements \OCP\Share_Backend_File_Dependent { public const FORMAT_SHARED_STORAGE = 0; @@ -192,11 +193,11 @@ class File implements \OCP\Share_Backend_File_Dependent { * @return boolean */ public function isShareTypeAllowed($shareType) { - if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) { + if ($shareType === IShare::TYPE_REMOTE) { return $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(); } - if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { + if ($shareType === IShare::TYPE_REMOTE_GROUP) { return $this->federatedShareProvider->isOutgoingServer2serverGroupShareEnabled(); } diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index 84e31494c92..fd2847f4af9 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/apps/files_sharing/lib/Updater.php @@ -27,6 +27,8 @@ namespace OCA\Files_Sharing; +use OCP\Share\IShare; + class Updater { /** @@ -59,9 +61,9 @@ class Updater { $shareManager = \OC::$server->getShareManager(); - $shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_USER, $src, false, -1); - $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $src, false, -1)); - $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_ROOM, $src, false, -1)); + $shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_USER, $src, false, -1); + $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_GROUP, $src, false, -1)); + $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_ROOM, $src, false, -1)); // If the path we move is not a share we don't care if (empty($shares)) { @@ -79,7 +81,7 @@ class Updater { //Ownership is moved over foreach ($shares as $share) { - /** @var \OCP\Share\IShare $share */ + /** @var IShare $share */ $share->setShareOwner($newOwner); $shareManager->updateShare($share); } diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 9e7d8e5c693..5339128fbef 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -134,7 +134,7 @@ class ApiTest extends TestCase { public function testCreateShareUserFile() { $this->setUp(); // for some reasons phpunit refuses to do this for us only for this test $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -151,7 +151,7 @@ class ApiTest extends TestCase { public function testCreateShareUserFolder() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -168,7 +168,7 @@ class ApiTest extends TestCase { public function testCreateShareGroupFile() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); $ocs->cleanup(); $data = $result->getData(); @@ -184,7 +184,7 @@ class ApiTest extends TestCase { public function testCreateShareGroupFolder() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); $ocs->cleanup(); $data = $result->getData(); @@ -200,7 +200,7 @@ class ApiTest extends TestCase { public function testCreateShareLink() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); $ocs->cleanup(); $data = $result->getData(); @@ -223,7 +223,7 @@ class ApiTest extends TestCase { public function testCreateShareLinkPublicUpload() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true'); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true'); $ocs->cleanup(); $data = $result->getData(); @@ -256,7 +256,7 @@ class ApiTest extends TestCase { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); $this->fail(); } catch (OCSForbiddenException $e) { } @@ -264,7 +264,7 @@ class ApiTest extends TestCase { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', ''); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', ''); $this->fail(); } catch (OCSForbiddenException $e) { } @@ -272,7 +272,7 @@ class ApiTest extends TestCase { // share with password should succeed $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', $password); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', $password); $ocs->cleanup(); $data = $result->getData(); @@ -309,7 +309,7 @@ class ApiTest extends TestCase { \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no'); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -325,7 +325,7 @@ class ApiTest extends TestCase { \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', 'admin,group1,group2'); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -340,7 +340,7 @@ class ApiTest extends TestCase { \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', 'admin,group'); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); // cleanup @@ -361,7 +361,7 @@ class ApiTest extends TestCase { $share->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share = $this->shareManager->createShare($share); @@ -381,7 +381,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -392,7 +392,7 @@ class ApiTest extends TestCase { $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -413,7 +413,7 @@ class ApiTest extends TestCase { */ public function testPublicLinkUrl() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); $ocs->cleanup(); $data = $result->getData(); @@ -466,14 +466,14 @@ class ApiTest extends TestCase { $share->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share); $share = $this->shareManager->newShare(); $share->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share); @@ -499,7 +499,7 @@ class ApiTest extends TestCase { $share1->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); @@ -507,7 +507,7 @@ class ApiTest extends TestCase { $share2->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) ->setSharedWith(self::TEST_FILES_SHARING_API_USER3) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share2 = $this->shareManager->createShare($share2); @@ -540,7 +540,7 @@ class ApiTest extends TestCase { $share1->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); @@ -564,7 +564,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); @@ -572,7 +572,7 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->newShare(); $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); @@ -594,7 +594,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); @@ -620,7 +620,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -630,7 +630,7 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->newShare(); $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -640,7 +640,7 @@ class ApiTest extends TestCase { $share3 = $this->shareManager->newShare(); $share3->setNode($node3) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); $share3->setStatus(IShare::STATUS_ACCEPTED); @@ -680,7 +680,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -690,7 +690,7 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->newShare(); $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -722,7 +722,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); @@ -731,14 +731,14 @@ class ApiTest extends TestCase { $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) ->setSharedWith(self::TEST_FILES_SHARING_API_USER3) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share2 = $this->shareManager->createShare($share2); $share3 = $this->shareManager->newShare(); $share3->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER3) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); @@ -800,7 +800,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -811,7 +811,7 @@ class ApiTest extends TestCase { $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -820,7 +820,7 @@ class ApiTest extends TestCase { $share3 = $this->shareManager->newShare(); $share3->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); $share3->setStatus(IShare::STATUS_ACCEPTED); @@ -864,7 +864,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -876,7 +876,7 @@ class ApiTest extends TestCase { $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) ->setSharedWith(self::TEST_FILES_SHARING_API_USER3) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -887,7 +887,7 @@ class ApiTest extends TestCase { $share3 = $this->shareManager->newShare(); $share3->setNode($node3) ->setSharedBy(self::TEST_FILES_SHARING_API_USER3) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); $share3->setStatus(IShare::STATUS_ACCEPTED); @@ -937,14 +937,14 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); $share2 = $this->shareManager->newShare(); $share2->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); @@ -985,7 +985,7 @@ class ApiTest extends TestCase { $share1 = $this->shareManager->newShare(); $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share1 = $this->shareManager->createShare($share1); @@ -1016,7 +1016,7 @@ class ApiTest extends TestCase { $share1 = $this->shareManager->newShare(); $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -1089,14 +1089,14 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); $share2 = $this->shareManager->newShare(); $share2->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share1); @@ -1108,8 +1108,8 @@ class ApiTest extends TestCase { $ocs->deleteShare($share2->getId()); $ocs->cleanup(); - $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER)); - $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_LINK)); + $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_USER)); + $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_LINK)); } /** @@ -1121,7 +1121,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -1132,7 +1132,7 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->newShare(); $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -1155,7 +1155,7 @@ class ApiTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -1182,7 +1182,7 @@ class ApiTest extends TestCase { $pass = true; try { $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, 'localDir', self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER3, @@ -1229,7 +1229,7 @@ class ApiTest extends TestCase { // user 1 shares the mount point folder with user2 $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -1274,7 +1274,7 @@ class ApiTest extends TestCase { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date); $this->assertTrue($valid); } catch (OCSNotFoundException $e) { $this->assertFalse($valid); @@ -1310,7 +1310,7 @@ class ApiTest extends TestCase { $date->add(new \DateInterval('P5D')); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); $ocs->cleanup(); $data = $result->getData(); @@ -1344,7 +1344,7 @@ class ApiTest extends TestCase { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); + $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); $this->fail(); } catch (OCSException $e) { $this->assertEquals(404, $e->getCode()); @@ -1365,7 +1365,7 @@ class ApiTest extends TestCase { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); + $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); $this->fail(); } catch (OCSException $e) { $this->assertEquals(404, $e->getCode()); @@ -1384,7 +1384,7 @@ class ApiTest extends TestCase { public function testInvisibleSharesUser() { // simulate a post request $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -1395,7 +1395,7 @@ class ApiTest extends TestCase { $ocs->cleanup(); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); - $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); $ocs->cleanup(); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); @@ -1416,7 +1416,7 @@ class ApiTest extends TestCase { public function testInvisibleSharesGroup() { // simulate a post request $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); $ocs->cleanup(); $data = $result->getData(); @@ -1429,7 +1429,7 @@ class ApiTest extends TestCase { \OC_Util::tearDownFS(); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); - $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); $ocs->cleanup(); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php index 09fc9f6f5a7..7b80bfcaaae 100644 --- a/apps/files_sharing/tests/CacheTest.php +++ b/apps/files_sharing/tests/CacheTest.php @@ -100,7 +100,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('container/shareddir'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -111,7 +111,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('container/shared single file.txt'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE)); @@ -135,7 +135,7 @@ class CacheTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER); + $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER); foreach ($shares as $share) { $this->shareManager->deleteShare($share); } @@ -312,7 +312,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('container/shareddir/subdir'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER3) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -398,7 +398,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('test.txt'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE); @@ -431,7 +431,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('foo'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -460,7 +460,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('foo'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -497,7 +497,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('foo/sub'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 577f574f8ed..e186092f0bf 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -52,7 +52,6 @@ use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; use OCP\Lock\LockedException; -use OCP\Share; use OCP\Share\Exceptions\GenericShareException; use OCP\Share\IManager; use OCP\Share\IShare; @@ -260,7 +259,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setSharedWith($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setNode($node); $this->shareManager @@ -355,7 +354,7 @@ class ShareAPIControllerTest extends TestCase { $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $share->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group') ->setNode($node); @@ -417,7 +416,7 @@ class ShareAPIControllerTest extends TestCase { $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $share->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group') ->setNode($node); @@ -504,9 +503,9 @@ class ShareAPIControllerTest extends TestCase { $share->method('getToken')->willReturn($token); $share->method('getPassword')->willReturn($password); - if ($shareType === \OCP\Share::SHARE_TYPE_USER || - $shareType === \OCP\Share::SHARE_TYPE_GROUP || - $shareType === \OCP\Share::SHARE_TYPE_LINK) { + if ($shareType === IShare::TYPE_USER || + $shareType === IShare::TYPE_GROUP || + $shareType === IShare::TYPE_LINK) { $share->method('getFullId')->willReturn('ocinternal:'.$id); } @@ -547,7 +546,7 @@ class ShareAPIControllerTest extends TestCase { // File shared with user $share = $this->createShare( 100, - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, 'userId', 'initiatorId', 'ownerId', @@ -562,7 +561,7 @@ class ShareAPIControllerTest extends TestCase { ); $expected = [ 'id' => 100, - 'share_type' => \OCP\Share::SHARE_TYPE_USER, + 'share_type' => IShare::TYPE_USER, 'share_with' => 'userId', 'share_with_displayname' => 'userDisplay', 'uid_owner' => 'initiatorId', @@ -595,7 +594,7 @@ class ShareAPIControllerTest extends TestCase { // Folder shared with group $share = $this->createShare( 101, - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, 'groupId', 'initiatorId', 'ownerId', @@ -610,7 +609,7 @@ class ShareAPIControllerTest extends TestCase { ); $expected = [ 'id' => 101, - 'share_type' => \OCP\Share::SHARE_TYPE_GROUP, + 'share_type' => IShare::TYPE_GROUP, 'share_with' => 'groupId', 'share_with_displayname' => 'groupId', 'uid_owner' => 'initiatorId', @@ -644,7 +643,7 @@ class ShareAPIControllerTest extends TestCase { $expire = \DateTime::createFromFormat('Y-m-d h:i:s', '2000-01-02 01:02:03'); $share = $this->createShare( 101, - \OCP\Share::SHARE_TYPE_LINK, + IShare::TYPE_LINK, null, 'initiatorId', 'ownerId', @@ -662,7 +661,7 @@ class ShareAPIControllerTest extends TestCase { ); $expected = [ 'id' => 101, - 'share_type' => \OCP\Share::SHARE_TYPE_LINK, + 'share_type' => IShare::TYPE_LINK, 'password' => 'password', 'share_with' => 'password', 'share_with_displayname' => '(Shared link)', @@ -1405,7 +1404,7 @@ class ShareAPIControllerTest extends TestCase { $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $share = $this->getMockBuilder(IShare::class)->getMock(); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $share->method('getShareType')->willReturn(IShare::TYPE_USER); $share->method('getSharedWith')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); @@ -1425,18 +1424,18 @@ class ShareAPIControllerTest extends TestCase { // getPermissions -> share $share = $this->getMockBuilder(IShare::class)->getMock(); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $share->method('getShareType')->willReturn(IShare::TYPE_USER); $share->method('getSharedWith')->willReturn($this->getMockBuilder(IUser::class)->getMock()); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); // getPermissions -> read $share = $this->getMockBuilder(IShare::class)->getMock(); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $share->method('getShareType')->willReturn(IShare::TYPE_USER); $share->method('getSharedWith')->willReturn($this->getMockBuilder(IUser::class)->getMock()); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $share = $this->getMockBuilder(IShare::class)->getMock(); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); + $share->method('getShareType')->willReturn(IShare::TYPE_GROUP); $share->method('getSharedWith')->willReturn('group'); $user = $this->createMock(IUser::class); @@ -1457,18 +1456,18 @@ class ShareAPIControllerTest extends TestCase { $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); + $share->method('getShareType')->willReturn(IShare::TYPE_GROUP); $share->method('getSharedWith')->willReturn('group2'); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); // null group $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); + $share->method('getShareType')->willReturn(IShare::TYPE_GROUP); $share->method('getSharedWith')->willReturn('groupnull'); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); } @@ -1476,7 +1475,7 @@ class ShareAPIControllerTest extends TestCase { $result = []; $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_ROOM); + $share->method('getShareType')->willReturn(IShare::TYPE_ROOM); $share->method('getSharedWith')->willReturn('recipientRoom'); $result[] = [ @@ -1623,7 +1622,7 @@ class ShareAPIControllerTest extends TestCase { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER); } @@ -1657,7 +1656,7 @@ class ShareAPIControllerTest extends TestCase { ->with('invalidUser') ->willReturn(false); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'invalidUser'); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'invalidUser'); } public function testCreateShareUser() { @@ -1713,14 +1712,14 @@ class ShareAPIControllerTest extends TestCase { ~\OCP\Constants::PERMISSION_DELETE & ~\OCP\Constants::PERMISSION_CREATE ) && - $share->getShareType() === \OCP\Share::SHARE_TYPE_USER && + $share->getShareType() === IShare::TYPE_USER && $share->getSharedWith() === 'validUser' && $share->getSharedBy() === 'currentUser'; })) ->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser'); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'validUser'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1757,7 +1756,7 @@ class ShareAPIControllerTest extends TestCase { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup'); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'invalidGroup'); } public function testCreateShareGroup() { @@ -1787,7 +1786,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturnMap([ ['path', null, 'valid-path'], ['permissions', null, \OCP\Constants::PERMISSION_ALL], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_GROUP], + ['shareType', '-1', IShare::TYPE_GROUP], ['shareWith', null, 'validGroup'], ]); @@ -1822,14 +1821,14 @@ class ShareAPIControllerTest extends TestCase { ->with($this->callback(function (\OCP\Share\IShare $share) use ($path) { return $share->getNode() === $path && $share->getPermissions() === \OCP\Constants::PERMISSION_ALL && - $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP && + $share->getShareType() === IShare::TYPE_GROUP && $share->getSharedWith() === 'validGroup' && $share->getSharedBy() === 'currentUser'; })) ->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'validGroup'); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'validGroup'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1866,7 +1865,7 @@ class ShareAPIControllerTest extends TestCase { ->method('allowGroupSharing') ->willReturn(false); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup'); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'invalidGroup'); } @@ -1878,7 +1877,7 @@ class ShareAPIControllerTest extends TestCase { ->method('getParam') ->willReturnMap([ ['path', null, 'valid-path'], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], + ['shareType', '-1', IShare::TYPE_LINK], ]); $path = $this->getMockBuilder(Folder::class)->getMock(); @@ -1892,7 +1891,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare()); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); } @@ -1912,7 +1911,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true'); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true'); } @@ -1933,7 +1932,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true'); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true'); } public function testCreateShareLinkPublicUploadFolder() { @@ -1955,7 +1954,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->once())->method('createShare')->with( $this->callback(function (\OCP\Share\IShare $share) use ($path) { return $share->getNode() === $path && - $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + $share->getShareType() === IShare::TYPE_LINK && $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) && $share->getSharedBy() === 'currentUser' && $share->getPassword() === null && @@ -1964,7 +1963,7 @@ class ShareAPIControllerTest extends TestCase { )->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true', '', null, ''); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true', '', null, ''); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1989,7 +1988,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->once())->method('createShare')->with( $this->callback(function (\OCP\Share\IShare $share) use ($path) { return $share->getNode() === $path && - $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + $share->getShareType() === IShare::TYPE_LINK && $share->getPermissions() === \OCP\Constants::PERMISSION_READ && $share->getSharedBy() === 'currentUser' && $share->getPassword() === 'password' && @@ -1998,7 +1997,7 @@ class ShareAPIControllerTest extends TestCase { )->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', null, ''); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', null, ''); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -2025,7 +2024,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->once())->method('createShare')->with( $this->callback(function (\OCP\Share\IShare $share) use ($path) { return $share->getNode() === $path && - $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + $share->getShareType() === IShare::TYPE_LINK && $share->getPermissions() === \OCP\Constants::PERMISSION_READ && $share->getSharedBy() === 'currentUser' && $share->getPassword() === 'password' && @@ -2035,7 +2034,7 @@ class ShareAPIControllerTest extends TestCase { )->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', 'true', ''); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', ''); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -2066,7 +2065,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->never())->method('createShare'); - $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', 'true', ''); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', ''); } public function testCreateShareValidExpireDate() { @@ -2076,7 +2075,7 @@ class ShareAPIControllerTest extends TestCase { ->method('getParam') ->willReturnMap([ ['path', null, 'valid-path'], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], + ['shareType', '-1', IShare::TYPE_LINK], ['publicUpload', null, 'false'], ['expireDate', '', '2000-01-01'], ['password', '', ''], @@ -2101,7 +2100,7 @@ class ShareAPIControllerTest extends TestCase { $date->setTime(0,0,0); return $share->getNode() === $path && - $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + $share->getShareType() === IShare::TYPE_LINK && $share->getPermissions() === \OCP\Constants::PERMISSION_READ && $share->getSharedBy() === 'currentUser' && $share->getPassword() === null && @@ -2110,7 +2109,7 @@ class ShareAPIControllerTest extends TestCase { )->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, '2000-01-01'); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, '2000-01-01'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -2136,7 +2135,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, 'a1b2d3'); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, 'a1b2d3'); } public function testCreateShareRoom() { @@ -2204,14 +2203,14 @@ class ShareAPIControllerTest extends TestCase { ~\OCP\Constants::PERMISSION_DELETE & ~\OCP\Constants::PERMISSION_CREATE ) && - $share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM && + $share->getShareType() === IShare::TYPE_ROOM && $share->getSharedWith() === 'recipientRoom' && $share->getSharedBy() === 'currentUser'; })) ->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom'); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -2255,7 +2254,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->never())->method('createShare'); - $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom'); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom'); } @@ -2316,7 +2315,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->never())->method('createShare'); - $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom'); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom'); } /** @@ -2373,7 +2372,7 @@ class ShareAPIControllerTest extends TestCase { })) ->willReturnArgument(0); - $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser'); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'validUser'); } @@ -2412,7 +2411,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setNode($node); $node->expects($this->once()) @@ -2433,7 +2432,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setNode($node); $node->expects($this->once()) @@ -2454,7 +2453,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setExpirationDate(new \DateTime()) ->setNote('note') @@ -2517,7 +2516,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setNode($folder); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); @@ -2575,7 +2574,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setNode($folder); @@ -2625,7 +2624,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setNode($folder); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); @@ -2664,7 +2663,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setNode($folder); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); @@ -2685,7 +2684,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setNode($file); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); @@ -2704,7 +2703,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -2749,7 +2748,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(false) ->setExpirationDate($date) @@ -2800,7 +2799,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(false) ->setExpirationDate($date) @@ -2833,7 +2832,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -2883,7 +2882,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -2951,7 +2950,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate(new \DateTime()) @@ -3016,7 +3015,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -3078,7 +3077,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -3139,7 +3138,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -3198,7 +3197,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setNode($file); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); @@ -3246,7 +3245,7 @@ class ShareAPIControllerTest extends TestCase { ->setId(42) ->setSharedBy($this->currentUser) ->setShareOwner('anotheruser') - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group1') ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setNode($folder); @@ -3258,7 +3257,7 @@ class ShareAPIControllerTest extends TestCase { ->setId(42) ->setSharedBy($this->currentUser) ->setShareOwner('anotheruser') - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group1') ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setNode($folder); @@ -3274,9 +3273,9 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->any()) ->method('getSharedWith') ->willReturnMap([ - ['currentUser', \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0, []], - ['currentUser', \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]], - ['currentUser', \OCP\Share::SHARE_TYPE_ROOM, $share->getNode(), -1, 0, []] + ['currentUser', IShare::TYPE_USER, $share->getNode(), -1, 0, []], + ['currentUser', IShare::TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]], + ['currentUser', IShare::TYPE_ROOM, $share->getNode(), -1, 0, []] ]); $userFolder = $this->createMock(Folder::class); @@ -3319,7 +3318,7 @@ class ShareAPIControllerTest extends TestCase { ->setId(42) ->setSharedBy($this->currentUser) ->setShareOwner($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group1') ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setNode($folder); @@ -3331,7 +3330,7 @@ class ShareAPIControllerTest extends TestCase { ->setId(42) ->setSharedBy($this->currentUser) ->setShareOwner($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group1') ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setNode($folder); @@ -3341,8 +3340,8 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->any()) ->method('getSharedWith') ->willReturnMap([ - ['currentUser', \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0, []], - ['currentUser', \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]] + ['currentUser', IShare::TYPE_USER, $share->getNode(), -1, 0, []], + ['currentUser', IShare::TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]] ]); $this->shareManager->expects($this->once()) @@ -3406,7 +3405,7 @@ class ShareAPIControllerTest extends TestCase { $result = []; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -3421,7 +3420,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_USER, + 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3454,7 +3453,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_USER, + 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiatorDN', 'permissions' => 1, @@ -3489,7 +3488,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -3503,7 +3502,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_USER, + 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3534,7 +3533,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') ->setShareOwner('currentUser') @@ -3548,7 +3547,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_USER, + 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3581,7 +3580,7 @@ class ShareAPIControllerTest extends TestCase { // with existing group $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $share->setShareType(IShare::TYPE_GROUP) ->setSharedWith('recipientGroup') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -3595,7 +3594,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_GROUP, + 'share_type' => IShare::TYPE_GROUP, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3627,7 +3626,7 @@ class ShareAPIControllerTest extends TestCase { // with unknown group / no group backend $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(Share::SHARE_TYPE_GROUP) + $share->setShareType(IShare::TYPE_GROUP) ->setSharedWith('recipientGroup2') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -3640,7 +3639,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => Share::SHARE_TYPE_GROUP, + 'share_type' => IShare::TYPE_GROUP, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3671,7 +3670,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $share->setShareType(IShare::TYPE_LINK) ->setSharedBy('initiator') ->setShareOwner('owner') ->setPermissions(\OCP\Constants::PERMISSION_READ) @@ -3688,7 +3687,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_LINK, + 'share_type' => IShare::TYPE_LINK, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3722,7 +3721,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $share->setShareType(IShare::TYPE_LINK) ->setSharedBy('initiator') ->setShareOwner('owner') ->setPermissions(\OCP\Constants::PERMISSION_READ) @@ -3740,7 +3739,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_LINK, + 'share_type' => IShare::TYPE_LINK, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3774,7 +3773,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + $share->setShareType(IShare::TYPE_REMOTE) ->setSharedBy('initiator') ->setSharedWith('user@server.com') ->setShareOwner('owner') @@ -3788,7 +3787,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_REMOTE, + 'share_type' => IShare::TYPE_REMOTE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3820,7 +3819,7 @@ class ShareAPIControllerTest extends TestCase { // Circle with id, display name and avatar set by the Circles app $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE) + $share->setShareType(IShare::TYPE_CIRCLE) ->setSharedBy('initiator') ->setSharedWith('Circle (Public circle, circleOwner) [4815162342]') ->setSharedWithDisplayName('The display name') @@ -3835,7 +3834,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE, + 'share_type' => IShare::TYPE_CIRCLE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3868,7 +3867,7 @@ class ShareAPIControllerTest extends TestCase { // Circle with id set by the Circles app $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE) + $share->setShareType(IShare::TYPE_CIRCLE) ->setSharedBy('initiator') ->setSharedWith('Circle (Public circle, circleOwner) [4815162342]') ->setShareOwner('owner') @@ -3881,7 +3880,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE, + 'share_type' => IShare::TYPE_CIRCLE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3914,7 +3913,7 @@ class ShareAPIControllerTest extends TestCase { // Circle with id not set by the Circles app $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE) + $share->setShareType(IShare::TYPE_CIRCLE) ->setSharedBy('initiator') ->setSharedWith('Circle (Public circle, circleOwner)') ->setShareOwner('owner') @@ -3927,7 +3926,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE, + 'share_type' => IShare::TYPE_CIRCLE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3959,7 +3958,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setSharedBy('initiator') ->setSharedWith('recipient') ->setShareOwner('owner') @@ -3974,7 +3973,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $share->setShareType(IShare::TYPE_EMAIL) ->setSharedBy('initiator') ->setSharedWith('user@server.com') ->setShareOwner('owner') @@ -3988,7 +3987,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_EMAIL, + 'share_type' => IShare::TYPE_EMAIL, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -4021,7 +4020,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $share->setShareType(IShare::TYPE_EMAIL) ->setSharedBy('initiator') ->setSharedWith('user@server.com') ->setShareOwner('owner') @@ -4036,7 +4035,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_EMAIL, + 'share_type' => IShare::TYPE_EMAIL, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -4167,7 +4166,7 @@ class ShareAPIControllerTest extends TestCase { $result = []; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_ROOM) + $share->setShareType(IShare::TYPE_ROOM) ->setSharedWith('recipientRoom') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -4181,7 +4180,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_ROOM, + 'share_type' => IShare::TYPE_ROOM, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -4212,7 +4211,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_ROOM) + $share->setShareType(IShare::TYPE_ROOM) ->setSharedWith('recipientRoom') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -4226,7 +4225,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_ROOM, + 'share_type' => IShare::TYPE_ROOM, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php index 7beb4058c4f..8939198d4a8 100644 --- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php @@ -38,7 +38,7 @@ use OCP\Collaboration\Collaborators\ISearch; use OCP\IConfig; use OCP\IRequest; use OCP\IURLGenerator; -use OCP\Share; +use OCP\Share\IShare; use OCP\Share\IManager; /** @@ -91,8 +91,8 @@ class ShareesAPIControllerTest extends TestCase { } public function dataSearch() { - $noRemote = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_EMAIL]; - $allTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_REMOTE_GROUP, Share::SHARE_TYPE_EMAIL]; + $noRemote = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_EMAIL]; + $allTypes = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE, IShare::TYPE_REMOTE_GROUP, IShare::TYPE_EMAIL]; return [ [[], '', 'yes', true, true, true, $noRemote, false, true, true], @@ -293,7 +293,7 @@ class ShareesAPIControllerTest extends TestCase { $this->shareManager->expects($this->any()) ->method('shareProviderExists') ->willReturnCallback(function ($shareType) use ($emailSharingEnabled) { - if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { + if ($shareType === \OCP\IShare::TYPE_EMAIL) { return $emailSharingEnabled; } else { return false; diff --git a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php index f081c947f53..3936a3b9da2 100644 --- a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php +++ b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php @@ -27,6 +27,7 @@ namespace OCA\Files_Sharing\Tests; use OCA\Files_Sharing\DeleteOrphanedSharesJob; +use OCP\Share\IShare; /** * Class DeleteOrphanedSharesJobTest @@ -138,7 +139,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase { $share = $shareManager->newShare(); $share->setNode($testSubFolder) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setSharedWith($this->user2) ->setSharedBy($this->user1); diff --git a/apps/files_sharing/tests/EtagPropagationTest.php b/apps/files_sharing/tests/EtagPropagationTest.php index 081b720f820..ee2f5b204e3 100644 --- a/apps/files_sharing/tests/EtagPropagationTest.php +++ b/apps/files_sharing/tests/EtagPropagationTest.php @@ -31,6 +31,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Files\Filesystem; use OC\Files\View; +use OCP\Share\IShare; /** * Class EtagPropagationTest @@ -75,7 +76,7 @@ class EtagPropagationTest extends PropagationTestCase { ->get('/foo.txt'); $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE); @@ -86,7 +87,7 @@ class EtagPropagationTest extends PropagationTestCase { $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -95,7 +96,7 @@ class EtagPropagationTest extends PropagationTestCase { $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER3) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -109,7 +110,7 @@ class EtagPropagationTest extends PropagationTestCase { ->get('/directReshare'); $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -134,7 +135,7 @@ class EtagPropagationTest extends PropagationTestCase { ->get('/sub1/sub2/folder/inside'); $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER4) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -148,7 +149,7 @@ class EtagPropagationTest extends PropagationTestCase { ->get('/directReshare'); $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER4) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -284,7 +285,7 @@ class EtagPropagationTest extends PropagationTestCase { $node = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1)->get('/sub1/sub2/folder'); $shareManager = \OC::$server->getShareManager(); - $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node, true); + $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node, true); foreach ($shares as $share) { if ($share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2) { @@ -307,7 +308,7 @@ class EtagPropagationTest extends PropagationTestCase { $node = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1)->get('/sub1/sub2/folder/inside'); $shareManager = \OC::$server->getShareManager(); - $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node, true); + $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node, true); foreach ($shares as $share) { $shareManager->deleteShare($share); @@ -455,7 +456,7 @@ class EtagPropagationTest extends PropagationTestCase { $userFolder = $this->rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER1); $node = $userFolder->get('/sub1/sub2/folder'); - $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node); + $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node); /** @var \OCP\Share\IShare[] $shares */ $shares = array_filter($shares, function (\OCP\Share\IShare $share) { return $share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2; diff --git a/apps/files_sharing/tests/ExpireSharesJobTest.php b/apps/files_sharing/tests/ExpireSharesJobTest.php index 1854ce4990c..219a91a2829 100644 --- a/apps/files_sharing/tests/ExpireSharesJobTest.php +++ b/apps/files_sharing/tests/ExpireSharesJobTest.php @@ -25,6 +25,7 @@ namespace OCA\Files_Sharing\Tests; use OCA\Files_Sharing\ExpireSharesJob; +use OCP\Share\IShare; /** * Class ExpireSharesJobTest @@ -140,7 +141,7 @@ class ExpireSharesJobTest extends \Test\TestCase { $share = $shareManager->newShare(); $share->setNode($testFolder) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setSharedBy($this->user1); @@ -197,7 +198,7 @@ class ExpireSharesJobTest extends \Test\TestCase { $share = $shareManager->newShare(); $share->setNode($testFolder) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setSharedBy($this->user1) ->setSharedWith($this->user2); diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 5807c3e9fd5..d6fab64dc67 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -39,6 +39,7 @@ use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; use OCP\IGroupManager; use OCP\IUserManager; +use OCP\Share\IShare; use Test\Traits\UserTrait; /** @@ -130,7 +131,7 @@ class ManagerTest extends TestCase { 'password' => '', 'name' => '/SharedFolder', 'owner' => 'foobar', - 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'accepted' => false, 'user' => $this->uid, ]; diff --git a/apps/files_sharing/tests/GroupEtagPropagationTest.php b/apps/files_sharing/tests/GroupEtagPropagationTest.php index 5232a536259..ba688f70263 100644 --- a/apps/files_sharing/tests/GroupEtagPropagationTest.php +++ b/apps/files_sharing/tests/GroupEtagPropagationTest.php @@ -28,6 +28,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Files\Filesystem; use OC\Files\View; +use OCP\Share\IShare; /** * @group SLOWDB @@ -53,7 +54,7 @@ class GroupEtagPropagationTest extends PropagationTestCase { $view1->mkdir('/test/sub'); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, '/test', self::TEST_FILES_SHARING_API_USER1, 'group1', @@ -68,7 +69,7 @@ class GroupEtagPropagationTest extends PropagationTestCase { $view2 = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files'); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, '/test', self::TEST_FILES_SHARING_API_USER2, 'group2', @@ -76,7 +77,7 @@ class GroupEtagPropagationTest extends PropagationTestCase { ); $this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER3); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, '/test/sub', self::TEST_FILES_SHARING_API_USER2, 'group3', diff --git a/apps/files_sharing/tests/LockingTest.php b/apps/files_sharing/tests/LockingTest.php index c6a799f64a6..680220e5fa5 100644 --- a/apps/files_sharing/tests/LockingTest.php +++ b/apps/files_sharing/tests/LockingTest.php @@ -29,6 +29,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Files\Filesystem; use OC\Files\View; use OCP\Lock\ILockingProvider; +use OCP\Share\IShare; /** * Class LockingTest @@ -63,7 +64,7 @@ class LockingTest extends TestCase { $fileId = Filesystem::getFileInfo('/foo/bar.txt')->getId(); $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, '/foo/bar.txt', $this->ownerUid, $this->recipientUid, @@ -79,7 +80,7 @@ class LockingTest extends TestCase { parent::tearDown(); } - + public function testLockAsRecipient() { $this->expectException(\OCP\Lock\LockedException::class); diff --git a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php index 0a1737ba37f..cdba86863f1 100644 --- a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php +++ b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php @@ -28,7 +28,7 @@ use OCA\Files_Sharing\Migration\SetPasswordColumn; use OCA\Files_Sharing\Tests\TestCase; use OCP\IConfig; use OCP\Migration\IOutput; -use OCP\Share; +use OCP\Share\IShare; /** * Class SetPasswordColumnTest @@ -74,7 +74,7 @@ class SetPasswordColumnTest extends TestCase { ->with('files_sharing', 'installed_version', '0.0.0') ->willReturn('1.3.0'); - $shareTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_EMAIL, Share::SHARE_TYPE_LINK]; + $shareTypes = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE, IShare::TYPE_EMAIL, IShare::TYPE_LINK]; foreach ($shareTypes as $shareType) { for ($i = 0; $i < 5; $i++) { @@ -109,7 +109,7 @@ class SetPasswordColumnTest extends TestCase { $allShares = $query->execute()->fetchAll(); foreach ($allShares as $share) { - if ((int)$share['share_type'] === Share::SHARE_TYPE_LINK) { + if ((int)$share['share_type'] === IShare::TYPE_LINK) { $this->assertNull($share['share_with']); $this->assertSame('shareWith', $share['password']); } else { diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php index ec52db8542e..60c622ec4a4 100644 --- a/apps/files_sharing/tests/MountProviderTest.php +++ b/apps/files_sharing/tests/MountProviderTest.php @@ -129,19 +129,19 @@ class MountProviderTest extends \Test\TestCase { ->willReturn('user1'); $this->shareManager->expects($this->at(0)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_USER) + ->with('user1', IShare::TYPE_USER) ->willReturn($userShares); $this->shareManager->expects($this->at(1)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1) + ->with('user1', IShare::TYPE_GROUP, null, -1) ->willReturn($groupShares); $this->shareManager->expects($this->at(2)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1) + ->with('user1', IShare::TYPE_CIRCLE, null, -1) ->willReturn($circleShares); $this->shareManager->expects($this->at(3)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_ROOM, null, -1) + ->with('user1', IShare::TYPE_ROOM, null, -1) ->willReturn($roomShares); $this->shareManager->expects($this->any()) ->method('newShare') @@ -338,19 +338,19 @@ class MountProviderTest extends \Test\TestCase { $roomShares = []; $this->shareManager->expects($this->at(0)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_USER) + ->with('user1', IShare::TYPE_USER) ->willReturn($userShares); $this->shareManager->expects($this->at(1)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1) + ->with('user1', IShare::TYPE_GROUP, null, -1) ->willReturn($groupShares); $this->shareManager->expects($this->at(2)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1) + ->with('user1', IShare::TYPE_CIRCLE, null, -1) ->willReturn($circleShares); $this->shareManager->expects($this->at(3)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_ROOM, null, -1) + ->with('user1', IShare::TYPE_ROOM, null, -1) ->willReturn($roomShares); $this->shareManager->expects($this->any()) ->method('newShare') diff --git a/apps/files_sharing/tests/PermissionsTest.php b/apps/files_sharing/tests/PermissionsTest.php index 30c6c2a73d2..64dad207382 100644 --- a/apps/files_sharing/tests/PermissionsTest.php +++ b/apps/files_sharing/tests/PermissionsTest.php @@ -86,7 +86,7 @@ class PermissionsTest extends TestCase { $node = $rootFolder->get('container/shareddir'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -97,7 +97,7 @@ class PermissionsTest extends TestCase { $node = $rootFolder->get('container/shareddirrestricted'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE); @@ -123,7 +123,7 @@ class PermissionsTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER); + $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER); foreach ($shares as $share) { $this->shareManager->deleteShare($share); } diff --git a/apps/files_sharing/tests/ShareTest.php b/apps/files_sharing/tests/ShareTest.php index ba6b401e65e..3b695493c23 100644 --- a/apps/files_sharing/tests/ShareTest.php +++ b/apps/files_sharing/tests/ShareTest.php @@ -28,6 +28,8 @@ namespace OCA\Files_Sharing\Tests; +use OCP\Share\IShare; + /** * Class ShareTest * @@ -77,7 +79,7 @@ class ShareTest extends TestCase { $testGroup->addUser($user2); $share1 = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -85,7 +87,7 @@ class ShareTest extends TestCase { ); $share2 = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, $this->filename, self::TEST_FILES_SHARING_API_USER1, 'testGroup', @@ -131,7 +133,7 @@ class ShareTest extends TestCase { $folderinfo = $this->view->getFileInfo($this->folder); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -141,7 +143,7 @@ class ShareTest extends TestCase { \OCA\Files_Sharing\Helper::setShareFolder('/Shared/subfolder'); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -164,7 +166,7 @@ class ShareTest extends TestCase { \OC\Files\Filesystem::file_put_contents('test.txt', 'test'); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, 'test.txt', self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_GROUP1, @@ -173,14 +175,14 @@ class ShareTest extends TestCase { $this->loginHelper(self::TEST_FILES_SHARING_API_USER2); - $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP); + $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP); $share = $shares[0]; $this->assertSame('/test.txt' ,$share->getTarget()); $this->assertSame(19, $share->getPermissions()); \OC\Files\Filesystem::rename('test.txt', 'new test.txt'); - $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP); + $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP); $share = $shares[0]; $this->assertSame('/new test.txt' ,$share->getTarget()); $this->assertSame(19, $share->getPermissions()); @@ -189,7 +191,7 @@ class ShareTest extends TestCase { $this->shareManager->updateShare($share); $this->loginHelper(self::TEST_FILES_SHARING_API_USER2); - $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP); + $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP); $share = $shares[0]; $this->assertSame('/new test.txt' ,$share->getTarget()); @@ -204,7 +206,7 @@ class ShareTest extends TestCase { $pass = true; try { $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -235,7 +237,7 @@ class ShareTest extends TestCase { public function testFileOwner() { $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, diff --git a/apps/files_sharing/tests/SharedMountTest.php b/apps/files_sharing/tests/SharedMountTest.php index 59c0e3b76af..c60039e321a 100644 --- a/apps/files_sharing/tests/SharedMountTest.php +++ b/apps/files_sharing/tests/SharedMountTest.php @@ -32,6 +32,7 @@ namespace OCA\Files_Sharing\Tests; use OCP\IGroupManager; use OCP\IUserManager; +use OCP\Share\IShare; /** * Class SharedMountTest @@ -84,7 +85,7 @@ class SharedMountTest extends TestCase { // share to user $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -115,7 +116,7 @@ class SharedMountTest extends TestCase { public function testDeleteParentOfMountPoint() { // share to user $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -154,7 +155,7 @@ class SharedMountTest extends TestCase { public function testMoveSharedFile() { $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -197,7 +198,7 @@ class SharedMountTest extends TestCase { $fileinfo = $this->view->getFileInfo($this->filename); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, $this->filename, self::TEST_FILES_SHARING_API_USER1, 'testGroup', @@ -351,7 +352,7 @@ class SharedMountTest extends TestCase { // Share item with group $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, $path, self::TEST_FILES_SHARING_API_USER1, 'testGroup', @@ -415,7 +416,7 @@ class SharedMountTest extends TestCase { // Share item with group $fileinfo = $this->view->getFileInfo($this->folder); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, $this->folder, self::TEST_FILES_SHARING_API_USER1, 'testGroup', diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php index 7d20d98585f..fb8207a3c1d 100644 --- a/apps/files_sharing/tests/SharedStorageTest.php +++ b/apps/files_sharing/tests/SharedStorageTest.php @@ -79,7 +79,7 @@ class SharedStorageTest extends TestCase { // share to user $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -124,7 +124,7 @@ class SharedStorageTest extends TestCase { // share to user $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -164,7 +164,7 @@ class SharedStorageTest extends TestCase { $file2Size = $this->view->filesize($this->filename); $share1 = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -172,7 +172,7 @@ class SharedStorageTest extends TestCase { ); $share2 = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -194,7 +194,7 @@ class SharedStorageTest extends TestCase { public function testGetPermissions() { $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -226,7 +226,7 @@ class SharedStorageTest extends TestCase { $this->view->file_put_contents($this->folder . '/existing.txt', 'foo'); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -259,7 +259,7 @@ class SharedStorageTest extends TestCase { $fileinfoFolder = $this->view->getFileInfo($this->folder); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -298,7 +298,7 @@ class SharedStorageTest extends TestCase { //cleanup self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - $result = \OC\Share\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, + $result = \OC\Share\Share::unshare('folder', $fileinfoFolder['fileid'], IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $this->assertTrue($result); } @@ -307,7 +307,7 @@ class SharedStorageTest extends TestCase { $this->view->file_put_contents($this->folder . '/existing.txt', 'foo'); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -353,7 +353,7 @@ class SharedStorageTest extends TestCase { $this->view->file_put_contents($this->folder . '/existing.txt', 'foo'); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -387,14 +387,14 @@ class SharedStorageTest extends TestCase { // share 2 different files with 2 different users $share1 = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL ); $share2 = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER3, @@ -426,7 +426,7 @@ class SharedStorageTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -459,7 +459,7 @@ class SharedStorageTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -501,7 +501,7 @@ class SharedStorageTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $share1 = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, 'foo', self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_GROUP1, @@ -514,7 +514,7 @@ class SharedStorageTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER3); $share2 = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, 'foo', self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_GROUP1, @@ -543,7 +543,7 @@ class SharedStorageTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, diff --git a/apps/files_sharing/tests/SizePropagationTest.php b/apps/files_sharing/tests/SizePropagationTest.php index 93265f9310a..8496341e653 100644 --- a/apps/files_sharing/tests/SizePropagationTest.php +++ b/apps/files_sharing/tests/SizePropagationTest.php @@ -26,6 +26,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Files\View; +use OCP\Share\IShare; use Test\Traits\UserTrait; /** @@ -54,7 +55,7 @@ class SizePropagationTest extends TestCase { $ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar'); $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, '/sharedfolder', self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER1, @@ -89,7 +90,7 @@ class SizePropagationTest extends TestCase { $ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar'); $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, '/sharedfolder', self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER1, diff --git a/apps/files_sharing/tests/UnshareChildrenTest.php b/apps/files_sharing/tests/UnshareChildrenTest.php index 3d0f13c7212..b9d06bb7fa4 100644 --- a/apps/files_sharing/tests/UnshareChildrenTest.php +++ b/apps/files_sharing/tests/UnshareChildrenTest.php @@ -28,6 +28,8 @@ namespace OCA\Files_Sharing\Tests; +use OCP\Share\IShare; + /** * Class UnshareChildrenTest * @@ -78,7 +80,7 @@ class UnshareChildrenTest extends TestCase { $fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder); $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -88,7 +90,7 @@ class UnshareChildrenTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER2); // one folder should be shared with the user - $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER); + $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_USER); $this->assertCount(1, $shares); // move shared folder to 'localDir' @@ -101,7 +103,7 @@ class UnshareChildrenTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER2); // after the parent directory was deleted the share should be unshared - $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER); + $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_USER); $this->assertEmpty($shares); self::loginHelper(self::TEST_FILES_SHARING_API_USER1); diff --git a/apps/files_sharing/tests/UpdaterTest.php b/apps/files_sharing/tests/UpdaterTest.php index 7f6f3172fcc..30efbac533d 100644 --- a/apps/files_sharing/tests/UpdaterTest.php +++ b/apps/files_sharing/tests/UpdaterTest.php @@ -31,6 +31,8 @@ namespace OCA\Files_Sharing\Tests; +use OCP\Share\IShare; + /** * Class UpdaterTest * @@ -82,7 +84,7 @@ class UpdaterTest extends TestCase { $this->assertTrue($fileinfo instanceof \OC\Files\FileInfo); $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -166,7 +168,7 @@ class UpdaterTest extends TestCase { $this->loginHelper(self::TEST_FILES_SHARING_API_USER1); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -202,7 +204,7 @@ class UpdaterTest extends TestCase { $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, diff --git a/apps/files_sharing/tests/WatcherTest.php b/apps/files_sharing/tests/WatcherTest.php index e105bf16161..fc255753060 100644 --- a/apps/files_sharing/tests/WatcherTest.php +++ b/apps/files_sharing/tests/WatcherTest.php @@ -70,7 +70,7 @@ class WatcherTest extends TestCase { // share "shareddir" with user2 $this->_share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, 'container/shareddir', self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php index ec0c3d522aa..2efdf1b8958 100644 --- a/apps/files_trashbin/tests/StorageTest.php +++ b/apps/files_trashbin/tests/StorageTest.php @@ -45,6 +45,7 @@ use OCP\Files\Node; use OCP\ILogger; use OCP\IUserManager; use OCP\Lock\ILockingProvider; +use OCP\Share\IShare; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -284,7 +285,7 @@ class StorageTest extends \Test\TestCase { $node = \OC::$server->getUserFolder($this->user)->get('share'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy($this->user) ->setSharedWith($recipientUser) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -338,7 +339,7 @@ class StorageTest extends \Test\TestCase { $node = \OC::$server->getUserFolder($this->user)->get('share'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy($this->user) ->setSharedWith($recipientUser) ->setPermissions(\OCP\Constants::PERMISSION_ALL); diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php index 136d8121cfa..7dfa93bb044 100644 --- a/apps/files_trashbin/tests/TrashbinTest.php +++ b/apps/files_trashbin/tests/TrashbinTest.php @@ -30,6 +30,7 @@ */ use OCA\Files_Sharing\AppInfo\Application; +use OCP\Share\IShare; /** * Class Test_Encryption @@ -223,7 +224,7 @@ class TrashbinTest extends \Test\TestCase { //share user1-4.txt with user2 $node = \OC::$server->getUserFolder(self::TEST_TRASHBIN_USER1)->get($folder); $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setNode($node) ->setSharedBy(self::TEST_TRASHBIN_USER1) ->setSharedWith(self::TEST_TRASHBIN_USER2) diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index 72fd313ac16..ffbf4e19f98 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -336,7 +336,7 @@ class VersioningTest extends \Test\TestCase { $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -403,7 +403,7 @@ class VersioningTest extends \Test\TestCase { $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -452,7 +452,7 @@ class VersioningTest extends \Test\TestCase { $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -519,7 +519,7 @@ class VersioningTest extends \Test\TestCase { $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('test.txt'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE); @@ -662,7 +662,7 @@ class VersioningTest extends \Test\TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_READ); @@ -700,7 +700,7 @@ class VersioningTest extends \Test\TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -875,7 +875,7 @@ class VersioningTest extends \Test\TestCase { $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 3a1a069172c..0f1afd43ba4 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -177,7 +177,7 @@ class ShareByMailProvider implements IShareProvider { /* * Check if file is not already shared with the remote user */ - $alreadyShared = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_EMAIL, $share->getNode(), 1, 0); + $alreadyShared = $this->getSharedWith($shareWith, IShare::TYPE_EMAIL, $share->getNode(), 1, 0); if (!empty($alreadyShared)) { $message = 'Sharing %1$s failed, this item is already shared with %2$s'; $message_t = $this->l->t('Sharing %1$s failed, this item is already shared with %2$s', [$share->getNode()->getName(), $shareWith]); @@ -655,7 +655,7 @@ class ShareByMailProvider implements IShareProvider { $qb->select('*') ->from('share') ->where($qb->expr()->eq('parent', $qb->createNamedParameter($parent->getId()))) - ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))) + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->orderBy('id'); $cursor = $qb->execute(); @@ -685,7 +685,7 @@ class ShareByMailProvider implements IShareProvider { protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload) { $qb = $this->dbConnection->getQueryBuilder(); $qb->insert('share') - ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)) + ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)) ->setValue('item_type', $qb->createNamedParameter($itemType)) ->setValue('item_source', $qb->createNamedParameter($itemSource)) ->setValue('file_source', $qb->createNamedParameter($itemSource)) @@ -794,7 +794,7 @@ class ShareByMailProvider implements IShareProvider { $qb->select('*') ->from('share'); - $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))); + $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))); /** * Reshares for this user are shares where they are the owner. @@ -851,7 +851,7 @@ class ShareByMailProvider implements IShareProvider { $qb->select('*') ->from('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) - ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))); + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))); $cursor = $qb->execute(); $data = $cursor->fetch(); @@ -882,7 +882,7 @@ class ShareByMailProvider implements IShareProvider { $cursor = $qb->select('*') ->from('share') ->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($path->getId()))) - ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))) + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->execute(); $shares = []; @@ -915,7 +915,7 @@ class ShareByMailProvider implements IShareProvider { } $qb->setFirstResult($offset); - $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))); + $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))); $qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))); // Filter by node if provided @@ -946,7 +946,7 @@ class ShareByMailProvider implements IShareProvider { $cursor = $qb->select('*') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token))) ->execute(); @@ -1065,7 +1065,7 @@ class ShareByMailProvider implements IShareProvider { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->andWhere($qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid))) ->execute(); } @@ -1122,7 +1122,7 @@ class ShareByMailProvider implements IShareProvider { $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->andWhere( - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)) + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)) ); /** @@ -1166,7 +1166,7 @@ class ShareByMailProvider implements IShareProvider { $qb = $this->dbConnection->getQueryBuilder(); $qb->select('share_with') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index 2dc8ff9c953..61c76ea1f39 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -762,7 +762,7 @@ class ShareByMailProviderTest extends TestCase { $instance = $this->getInstance(['createShareObject']); $idMail = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token); - $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, '', \OCP\Share::SHARE_TYPE_LINK); + $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, '', IShare::TYPE_LINK); $this->assertTrue($idMail !== $idPublic); @@ -795,7 +795,7 @@ class ShareByMailProviderTest extends TestCase { $instance = $this->getInstance(['createShareObject']); $idMail = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token); - $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, "token2", '', \OCP\Share::SHARE_TYPE_LINK); + $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, "token2", '', IShare::TYPE_LINK); $this->assertTrue($idMail !== $idPublic); @@ -858,7 +858,7 @@ class ShareByMailProviderTest extends TestCase { $instance = $this->getInstance(); - $instance->userDeleted($uidOwner, \OCP\Share::SHARE_TYPE_EMAIL); + $instance->userDeleted($uidOwner, IShare::TYPE_EMAIL); $query = $this->connection->getQueryBuilder(); $query->select('*')->from('share'); @@ -913,7 +913,7 @@ class ShareByMailProviderTest extends TestCase { $this->invokePrivate($instance, 'getRawShare', [$id+1]); } - private function createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $note='', $shareType = \OCP\Share::SHARE_TYPE_EMAIL) { + private function createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $note='', $shareType = IShare::TYPE_EMAIL) { $qb = $this->connection->getQueryBuilder(); $qb->insert('share') ->setValue('share_type', $qb->createNamedParameter($shareType)) diff --git a/core/Controller/AutoCompleteController.php b/core/Controller/AutoCompleteController.php index 0eebaabafd6..aa67ff9a30a 100644 --- a/core/Controller/AutoCompleteController.php +++ b/core/Controller/AutoCompleteController.php @@ -36,6 +36,7 @@ use OCP\Collaboration\AutoComplete\IManager; use OCP\Collaboration\Collaborators\ISearch; use OCP\IRequest; use OCP\Share; +use OCP\Share\IShare; use Symfony\Component\EventDispatcher\EventDispatcherInterface; class AutoCompleteController extends Controller { @@ -71,7 +72,7 @@ class AutoCompleteController extends Controller { * @param int $limit * @return DataResponse */ - public function get($search, $itemType, $itemId, $sorter = null, $shareTypes = [Share::SHARE_TYPE_USER], $limit = 10): DataResponse { + public function get($search, $itemType, $itemId, $sorter = null, $shareTypes = [IShare::TYPE_USER], $limit = 10): DataResponse { // if enumeration/user listings are disabled, we'll receive an empty // result from search() – thus nothing else to do here. [$results,] = $this->collaboratorSearch->search($search, $shareTypes, false, $limit, 0); diff --git a/lib/private/Collaboration/Collaborators/GroupPlugin.php b/lib/private/Collaboration/Collaborators/GroupPlugin.php index 4816fdd7c04..d4051cab36f 100644 --- a/lib/private/Collaboration/Collaborators/GroupPlugin.php +++ b/lib/private/Collaboration/Collaborators/GroupPlugin.php @@ -34,7 +34,7 @@ use OCP\IConfig; use OCP\IGroup; use OCP\IGroupManager; use OCP\IUserSession; -use OCP\Share; +use OCP\Share\IShare; class GroupPlugin implements ISearchPlugin { protected $shareeEnumeration; @@ -95,7 +95,7 @@ class GroupPlugin implements ISearchPlugin { $result['exact'][] = [ 'label' => $group->getDisplayName(), 'value' => [ - 'shareType' => Share::SHARE_TYPE_GROUP, + 'shareType' => IShare::TYPE_GROUP, 'shareWith' => $gid, ], ]; @@ -106,7 +106,7 @@ class GroupPlugin implements ISearchPlugin { $result['wide'][] = [ 'label' => $group->getDisplayName(), 'value' => [ - 'shareType' => Share::SHARE_TYPE_GROUP, + 'shareType' => IShare::TYPE_GROUP, 'shareWith' => $gid, ], ]; @@ -121,7 +121,7 @@ class GroupPlugin implements ISearchPlugin { $result['exact'][] = [ 'label' => $group->getDisplayName(), 'value' => [ - 'shareType' => Share::SHARE_TYPE_GROUP, + 'shareType' => IShare::TYPE_GROUP, 'shareWith' => $group->getGID(), ], ]; diff --git a/lib/private/Collaboration/Collaborators/LookupPlugin.php b/lib/private/Collaboration/Collaborators/LookupPlugin.php index f0d5b92f18a..ab36d712d2a 100644 --- a/lib/private/Collaboration/Collaborators/LookupPlugin.php +++ b/lib/private/Collaboration/Collaborators/LookupPlugin.php @@ -34,7 +34,7 @@ use OCP\Http\Client\IClientService; use OCP\IConfig; use OCP\ILogger; use OCP\IUserSession; -use OCP\Share; +use OCP\Share\IShare; class LookupPlugin implements ISearchPlugin { @@ -107,7 +107,7 @@ class LookupPlugin implements ISearchPlugin { $result[] = [ 'label' => $label, 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $lookup['federationId'], ], 'extra' => $lookup, diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index f912690cb72..90dc5919176 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -37,7 +37,7 @@ use OCP\IConfig; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserSession; -use OCP\Share; +use OCP\Share\IShare; class MailPlugin implements ISearchPlugin { protected $shareeEnumeration; @@ -133,7 +133,7 @@ class MailPlugin implements ISearchPlugin { 'uuid' => $contact['UID'], 'name' => $contact['FN'], 'value' => [ - 'shareType' => Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => $cloud->getUser(), ], ]]; @@ -167,7 +167,7 @@ class MailPlugin implements ISearchPlugin { 'uuid' => $contact['UID'], 'name' => $contact['FN'], 'value' => [ - 'shareType' => Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => $cloud->getUser(), ], ]; @@ -188,7 +188,7 @@ class MailPlugin implements ISearchPlugin { 'name' => $contact['FN'], 'type' => $emailAddressType ?? '', 'value' => [ - 'shareType' => Share::SHARE_TYPE_EMAIL, + 'shareType' => IShare::TYPE_EMAIL, 'shareWith' => $emailAddress, ], ]; @@ -199,7 +199,7 @@ class MailPlugin implements ISearchPlugin { 'name' => $contact['FN'], 'type' => $emailAddressType ?? '', 'value' => [ - 'shareType' => Share::SHARE_TYPE_EMAIL, + 'shareType' => IShare::TYPE_EMAIL, 'shareWith' => $emailAddress, ], ]; @@ -226,7 +226,7 @@ class MailPlugin implements ISearchPlugin { 'label' => $search, 'uuid' => $search, 'value' => [ - 'shareType' => Share::SHARE_TYPE_EMAIL, + 'shareType' => IShare::TYPE_EMAIL, 'shareWith' => $search, ], ]; diff --git a/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php b/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php index 777af6093db..17e7793a685 100644 --- a/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php +++ b/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php @@ -30,6 +30,7 @@ use OCP\Collaboration\Collaborators\SearchResultType; use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\ICloudIdManager; use OCP\Share; +use OCP\Share\IShare; class RemoteGroupPlugin implements ISearchPlugin { protected $shareeEnumeration; @@ -63,7 +64,7 @@ class RemoteGroupPlugin implements ISearchPlugin { 'guid' => $remoteGroup, 'name' => $remoteGroup, 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE_GROUP, + 'shareType' => IShare::TYPE_REMOTE_GROUP, 'shareWith' => $search, 'server' => $serverUrl, ], diff --git a/lib/private/Collaboration/Collaborators/RemotePlugin.php b/lib/private/Collaboration/Collaborators/RemotePlugin.php index 81e05050d2e..af94027fbe9 100644 --- a/lib/private/Collaboration/Collaborators/RemotePlugin.php +++ b/lib/private/Collaboration/Collaborators/RemotePlugin.php @@ -35,7 +35,7 @@ use OCP\Federation\ICloudIdManager; use OCP\IConfig; use OCP\IUserManager; use OCP\IUserSession; -use OCP\Share; +use OCP\Share\IShare; class RemotePlugin implements ISearchPlugin { protected $shareeEnumeration; @@ -101,7 +101,7 @@ class RemotePlugin implements ISearchPlugin { 'label' => $contact['FN'], 'uuid' => $contact['UID'], 'value' => [ - 'shareType' => Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => $remoteUser ] ]; @@ -117,7 +117,7 @@ class RemotePlugin implements ISearchPlugin { 'name' => $contact['FN'], 'type' => $cloudIdType, 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $cloudId, 'server' => $serverUrl, ], @@ -129,7 +129,7 @@ class RemotePlugin implements ISearchPlugin { 'name' => $contact['FN'], 'type' => $cloudIdType, 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $cloudId, 'server' => $serverUrl, ], @@ -158,7 +158,7 @@ class RemotePlugin implements ISearchPlugin { 'uuid' => $remoteUser, 'name' => $remoteUser, 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $search, 'server' => $serverUrl, ], diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php index 123fa731445..c5600fce070 100644 --- a/lib/private/Collaboration/Collaborators/UserPlugin.php +++ b/lib/private/Collaboration/Collaborators/UserPlugin.php @@ -115,7 +115,7 @@ class UserPlugin implements ISearchPlugin { $result['exact'][] = [ 'label' => $userDisplayName, 'value' => [ - 'shareType' => Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => $uid, ], ]; @@ -161,7 +161,7 @@ class UserPlugin implements ISearchPlugin { $result['exact'][] = [ 'label' => $user->getDisplayName(), 'value' => [ - 'shareType' => Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => $user->getUID(), ], ]; diff --git a/lib/private/Federation/CloudFederationShare.php b/lib/private/Federation/CloudFederationShare.php index 16f4216d65e..507a3cd061a 100644 --- a/lib/private/Federation/CloudFederationShare.php +++ b/lib/private/Federation/CloudFederationShare.php @@ -24,6 +24,7 @@ namespace OC\Federation; use OCP\Federation\ICloudFederationShare; +use OCP\Share\IShare; class CloudFederationShare implements ICloudFederationShare { private $share = [ @@ -204,7 +205,7 @@ class CloudFederationShare implements ICloudFederationShare { * @since 14.0.0 */ public function setShareType($shareType) { - if ($shareType === 'group' || $shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { + if ($shareType === 'group' || $shareType === IShare::TYPE_REMOTE_GROUP) { $this->share['shareType'] = 'group'; } else { $this->share['shareType'] = 'user'; diff --git a/lib/private/Repair/OldGroupMembershipShares.php b/lib/private/Repair/OldGroupMembershipShares.php index ae4c501d251..2b2fd9cd470 100644 --- a/lib/private/Repair/OldGroupMembershipShares.php +++ b/lib/private/Repair/OldGroupMembershipShares.php @@ -28,7 +28,7 @@ use OCP\IDBConnection; use OCP\IGroupManager; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; -use OCP\Share; +use OCP\Share\IShare; class OldGroupMembershipShares implements IRepairStep { @@ -78,7 +78,7 @@ class OldGroupMembershipShares implements IRepairStep { // \OC\Share\Constant::$shareTypeGroupUserUnique === 2 ->andWhere($query->expr()->eq('s1.share_type', $query->expr()->literal(2))) ->andWhere($query->expr()->isNotNull('s2.id')) - ->andWhere($query->expr()->eq('s2.share_type', $query->expr()->literal(Share::SHARE_TYPE_GROUP))) + ->andWhere($query->expr()->eq('s2.share_type', $query->expr()->literal(IShare::TYPE_GROUP))) ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')); $deleteQuery = $this->connection->getQueryBuilder(); diff --git a/lib/private/Share/Helper.php b/lib/private/Share/Helper.php index ec5136040e8..90dc3e957e9 100644 --- a/lib/private/Share/Helper.php +++ b/lib/private/Share/Helper.php @@ -31,6 +31,7 @@ namespace OC\Share; use OC\HintException; +use OCP\Share\IShare; class Helper extends \OC\Share\Constants { @@ -49,13 +50,13 @@ class Helper extends \OC\Share\Constants { public static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $suggestedTarget = null, $groupParent = null) { // FIXME: $uidOwner and $groupParent seems to be unused $backend = \OC\Share\Share::getBackend($itemType); - if ($shareType === self::SHARE_TYPE_LINK || $shareType === self::SHARE_TYPE_REMOTE) { + if ($shareType === IShare::TYPE_LINK || $shareType === IShare::TYPE_REMOTE) { if (isset($suggestedTarget)) { return $suggestedTarget; } return $backend->generateTarget($itemSource, false); } else { - if ($shareType == self::SHARE_TYPE_USER) { + if ($shareType == IShare::TYPE_USER) { // Share with is a user, so set share type to user and groups $shareType = self::$shareTypeUserAndGroups; } @@ -64,7 +65,7 @@ class Helper extends \OC\Share\Constants { if (!isset($suggestedTarget)) { $suggestedTarget = $itemSource; } - if ($shareType == self::SHARE_TYPE_GROUP) { + if ($shareType == IShare::TYPE_GROUP) { $target = $backend->generateTarget($suggestedTarget, false); } else { $target = $backend->generateTarget($suggestedTarget, $shareWith); diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index 8ea97cd69a7..c624f243123 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -39,6 +39,7 @@ namespace OC\Share; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\ILogger; +use OCP\Share\IShare; /** * This class provides the ability for apps to share their content between users. @@ -278,7 +279,7 @@ class Share extends Constants { * @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 * @deprecated 14.0.0 TESTS ONLY - this methods is as of 2018-06 only used by tests * called like this: - * \OC\Share\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ); + * \OC\Share\Share::shareItem('test', 1, IShare::TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ); */ public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) { $backend = self::getBackend($itemType); @@ -291,7 +292,7 @@ class Share extends Constants { $uidOwner = \OC_User::getUser(); // Verify share type and sharing conditions are met - if ($shareType === self::SHARE_TYPE_USER) { + if ($shareType === IShare::TYPE_USER) { if ($shareWith == $uidOwner) { $message = 'Sharing failed, because you can not share with yourself'; throw new \Exception($message); @@ -311,7 +312,7 @@ class Share extends Constants { throw new \Exception(sprintf($message, $shareWith)); } } - if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_USER, + if ($checkExists = self::getItems($itemType, $itemSource, IShare::TYPE_USER, $shareWith, null, self::FORMAT_NONE, null, 1, true, true)) { // Only allow the same share to occur again if it is the same // owner and is not a user share, this use case is for increasing @@ -324,7 +325,7 @@ class Share extends Constants { } // Put the item into the database - $result = self::put('test', $itemSource, self::SHARE_TYPE_USER, $shareWith, $uidOwner, $permissions); + $result = self::put('test', $itemSource, IShare::TYPE_USER, $shareWith, $uidOwner, $permissions); return $result ? true : false; } @@ -378,7 +379,7 @@ class Share extends Constants { $result = false; // only use default expiration date for link shares - if ((int) $item['share_type'] === self::SHARE_TYPE_LINK) { + if ((int) $item['share_type'] === IShare::TYPE_LINK) { // calculate expiration date if (!empty($item['expiration'])) { @@ -414,7 +415,7 @@ class Share extends Constants { protected static function unshareItem(array $item, $newParent = null) { $shareType = (int)$item['share_type']; $shareWith = null; - if ($shareType !== \OCP\Share::SHARE_TYPE_LINK) { + if ($shareType !== IShare::TYPE_LINK) { $shareWith = $item['share_with']; } @@ -438,7 +439,7 @@ class Share extends Constants { $deletedShares[] = $hookParams; $hookParams['deletedShares'] = $deletedShares; \OC_Hook::emit(\OCP\Share::class, 'post_unshare', $hookParams); - if ((int)$item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) { + if ((int)$item['share_type'] === IShare::TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) { list(, $remote) = Helper::splitUserRemote($item['share_with']); self::sendRemoteUnshare($remote, $item['id'], $item['token']); } @@ -635,13 +636,13 @@ class Share extends Constants { } if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { $where .= ' AND `share_type` != ?'; - $queryArgs[] = self::SHARE_TYPE_LINK; + $queryArgs[] = IShare::TYPE_LINK; } if (isset($shareType)) { // Include all user and group items if ($shareType == self::$shareTypeUserAndGroups && isset($shareWith)) { $where .= ' AND ((`share_type` in (?, ?) AND `share_with` = ?) '; - $queryArgs[] = self::SHARE_TYPE_USER; + $queryArgs[] = IShare::TYPE_USER; $queryArgs[] = self::$shareTypeGroupUserUnique; $queryArgs[] = $shareWith; @@ -653,7 +654,7 @@ class Share extends Constants { if (!empty($groups)) { $placeholders = implode(',', array_fill(0, count($groups), '?')); $where .= ' OR (`share_type` = ? AND `share_with` IN ('.$placeholders.')) '; - $queryArgs[] = self::SHARE_TYPE_GROUP; + $queryArgs[] = IShare::TYPE_GROUP; $queryArgs = array_merge($queryArgs, $groups); } $where .= ')'; @@ -761,7 +762,7 @@ class Share extends Constants { continue; } if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) { - $row['share_type'] = self::SHARE_TYPE_GROUP; + $row['share_type'] = IShare::TYPE_GROUP; $row['unique_name'] = true; // remember that we use a unique name for this user $row['share_with'] = $items[$row['parent']]['share_with']; // if the group share was unshared from the user we keep the permission, otherwise @@ -783,8 +784,8 @@ class Share extends Constants { $id = $targets[$row['id']]; if (isset($items[$id]) && $items[$id]['uid_owner'] == $row['uid_owner']) { // Switch to group share type to ensure resharing conditions aren't bypassed - if ($items[$id]['share_type'] != self::SHARE_TYPE_GROUP) { - $items[$id]['share_type'] = self::SHARE_TYPE_GROUP; + if ($items[$id]['share_type'] != IShare::TYPE_GROUP) { + $items[$id]['share_type'] = IShare::TYPE_GROUP; $items[$id]['share_with'] = $row['share_with']; } // Switch ids if sharing permission is granted on only @@ -851,11 +852,11 @@ class Share extends Constants { // Add display names to result $row['share_with_displayname'] = $row['share_with']; if (isset($row['share_with']) && $row['share_with'] != '' && - $row['share_type'] === self::SHARE_TYPE_USER) { + $row['share_type'] === IShare::TYPE_USER) { $shareWithUser = \OC::$server->getUserManager()->get($row['share_with']); $row['share_with_displayname'] = $shareWithUser === null ? $row['share_with'] : $shareWithUser->getDisplayName(); } elseif (isset($row['share_with']) && $row['share_with'] != '' && - $row['share_type'] === self::SHARE_TYPE_REMOTE) { + $row['share_type'] === IShare::TYPE_REMOTE) { $addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']); foreach ($addressBookEntries as $entry) { foreach ($entry['CLOUD'] as $cloudID) { @@ -1045,7 +1046,7 @@ class Share extends Constants { * @return mixed id of the new share or false * @deprecated TESTS ONLY - this methods is only used by tests * called like this: - * self::put('test', $itemSource, self::SHARE_TYPE_USER, $shareWith, $uidOwner, $permissions); + * self::put('test', $itemSource, IShare::TYPE_USER, $shareWith, $uidOwner, $permissions); */ private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions) { @@ -1054,7 +1055,7 @@ class Share extends Constants { $groupFileTarget = $fileTarget = $suggestedFileTarget = $filePath = ''; $groupItemTarget = $itemTarget = $fileSource = $parent = 0; - $result = self::checkReshare('test', $itemSource, self::SHARE_TYPE_USER, $shareWith, $uidOwner, $permissions, null, null); + $result = self::checkReshare('test', $itemSource, IShare::TYPE_USER, $shareWith, $uidOwner, $permissions, null, null); if (!empty($result)) { $parent = $result['parent']; $itemSource = $result['itemSource']; @@ -1115,12 +1116,12 @@ class Share extends Constants { // group share which doesn't exists until now, check if we need a unique target for this user - $itemTarget = Helper::generateTarget($itemType, $itemSource, self::SHARE_TYPE_USER, $user, + $itemTarget = Helper::generateTarget($itemType, $itemSource, IShare::TYPE_USER, $user, $uidOwner, $suggestedItemTarget, $parent); // do we also need a file target if (isset($fileSource)) { - $fileTarget = Helper::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $user, + $fileTarget = Helper::generateTarget('file', $filePath, IShare::TYPE_USER, $user, $uidOwner, $suggestedFileTarget, $parent); } else { $fileTarget = null; @@ -1190,7 +1191,7 @@ class Share extends Constants { * @param null|\DateTime $expirationDate * @deprecated TESTS ONLY - this methods is only used by tests * called like this: - * self::checkReshare('test', $itemSource, self::SHARE_TYPE_USER, $shareWith, $uidOwner, $permissions, null, null); + * self::checkReshare('test', $itemSource, IShare::TYPE_USER, $shareWith, $uidOwner, $permissions, null, null); */ private static function checkReshare($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, $itemSourceName, $expirationDate) { $backend = self::getBackend($itemType); @@ -1384,7 +1385,7 @@ class Share extends Constants { if (isset($row['stime'])) { $row['stime'] = (int) $row['stime']; } - if (isset($row['expiration']) && $row['share_type'] !== self::SHARE_TYPE_LINK) { + if (isset($row['expiration']) && $row['share_type'] !== IShare::TYPE_LINK) { // discard expiration date for non-link shares, which might have been // set by ancient bugs $row['expiration'] = null; @@ -1406,7 +1407,7 @@ class Share extends Constants { } elseif ($format === self::FORMAT_STATUSES) { $statuses = []; foreach ($items as $item) { - if ($item['share_type'] === self::SHARE_TYPE_LINK) { + if ($item['share_type'] === IShare::TYPE_LINK) { if ($item['uid_initiator'] !== \OC::$server->getUserSession()->getUser()->getUID()) { continue; } diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 302c3573a30..202b11a6c3d 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -136,7 +136,7 @@ class DefaultShareProvider implements IShareProvider { $qb->insert('share'); $qb->setValue('share_type', $qb->createNamedParameter($share->getShareType())); - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { + if ($share->getShareType() === IShare::TYPE_USER) { //Set the UID of the user we share with $qb->setValue('share_with', $qb->createNamedParameter($share->getSharedWith())); $qb->setValue('accepted', $qb->createNamedParameter(IShare::STATUS_PENDING)); @@ -145,7 +145,7 @@ class DefaultShareProvider implements IShareProvider { if ($share->getExpirationDate() !== null) { $qb->setValue('expiration', $qb->createNamedParameter($share->getExpirationDate(), 'datetime')); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($share->getShareType() === IShare::TYPE_GROUP) { //Set the GID of the group we share with $qb->setValue('share_with', $qb->createNamedParameter($share->getSharedWith())); @@ -153,7 +153,7 @@ class DefaultShareProvider implements IShareProvider { if ($share->getExpirationDate() !== null) { $qb->setValue('expiration', $qb->createNamedParameter($share->getExpirationDate(), 'datetime')); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { + } elseif ($share->getShareType() === IShare::TYPE_LINK) { //set label for public link $qb->setValue('label', $qb->createNamedParameter($share->getLabel())); //Set the token of the share @@ -244,7 +244,7 @@ class DefaultShareProvider implements IShareProvider { public function update(\OCP\Share\IShare $share) { $originalShare = $this->getShareById($share->getId()); - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { + if ($share->getShareType() === IShare::TYPE_USER) { /* * We allow updating the recipient on user shares. */ @@ -261,7 +261,7 @@ class DefaultShareProvider implements IShareProvider { ->set('note', $qb->createNamedParameter($share->getNote())) ->set('accepted', $qb->createNamedParameter($share->getStatus())) ->execute(); - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($share->getShareType() === IShare::TYPE_GROUP) { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) @@ -280,7 +280,7 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) - ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))) ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) @@ -298,7 +298,7 @@ class DefaultShareProvider implements IShareProvider { ->andWhere($qb->expr()->neq('permissions', $qb->createNamedParameter(0))) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->execute(); - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { + } elseif ($share->getShareType() === IShare::TYPE_LINK) { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) @@ -350,7 +350,7 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->select('*') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->andWhere($qb->expr()->orX( @@ -408,9 +408,9 @@ class DefaultShareProvider implements IShareProvider { $qb->expr()->in( 'share_type', $qb->createNamedParameter([ - \OCP\Share::SHARE_TYPE_USER, - \OCP\Share::SHARE_TYPE_GROUP, - \OCP\Share::SHARE_TYPE_LINK, + IShare::TYPE_USER, + IShare::TYPE_GROUP, + IShare::TYPE_LINK, ], IQueryBuilder::PARAM_INT_ARRAY) ) ) @@ -443,7 +443,7 @@ class DefaultShareProvider implements IShareProvider { * If the share is a group share delete all possible * user defined groups shares. */ - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + if ($share->getShareType() === IShare::TYPE_GROUP) { $qb->orWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))); } @@ -476,7 +476,7 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->select('*') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->andWhere($qb->expr()->orX( @@ -525,7 +525,7 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP), + 'share_type' => $qb->createNamedParameter(IShare::TYPE_USERGROUP), 'share_with' => $qb->createNamedParameter($recipient), 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()), 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()), @@ -566,7 +566,7 @@ class DefaultShareProvider implements IShareProvider { ->where( $qb->expr()->eq('parent', $qb->createNamedParameter($share->getParent())) )->andWhere( - $qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)) + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)) )->andWhere( $qb->expr()->eq('share_with', $qb->createNamedParameter($recipient)) ); @@ -580,20 +580,20 @@ class DefaultShareProvider implements IShareProvider { * @inheritdoc */ public function move(\OCP\Share\IShare $share, $recipient) { - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { + if ($share->getShareType() === IShare::TYPE_USER) { // Just update the target $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->set('file_target', $qb->createNamedParameter($share->getTarget())) ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->execute(); - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($share->getShareType() === IShare::TYPE_GROUP) { // Check if there is a usergroup share $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->select('id') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->andWhere($qb->expr()->orX( @@ -611,7 +611,7 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP), + 'share_type' => $qb->createNamedParameter(IShare::TYPE_USERGROUP), 'share_with' => $qb->createNamedParameter($recipient), 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()), 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()), @@ -646,9 +646,9 @@ class DefaultShareProvider implements IShareProvider { )); $qb->andWhere($qb->expr()->orX( - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)), - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)), - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK)) + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER)), + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)), + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_LINK)) )); /** @@ -744,9 +744,9 @@ class DefaultShareProvider implements IShareProvider { $qb->expr()->in( 'share_type', $qb->createNamedParameter([ - \OCP\Share::SHARE_TYPE_USER, - \OCP\Share::SHARE_TYPE_GROUP, - \OCP\Share::SHARE_TYPE_LINK, + IShare::TYPE_USER, + IShare::TYPE_GROUP, + IShare::TYPE_LINK, ], IQueryBuilder::PARAM_INT_ARRAY) ) ) @@ -770,7 +770,7 @@ class DefaultShareProvider implements IShareProvider { } // If the recipient is set for a group share resolve to that user - if ($recipientId !== null && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + if ($recipientId !== null && $share->getShareType() === IShare::TYPE_GROUP) { $share = $this->resolveGroupShares([$share], $recipientId)[0]; } @@ -791,8 +791,8 @@ class DefaultShareProvider implements IShareProvider { ->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($path->getId()))) ->andWhere( $qb->expr()->orX( - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)), - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)) + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER)), + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)) ) ) ->andWhere($qb->expr()->orX( @@ -837,7 +837,7 @@ class DefaultShareProvider implements IShareProvider { /** @var Share[] $shares */ $shares = []; - if ($shareType === \OCP\Share::SHARE_TYPE_USER) { + if ($shareType === IShare::TYPE_USER) { //Get shares directly with this user $qb = $this->dbConn->getQueryBuilder(); $qb->select('s.*', @@ -859,7 +859,7 @@ class DefaultShareProvider implements IShareProvider { } $qb->setFirstResult($offset); - $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER))) + $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), @@ -879,7 +879,7 @@ class DefaultShareProvider implements IShareProvider { } } $cursor->closeCursor(); - } elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($shareType === IShare::TYPE_GROUP) { $user = $this->userManager->get($userId); $allGroups = $this->groupManager->getUserGroupIds($user); @@ -920,7 +920,7 @@ class DefaultShareProvider implements IShareProvider { $groups = array_filter($groups); - $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))) + $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))) ->andWhere($qb->expr()->in('share_with', $qb->createNamedParameter( $groups, IQueryBuilder::PARAM_STR_ARRAY @@ -968,7 +968,7 @@ class DefaultShareProvider implements IShareProvider { $cursor = $qb->select('*') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_LINK))) ->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), @@ -1013,15 +1013,15 @@ class DefaultShareProvider implements IShareProvider { $shareTime->setTimestamp((int)$data['stime']); $share->setShareTime($shareTime); - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { + if ($share->getShareType() === IShare::TYPE_USER) { $share->setSharedWith($data['share_with']); $user = $this->userManager->get($data['share_with']); if ($user !== null) { $share->setSharedWithDisplayName($user->getDisplayName()); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($share->getShareType() === IShare::TYPE_GROUP) { $share->setSharedWith($data['share_with']); - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { + } elseif ($share->getShareType() === IShare::TYPE_LINK) { $share->setPassword($data['password']); $share->setSendPasswordByTalk((bool)$data['password_by_talk']); $share->setToken($data['token']); @@ -1122,13 +1122,13 @@ class DefaultShareProvider implements IShareProvider { $qb->delete('share'); - if ($shareType === \OCP\Share::SHARE_TYPE_USER) { + if ($shareType === IShare::TYPE_USER) { /* * Delete all user shares that are owned by this user * or that are received by this user */ - $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER))); + $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER))); $qb->andWhere( $qb->expr()->orX( @@ -1136,7 +1136,7 @@ class DefaultShareProvider implements IShareProvider { $qb->expr()->eq('share_with', $qb->createNamedParameter($uid)) ) ); - } elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($shareType === IShare::TYPE_GROUP) { /* * Delete all group shares that are owned by this user * Or special user group shares that are received by this user @@ -1144,8 +1144,8 @@ class DefaultShareProvider implements IShareProvider { $qb->where( $qb->expr()->andX( $qb->expr()->orX( - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)), - $qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)) + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)), + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)) ), $qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid)) ) @@ -1153,16 +1153,16 @@ class DefaultShareProvider implements IShareProvider { $qb->orWhere( $qb->expr()->andX( - $qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)), + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)), $qb->expr()->eq('share_with', $qb->createNamedParameter($uid)) ) ); - } elseif ($shareType === \OCP\Share::SHARE_TYPE_LINK) { + } elseif ($shareType === IShare::TYPE_LINK) { /* * Delete all link shares owned by this user. * And all link shares initiated by this user (until #22327 is in) */ - $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK))); + $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_LINK))); $qb->andWhere( $qb->expr()->orX( @@ -1191,7 +1191,7 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $qb->select('id') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid))); $cursor = $qb->execute(); @@ -1205,7 +1205,7 @@ class DefaultShareProvider implements IShareProvider { $chunks = array_chunk($ids, 100); foreach ($chunks as $chunk) { $qb->delete('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))) ->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY))); $qb->execute(); } @@ -1216,7 +1216,7 @@ class DefaultShareProvider implements IShareProvider { */ $qb = $this->dbConn->getQueryBuilder(); $qb->delete('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid))); $qb->execute(); } @@ -1234,7 +1234,7 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $qb->select('id') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid))); $cursor = $qb->execute(); @@ -1251,7 +1251,7 @@ class DefaultShareProvider implements IShareProvider { * Delete all special shares wit this users for the found group shares */ $qb->delete('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($uid))) ->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY))); $qb->execute(); @@ -1271,13 +1271,13 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $or = $qb->expr()->orX( - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)), - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)), - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK)) + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER)), + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)), + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_LINK)) ); if ($currentAccess) { - $or->add($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))); + $or->add($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))); } $qb->select('id', 'parent', 'share_type', 'share_with', 'file_source', 'file_target', 'permissions') @@ -1296,11 +1296,11 @@ class DefaultShareProvider implements IShareProvider { $link = false; while ($row = $cursor->fetch()) { $type = (int)$row['share_type']; - if ($type === \OCP\Share::SHARE_TYPE_USER) { + if ($type === IShare::TYPE_USER) { $uid = $row['share_with']; $users[$uid] = isset($users[$uid]) ? $users[$uid] : []; $users[$uid][$row['id']] = $row; - } elseif ($type === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($type === IShare::TYPE_GROUP) { $gid = $row['share_with']; $group = $this->groupManager->get($gid); @@ -1314,9 +1314,9 @@ class DefaultShareProvider implements IShareProvider { $users[$uid] = isset($users[$uid]) ? $users[$uid] : []; $users[$uid][$row['id']] = $row; } - } elseif ($type === \OCP\Share::SHARE_TYPE_LINK) { + } elseif ($type === IShare::TYPE_LINK) { $link = true; - } elseif ($type === self::SHARE_TYPE_USERGROUP && $currentAccess === true) { + } elseif ($type === IShare::TYPE_USERGROUP && $currentAccess === true) { $uid = $row['share_with']; $users[$uid] = isset($users[$uid]) ? $users[$uid] : []; $users[$uid][$row['id']] = $row; @@ -1345,7 +1345,7 @@ class DefaultShareProvider implements IShareProvider { $type = (int) $share['share_type']; $permissions = (int) $share['permissions']; - if ($type === self::SHARE_TYPE_USERGROUP) { + if ($type === IShare::TYPE_USERGROUP) { unset($shares[$share['parent']]); if ($permissions === 0) { @@ -1377,10 +1377,10 @@ class DefaultShareProvider implements IShareProvider { * @throws \OCP\Files\NotFoundException */ private function propagateNote(IShare $share) { - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { + if ($share->getShareType() === IShare::TYPE_USER) { $user = $this->userManager->get($share->getSharedWith()); $this->sendNote([$user], $share); - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($share->getShareType() === IShare::TYPE_GROUP) { $group = $this->groupManager->get($share->getSharedWith()); $groupMembers = $group->getUsers(); $this->sendNote($groupMembers, $share); diff --git a/lib/private/Share20/LegacyHooks.php b/lib/private/Share20/LegacyHooks.php index 1e2391f0bd0..285b45be809 100644 --- a/lib/private/Share20/LegacyHooks.php +++ b/lib/private/Share20/LegacyHooks.php @@ -102,9 +102,9 @@ class LegacyHooks { // Prepare hook $shareType = $share->getShareType(); $sharedWith = ''; - if ($shareType === \OCP\Share::SHARE_TYPE_USER || - $shareType === \OCP\Share::SHARE_TYPE_GROUP || - $shareType === \OCP\Share::SHARE_TYPE_REMOTE) { + if ($shareType === IShare::TYPE_USER || + $shareType === IShare::TYPE_GROUP || + $shareType === IShare::TYPE_REMOTE) { $sharedWith = $share->getSharedWith(); } diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 3d7a274e662..91fb11adc76 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -208,45 +208,45 @@ class Manager implements IManager { /** * Check for generic requirements before creating a share * - * @param \OCP\Share\IShare $share + * @param IShare $share * @throws \InvalidArgumentException * @throws GenericShareException * * @suppress PhanUndeclaredClassMethod */ - protected function generalCreateChecks(\OCP\Share\IShare $share) { - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { + protected function generalCreateChecks(IShare $share) { + if ($share->getShareType() === IShare::TYPE_USER) { // We expect a valid user as sharedWith for user shares if (!$this->userManager->userExists($share->getSharedWith())) { throw new \InvalidArgumentException('SharedWith is not a valid user'); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($share->getShareType() === IShare::TYPE_GROUP) { // We expect a valid group as sharedWith for group shares if (!$this->groupManager->groupExists($share->getSharedWith())) { throw new \InvalidArgumentException('SharedWith is not a valid group'); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { + } elseif ($share->getShareType() === IShare::TYPE_LINK) { if ($share->getSharedWith() !== null) { throw new \InvalidArgumentException('SharedWith should be empty'); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) { + } elseif ($share->getShareType() === IShare::TYPE_REMOTE) { if ($share->getSharedWith() === null) { throw new \InvalidArgumentException('SharedWith should not be empty'); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { + } elseif ($share->getShareType() === IShare::TYPE_REMOTE_GROUP) { if ($share->getSharedWith() === null) { throw new \InvalidArgumentException('SharedWith should not be empty'); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { + } elseif ($share->getShareType() === IShare::TYPE_EMAIL) { if ($share->getSharedWith() === null) { throw new \InvalidArgumentException('SharedWith should not be empty'); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) { + } elseif ($share->getShareType() === IShare::TYPE_CIRCLE) { $circle = \OCA\Circles\Api\v1\Circles::detailsCircle($share->getSharedWith()); if ($circle === null) { throw new \InvalidArgumentException('SharedWith is not a valid circle'); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM) { + } elseif ($share->getShareType() === IShare::TYPE_ROOM) { } else { // We can't handle other types yet throw new \InvalidArgumentException('unknown share type'); @@ -258,7 +258,7 @@ class Manager implements IManager { } // Cannot share with yourself - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && + if ($share->getShareType() === IShare::TYPE_USER && $share->getSharedWith() === $share->getSharedBy()) { throw new \InvalidArgumentException('Can’t share with yourself'); } @@ -306,12 +306,12 @@ class Manager implements IManager { $userMountPoint = array_shift($userMountPoints); /* Check if this is an incoming share */ - $incomingShares = $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_USER, $userMountPoint, -1, 0); - $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_GROUP, $userMountPoint, -1, 0)); - $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_CIRCLE, $userMountPoint, -1, 0)); - $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_ROOM, $userMountPoint, -1, 0)); + $incomingShares = $this->getSharedWith($share->getSharedBy(), IShare::TYPE_USER, $userMountPoint, -1, 0); + $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), IShare::TYPE_GROUP, $userMountPoint, -1, 0)); + $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), IShare::TYPE_CIRCLE, $userMountPoint, -1, 0)); + $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), IShare::TYPE_ROOM, $userMountPoint, -1, 0)); - /** @var \OCP\Share\IShare[] $incomingShares */ + /** @var IShare[] $incomingShares */ if (!empty($incomingShares)) { foreach ($incomingShares as $incomingShare) { $permissions |= $incomingShare->getPermissions(); @@ -339,8 +339,8 @@ class Manager implements IManager { // Check that read permissions are always set // Link shares are allowed to have no read permissions to allow upload to hidden folders - $noReadPermissionRequired = $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK - || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL; + $noReadPermissionRequired = $share->getShareType() === IShare::TYPE_LINK + || $share->getShareType() === IShare::TYPE_EMAIL; if (!$noReadPermissionRequired && ($share->getPermissions() & \OCP\Constants::PERMISSION_READ) === 0) { throw new \InvalidArgumentException('Shares need at least read permissions'); @@ -361,13 +361,13 @@ class Manager implements IManager { /** * Validate if the expiration date fits the system settings * - * @param \OCP\Share\IShare $share The share to validate the expiration date of - * @return \OCP\Share\IShare The modified share object + * @param IShare $share The share to validate the expiration date of + * @return IShare The modified share object * @throws GenericShareException * @throws \InvalidArgumentException * @throws \Exception */ - protected function validateExpirationDateInternal(\OCP\Share\IShare $share) { + protected function validateExpirationDateInternal(IShare $share) { $expirationDate = $share->getExpirationDate(); if ($expirationDate !== null) { @@ -437,13 +437,13 @@ class Manager implements IManager { /** * Validate if the expiration date fits the system settings * - * @param \OCP\Share\IShare $share The share to validate the expiration date of - * @return \OCP\Share\IShare The modified share object + * @param IShare $share The share to validate the expiration date of + * @return IShare The modified share object * @throws GenericShareException * @throws \InvalidArgumentException * @throws \Exception */ - protected function validateExpirationDate(\OCP\Share\IShare $share) { + protected function validateExpirationDate(IShare $share) { $expirationDate = $share->getExpirationDate(); if ($expirationDate !== null) { @@ -513,10 +513,10 @@ class Manager implements IManager { /** * Check for pre share requirements for user shares * - * @param \OCP\Share\IShare $share + * @param IShare $share * @throws \Exception */ - protected function userCreateChecks(\OCP\Share\IShare $share) { + protected function userCreateChecks(IShare $share) { // Check if we can share with group members only if ($this->shareWithGroupMembersOnly()) { $sharedBy = $this->userManager->get($share->getSharedBy()); @@ -536,7 +536,7 @@ class Manager implements IManager { * * Also this is not what we want in the future.. then we want to squash identical shares. */ - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_USER); + $provider = $this->factory->getProviderForType(IShare::TYPE_USER); $existingShares = $provider->getSharesByPath($share->getNode()); foreach ($existingShares as $existingShare) { // Ignore if it is the same share @@ -554,7 +554,7 @@ class Manager implements IManager { } // The share is already shared with this user via a group share - if ($existingShare->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + if ($existingShare->getShareType() === IShare::TYPE_GROUP) { $group = $this->groupManager->get($existingShare->getSharedWith()); if (!is_null($group)) { $user = $this->userManager->get($share->getSharedWith()); @@ -570,10 +570,10 @@ class Manager implements IManager { /** * Check for pre share requirements for group shares * - * @param \OCP\Share\IShare $share + * @param IShare $share * @throws \Exception */ - protected function groupCreateChecks(\OCP\Share\IShare $share) { + protected function groupCreateChecks(IShare $share) { // Verify group shares are allowed if (!$this->allowGroupSharing()) { throw new \Exception('Group sharing is now allowed'); @@ -593,7 +593,7 @@ class Manager implements IManager { * * Also this is not what we want in the future.. then we want to squash identical shares. */ - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP); + $provider = $this->factory->getProviderForType(IShare::TYPE_GROUP); $existingShares = $provider->getSharesByPath($share->getNode()); foreach ($existingShares as $existingShare) { try { @@ -613,10 +613,10 @@ class Manager implements IManager { /** * Check for pre share requirements for link shares * - * @param \OCP\Share\IShare $share + * @param IShare $share * @throws \Exception */ - protected function linkCreateChecks(\OCP\Share\IShare $share) { + protected function linkCreateChecks(IShare $share) { // Are link shares allowed? if (!$this->shareApiAllowLinks()) { throw new \Exception('Link sharing is not allowed'); @@ -638,9 +638,9 @@ class Manager implements IManager { * * FIXME: Remove once multiple link shares can be properly displayed * - * @param \OCP\Share\IShare $share + * @param IShare $share */ - protected function setLinkParent(\OCP\Share\IShare $share) { + protected function setLinkParent(IShare $share) { // No sense in checking if the method is not there. if (method_exists($share, 'setParent')) { @@ -670,10 +670,10 @@ class Manager implements IManager { /** * Check if the user that is sharing can actually share * - * @param \OCP\Share\IShare $share + * @param IShare $share * @throws \Exception */ - protected function canShare(\OCP\Share\IShare $share) { + protected function canShare(IShare $share) { if (!$this->shareApiEnabled()) { throw new \Exception('Sharing is disabled'); } @@ -686,13 +686,13 @@ class Manager implements IManager { /** * Share a path * - * @param \OCP\Share\IShare $share + * @param IShare $share * @return Share The share object * @throws \Exception * * TODO: handle link share permissions or check them */ - public function createShare(\OCP\Share\IShare $share) { + public function createShare(IShare $share) { $this->canShare($share); $this->generalCreateChecks($share); @@ -720,17 +720,17 @@ class Manager implements IManager { } //Verify share type - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { + if ($share->getShareType() === IShare::TYPE_USER) { $this->userCreateChecks($share); //Verify the expiration date $share = $this->validateExpirationDateInternal($share); - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($share->getShareType() === IShare::TYPE_GROUP) { $this->groupCreateChecks($share); //Verify the expiration date $share = $this->validateExpirationDateInternal($share); - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { + } elseif ($share->getShareType() === IShare::TYPE_LINK) { $this->linkCreateChecks($share); $this->setLinkParent($share); @@ -754,7 +754,7 @@ class Manager implements IManager { if ($share->getPassword() !== null) { $share->setPassword($this->hasher->hash($share->getPassword())); } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { + } elseif ($share->getShareType() === IShare::TYPE_EMAIL) { $share->setToken( $this->secureRandom->generate( \OC\Share\Constants::TOKEN_LENGTH, @@ -764,7 +764,7 @@ class Manager implements IManager { } // Cannot share with the owner - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && + if ($share->getShareType() === IShare::TYPE_USER && $share->getSharedWith() === $share->getShareOwner()) { throw new \InvalidArgumentException('Can’t share with the share owner'); } @@ -798,7 +798,7 @@ class Manager implements IManager { $this->dispatcher->dispatchTyped(new Share\Events\ShareCreatedEvent($share)); - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { + if ($share->getShareType() === IShare::TYPE_USER) { $mailSend = $share->getMailSend(); if ($mailSend === true) { $user = $this->userManager->get($share->getSharedWith()); @@ -913,11 +913,11 @@ class Manager implements IManager { /** * Update a share * - * @param \OCP\Share\IShare $share - * @return \OCP\Share\IShare The share object + * @param IShare $share + * @return IShare The share object * @throws \InvalidArgumentException */ - public function updateShare(\OCP\Share\IShare $share) { + public function updateShare(IShare $share) { $expirationDateUpdated = false; $this->canShare($share); @@ -935,19 +935,19 @@ class Manager implements IManager { // We can only change the recipient on user shares if ($share->getSharedWith() !== $originalShare->getSharedWith() && - $share->getShareType() !== \OCP\Share::SHARE_TYPE_USER) { + $share->getShareType() !== IShare::TYPE_USER) { throw new \InvalidArgumentException('Can only update recipient on user shares'); } // Cannot share with the owner - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && + if ($share->getShareType() === IShare::TYPE_USER && $share->getSharedWith() === $share->getShareOwner()) { throw new \InvalidArgumentException('Can’t share with the share owner'); } $this->generalCreateChecks($share); - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { + if ($share->getShareType() === IShare::TYPE_USER) { $this->userCreateChecks($share); if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { @@ -955,7 +955,7 @@ class Manager implements IManager { $this->validateExpirationDate($share); $expirationDateUpdated = true; } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($share->getShareType() === IShare::TYPE_GROUP) { $this->groupCreateChecks($share); if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { @@ -963,7 +963,7 @@ class Manager implements IManager { $this->validateExpirationDate($share); $expirationDateUpdated = true; } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { + } elseif ($share->getShareType() === IShare::TYPE_LINK) { $this->linkCreateChecks($share); $plainTextPassword = $share->getPassword(); @@ -979,7 +979,7 @@ class Manager implements IManager { $this->validateExpirationDate($share); $expirationDateUpdated = true; } - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { + } elseif ($share->getShareType() === IShare::TYPE_EMAIL) { // The new password is not set again if it is the same as the old // one. $plainTextPassword = $share->getPassword(); @@ -1000,7 +1000,7 @@ class Manager implements IManager { // Now update the share! $provider = $this->factory->getProviderForType($share->getShareType()); - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { + if ($share->getShareType() === IShare::TYPE_EMAIL) { $share = $provider->update($share, $plainTextPassword); } else { $share = $provider->update($share); @@ -1073,12 +1073,12 @@ class Manager implements IManager { * Updates the password of the given share if it is not the same as the * password of the original share. * - * @param \OCP\Share\IShare $share the share to update its password. - * @param \OCP\Share\IShare $originalShare the original share to compare its + * @param IShare $share the share to update its password. + * @param IShare $originalShare the original share to compare its * password with. * @return boolean whether the password was updated or not. */ - private function updateSharePasswordIfNeeded(\OCP\Share\IShare $share, \OCP\Share\IShare $originalShare) { + private function updateSharePasswordIfNeeded(IShare $share, IShare $originalShare) { $passwordsAreDifferent = ($share->getPassword() !== $originalShare->getPassword()) && (($share->getPassword() !== null && $originalShare->getPassword() === null) || ($share->getPassword() === null && $originalShare->getPassword() !== null) || @@ -1109,10 +1109,10 @@ class Manager implements IManager { * Delete all the children of this share * FIXME: remove once https://github.com/owncloud/core/pull/21660 is in * - * @param \OCP\Share\IShare $share - * @return \OCP\Share\IShare[] List of deleted shares + * @param IShare $share + * @return IShare[] List of deleted shares */ - protected function deleteChildren(\OCP\Share\IShare $share) { + protected function deleteChildren(IShare $share) { $deletedShares = []; $provider = $this->factory->getProviderForType($share->getShareType()); @@ -1131,11 +1131,11 @@ class Manager implements IManager { /** * Delete a share * - * @param \OCP\Share\IShare $share + * @param IShare $share * @throws ShareNotFound * @throws \InvalidArgumentException */ - public function deleteShare(\OCP\Share\IShare $share) { + public function deleteShare(IShare $share) { try { $share->getFullId(); } catch (\UnexpectedValueException $e) { @@ -1167,10 +1167,10 @@ class Manager implements IManager { * the users in a groups deletes that share. But the provider should * handle this. * - * @param \OCP\Share\IShare $share + * @param IShare $share * @param string $recipientId */ - public function deleteFromSelf(\OCP\Share\IShare $share, $recipientId) { + public function deleteFromSelf(IShare $share, $recipientId) { list($providerId, ) = $this->splitFullId($share->getFullId()); $provider = $this->factory->getProvider($providerId); @@ -1189,16 +1189,16 @@ class Manager implements IManager { /** * @inheritdoc */ - public function moveShare(\OCP\Share\IShare $share, $recipientId) { - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { + public function moveShare(IShare $share, $recipientId) { + if ($share->getShareType() === IShare::TYPE_LINK) { throw new \InvalidArgumentException('Can’t change target of link share'); } - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() !== $recipientId) { + if ($share->getShareType() === IShare::TYPE_USER && $share->getSharedWith() !== $recipientId) { throw new \InvalidArgumentException('Invalid recipient'); } - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + if ($share->getShareType() === IShare::TYPE_GROUP) { $sharedWith = $this->groupManager->get($share->getSharedWith()); if (is_null($sharedWith)) { throw new \InvalidArgumentException('Group "' . $share->getSharedWith() . '" does not exist'); @@ -1399,7 +1399,7 @@ class Manager implements IManager { $share = null; try { if ($this->shareApiAllowLinks()) { - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK); + $provider = $this->factory->getProviderForType(IShare::TYPE_LINK); $share = $provider->getShareByToken($token); } } catch (ProviderException $e) { @@ -1410,7 +1410,7 @@ class Manager implements IManager { // If it is not a link share try to fetch a federated share by token if ($share === null) { try { - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_REMOTE); + $provider = $this->factory->getProviderForType(IShare::TYPE_REMOTE); $share = $provider->getShareByToken($token); } catch (ProviderException $e) { } catch (ShareNotFound $e) { @@ -1418,27 +1418,27 @@ class Manager implements IManager { } // If it is not a link share try to fetch a mail share by token - if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) { + if ($share === null && $this->shareProviderExists(IShare::TYPE_EMAIL)) { try { - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_EMAIL); + $provider = $this->factory->getProviderForType(IShare::TYPE_EMAIL); $share = $provider->getShareByToken($token); } catch (ProviderException $e) { } catch (ShareNotFound $e) { } } - if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) { + if ($share === null && $this->shareProviderExists(IShare::TYPE_CIRCLE)) { try { - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_CIRCLE); + $provider = $this->factory->getProviderForType(IShare::TYPE_CIRCLE); $share = $provider->getShareByToken($token); } catch (ProviderException $e) { } catch (ShareNotFound $e) { } } - if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_ROOM)) { + if ($share === null && $this->shareProviderExists(IShare::TYPE_ROOM)) { try { - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_ROOM); + $provider = $this->factory->getProviderForType(IShare::TYPE_ROOM); $share = $provider->getShareByToken($token); } catch (ProviderException $e) { } catch (ShareNotFound $e) { @@ -1454,7 +1454,7 @@ class Manager implements IManager { /* * Reduce the permissions for link shares if public upload is not enabled */ - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + if ($share->getShareType() === IShare::TYPE_LINK && !$this->shareApiLinkAllowPublicUpload()) { $share->setPermissions($share->getPermissions() & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE)); } @@ -1472,11 +1472,11 @@ class Manager implements IManager { /** * Verify the password of a public share * - * @param \OCP\Share\IShare $share + * @param IShare $share * @param string $password * @return bool */ - public function checkPassword(\OCP\Share\IShare $share, $password) { + public function checkPassword(IShare $share, $password) { $passwordProtected = $share->getShareType() !== IShare::TYPE_LINK || $share->getShareType() !== IShare::TYPE_EMAIL || $share->getShareType() !== IShare::TYPE_CIRCLE; @@ -1507,7 +1507,7 @@ class Manager implements IManager { * @inheritdoc */ public function userDeleted($uid) { - $types = [\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK, \OCP\Share::SHARE_TYPE_REMOTE, \OCP\Share::SHARE_TYPE_EMAIL]; + $types = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK, IShare::TYPE_REMOTE, IShare::TYPE_EMAIL]; foreach ($types as $type) { try { @@ -1523,7 +1523,7 @@ class Manager implements IManager { * @inheritdoc */ public function groupDeleted($gid) { - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP); + $provider = $this->factory->getProviderForType(IShare::TYPE_GROUP); $provider->groupDeleted($gid); $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); @@ -1544,7 +1544,7 @@ class Manager implements IManager { * @inheritdoc */ public function userDeletedFromGroup($uid, $gid) { - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP); + $provider = $this->factory->getProviderForType(IShare::TYPE_GROUP); $provider->userDeletedFromGroup($uid, $gid); } @@ -1679,7 +1679,8 @@ class Manager implements IManager { /** * Create a new share - * @return \OCP\Share\IShare + * + * @return IShare */ public function newShare() { return new \OC\Share20\Share($this->rootFolder, $this->userManager); diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 73a14dd4ac1..128033f6498 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -41,6 +41,7 @@ use OCA\ShareByMail\ShareByMailProvider; use OCP\Defaults; use OCP\IServerContainer; use OCP\Share\IProviderFactory; +use OCP\Share\IShare; /** * Class ProviderFactory @@ -278,18 +279,18 @@ class ProviderFactory implements IProviderFactory { public function getProviderForType($shareType) { $provider = null; - if ($shareType === \OCP\Share::SHARE_TYPE_USER || - $shareType === \OCP\Share::SHARE_TYPE_GROUP || - $shareType === \OCP\Share::SHARE_TYPE_LINK + if ($shareType === IShare::TYPE_USER || + $shareType === IShare::TYPE_GROUP || + $shareType === IShare::TYPE_LINK ) { $provider = $this->defaultShareProvider(); - } elseif ($shareType === \OCP\Share::SHARE_TYPE_REMOTE || $shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { + } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) { $provider = $this->federatedShareProvider(); - } elseif ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { + } elseif ($shareType === IShare::TYPE_EMAIL) { $provider = $this->getShareByMailProvider(); - } elseif ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) { + } elseif ($shareType === IShare::TYPE_CIRCLE) { $provider = $this->getShareByCircleProvider(); - } elseif ($shareType === \OCP\Share::SHARE_TYPE_ROOM) { + } elseif ($shareType === IShare::TYPE_ROOM) { $provider = $this->getRoomShareProvider(); } diff --git a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php index 909a11596a3..3f9e0900d15 100644 --- a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php @@ -31,7 +31,7 @@ use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserSession; -use OCP\Share; +use OCP\Share\IShare; use Test\TestCase; class GroupPluginTest extends TestCase { @@ -135,7 +135,7 @@ class GroupPluginTest extends TestCase { [$this->getGroupMock('test1')], [], [], - [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]], true, false, ], @@ -145,7 +145,7 @@ class GroupPluginTest extends TestCase { [$this->getGroupMock('test1', 'Test One')], [], [], - [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + [['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]], true, false, ], @@ -155,7 +155,7 @@ class GroupPluginTest extends TestCase { [$this->getGroupMock('test1', 'Test One')], [], [], - [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + [['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]], true, false, ], @@ -164,7 +164,7 @@ class GroupPluginTest extends TestCase { 'Test One', false, true, [$this->getGroupMock('test1', 'Test One')], [], - [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + [['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]], [], true, false, @@ -185,8 +185,8 @@ class GroupPluginTest extends TestCase { $this->getGroupMock('test1'), ], [], - [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]], - [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]], + [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]], false, false, ], @@ -197,7 +197,7 @@ class GroupPluginTest extends TestCase { $this->getGroupMock('test1'), ], [], - [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]], + [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]], [], true, false, @@ -211,8 +211,8 @@ class GroupPluginTest extends TestCase { [], [], [ - ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']], - ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']], + ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']], + ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']], ], false, null, @@ -237,11 +237,11 @@ class GroupPluginTest extends TestCase { ], [], [ - ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']], + ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']], ], [ - ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']], - ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']], + ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']], + ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']], ], false, $this->getGroupMock('test'), @@ -254,7 +254,7 @@ class GroupPluginTest extends TestCase { ], [], [ - ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']], + ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']], ], [], true, @@ -270,7 +270,7 @@ class GroupPluginTest extends TestCase { ], [$this->getGroupMock('test1')], [], - [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]], false, false, ], @@ -293,7 +293,7 @@ class GroupPluginTest extends TestCase { $this->getGroupMock('test1'), ], [$this->getGroupMock('test')], - [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]], + [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]], [], false, false, @@ -305,7 +305,7 @@ class GroupPluginTest extends TestCase { $this->getGroupMock('test1'), ], [$this->getGroupMock('test')], - [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]], + [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]], [], true, false, @@ -318,7 +318,7 @@ class GroupPluginTest extends TestCase { ], [$this->getGroupMock('test1')], [], - [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]], false, false, ], @@ -341,8 +341,8 @@ class GroupPluginTest extends TestCase { $this->getGroupMock('test1'), ], [$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')], - [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]], - [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]], + [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]], false, false, ], @@ -353,7 +353,7 @@ class GroupPluginTest extends TestCase { $this->getGroupMock('test1'), ], [$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')], - [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]], + [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]], [], true, false, @@ -367,8 +367,8 @@ class GroupPluginTest extends TestCase { [$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')], [], [ - ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']], - ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']], + ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']], + ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']], ], false, null, @@ -393,11 +393,11 @@ class GroupPluginTest extends TestCase { ], [$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')], [ - ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']], + ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']], ], [ - ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']], - ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']], + ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']], + ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']], ], false, $this->getGroupMock('test'), @@ -410,7 +410,7 @@ class GroupPluginTest extends TestCase { ], [$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')], [ - ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']], + ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']], ], [], true, diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php index eb26443a269..383dd0c39a2 100644 --- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php @@ -36,7 +36,7 @@ use OCP\IConfig; use OCP\ILogger; use OCP\IUser; use OCP\IUserSession; -use OCP\Share; +use OCP\Share\IShare; use Test\TestCase; class LookupPluginTest extends TestCase { @@ -301,7 +301,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[0], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[0] ], 'extra' => ['federationId' => $fedIDs[0]], @@ -309,7 +309,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[1], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[1] ], 'extra' => ['federationId' => $fedIDs[1]], @@ -317,7 +317,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[2], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[2] ], 'extra' => ['federationId' => $fedIDs[2]], @@ -340,7 +340,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[0], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[0] ], 'extra' => ['federationId' => $fedIDs[0]], @@ -348,7 +348,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[1], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[1] ], 'extra' => ['federationId' => $fedIDs[1]], @@ -356,7 +356,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[2], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[2] ], 'extra' => ['federationId' => $fedIDs[2]], @@ -379,7 +379,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[0], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[0] ], 'extra' => ['federationId' => $fedIDs[0]], @@ -387,7 +387,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[1], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[1] ], 'extra' => ['federationId' => $fedIDs[1]], @@ -395,7 +395,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[2], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[2] ], 'extra' => ['federationId' => $fedIDs[2]], @@ -418,7 +418,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[0], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[0] ], 'extra' => ['federationId' => $fedIDs[0]], @@ -426,7 +426,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[1], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[1] ], 'extra' => ['federationId' => $fedIDs[1]], @@ -434,7 +434,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[2], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[2] ], 'extra' => ['federationId' => $fedIDs[2]], @@ -469,7 +469,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[0], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[0] ], 'extra' => ['federationId' => $fedIDs[0]], @@ -477,7 +477,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[1], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[1] ], 'extra' => ['federationId' => $fedIDs[1]], @@ -485,7 +485,7 @@ class LookupPluginTest extends TestCase { [ 'label' => $fedIDs[2], 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareType' => IShare::TYPE_REMOTE, 'shareWith' => $fedIDs[2] ], 'extra' => ['federationId' => $fedIDs[2]], diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index 613208d27b1..6e859b55358 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php @@ -33,7 +33,7 @@ use OCP\IConfig; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserSession; -use OCP\Share; +use OCP\Share\IShare; use Test\TestCase; class MailPluginTest extends TestCase { @@ -126,7 +126,7 @@ class MailPluginTest extends TestCase { 'test@remote.com', [], true, - ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]], + ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]], false, false, ], @@ -144,7 +144,7 @@ class MailPluginTest extends TestCase { 'test@remote.com', [], false, - ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]], + ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]], false, false, ], @@ -171,7 +171,7 @@ class MailPluginTest extends TestCase { ], ], true, - ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => []]], + ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => []]], false, false, ], @@ -225,7 +225,7 @@ class MailPluginTest extends TestCase { ], ], true, - ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]], + ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]], false, false, ], @@ -252,7 +252,7 @@ class MailPluginTest extends TestCase { ], ], false, - ['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]], + ['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]], false, false, ], @@ -279,7 +279,7 @@ class MailPluginTest extends TestCase { ], ], true, - ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]], + ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]], true, false, ], @@ -306,7 +306,7 @@ class MailPluginTest extends TestCase { ], ], false, - ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]], + ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]], true, false, ], @@ -334,7 +334,7 @@ class MailPluginTest extends TestCase { ], ], false, - ['emails' => [], 'exact' => ['emails' => [['name' => 'User Name @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'user name@localhost']]]]], + ['emails' => [], 'exact' => ['emails' => [['name' => 'User Name @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'user name@localhost']]]]], true, false, ], @@ -380,7 +380,7 @@ class MailPluginTest extends TestCase { ] ], false, - ['users' => [], 'exact' => ['users' => [['uuid' => 'uid1', 'name' => 'User', 'label' => 'User (test@example.com)','value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test'],]]]], + ['users' => [], 'exact' => ['users' => [['uuid' => 'uid1', 'name' => 'User', 'label' => 'User (test@example.com)','value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test'],]]]], true, false, ], @@ -438,8 +438,8 @@ class MailPluginTest extends TestCase { ], true, ['users' => [ - ['uuid' => 'uid1', 'name' => 'User1', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], - ['uuid' => 'uid2', 'name' => 'User2', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']], + ['uuid' => 'uid1', 'name' => 'User1', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], + ['uuid' => 'uid2', 'name' => 'User2', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']], ], 'emails' => [], 'exact' => ['users' => [], 'emails' => []]], false, true, @@ -476,8 +476,8 @@ class MailPluginTest extends TestCase { ], true, ['emails' => [ - ['uuid' => 'uid1', 'name' => 'User1', 'type' => '', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.com']], - ['uuid' => 'uid2', 'name' => 'User2', 'type' => '', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.de']], + ['uuid' => 'uid1', 'name' => 'User1', 'type' => '', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@example.com']], + ['uuid' => 'uid2', 'name' => 'User2', 'type' => '', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@example.de']], ], 'exact' => ['emails' => []]], false, true, @@ -509,8 +509,8 @@ class MailPluginTest extends TestCase { false, ['emails' => [ ], 'exact' => ['emails' => [ - ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'HOME', 'label' => 'User Name (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']], - ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'WORK', 'label' => 'User Name (username@other)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@other']] + ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'HOME', 'label' => 'User Name (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']], + ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'WORK', 'label' => 'User Name (username@other)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@other']] ]]], false, false, diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php index a651d4ec1d4..531a8447bd2 100644 --- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php +++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php @@ -33,7 +33,7 @@ use OCP\IConfig; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; -use OCP\Share; +use OCP\Share\IShare; use Test\TestCase; class RemotePluginTest extends TestCase { @@ -150,7 +150,7 @@ class RemotePluginTest extends TestCase { 'test@remote', [], true, - ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], + ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], false, true, ], @@ -158,7 +158,7 @@ class RemotePluginTest extends TestCase { 'test@remote', [], false, - ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], + ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], false, true, ], @@ -184,7 +184,7 @@ class RemotePluginTest extends TestCase { ], ], true, - ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => []]], + ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => []]], false, true, ], @@ -236,7 +236,7 @@ class RemotePluginTest extends TestCase { ], ], true, - ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], + ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], false, true, ], @@ -262,7 +262,7 @@ class RemotePluginTest extends TestCase { ], ], false, - ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], + ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], false, true, ], @@ -288,7 +288,7 @@ class RemotePluginTest extends TestCase { ], ], true, - ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]], + ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]], true, true, ], @@ -314,7 +314,7 @@ class RemotePluginTest extends TestCase { ], ], false, - ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]], + ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]], true, true, ], @@ -341,7 +341,7 @@ class RemotePluginTest extends TestCase { ], ], false, - ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User Name @ Localhost', 'label' => 'User Name @ Localhost (user name@localhost)', 'uuid' => 'uid3', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user name@localhost', 'server' => 'localhost']]]]], + ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User Name @ Localhost', 'label' => 'User Name @ Localhost (user name@localhost)', 'uuid' => 'uid3', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'user name@localhost', 'server' => 'localhost']]]]], true, true, ], @@ -368,7 +368,7 @@ class RemotePluginTest extends TestCase { ], ], false, - ['remotes' => [], 'exact' => ['remotes' => [['label' => 'user space (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user space@remote', 'server' => 'remote'], 'uuid' => 'user space', 'name' => 'user space']]]], + ['remotes' => [], 'exact' => ['remotes' => [['label' => 'user space (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'user space@remote', 'server' => 'remote'], 'uuid' => 'user space', 'name' => 'user space']]]], false, true, ], diff --git a/tests/lib/Collaboration/Collaborators/SearchTest.php b/tests/lib/Collaboration/Collaborators/SearchTest.php index 1b68e8eacc1..ab731c05c21 100644 --- a/tests/lib/Collaboration/Collaborators/SearchTest.php +++ b/tests/lib/Collaboration/Collaborators/SearchTest.php @@ -29,7 +29,7 @@ use OCP\Collaboration\Collaborators\ISearch; use OCP\Collaboration\Collaborators\ISearchPlugin; use OCP\Collaboration\Collaborators\SearchResultType; use OCP\IContainer; -use OCP\Share; +use OCP\Share\IShare; use Test\TestCase; class SearchTest extends TestCase { @@ -132,7 +132,7 @@ class SearchTest extends TestCase { public function dataSearchSharees() { return [ [ - 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false], + 'test', [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false], [ 'exact' => ['users' => [], 'groups' => [], 'remotes' => []], 'users' => [], @@ -141,7 +141,7 @@ class SearchTest extends TestCase { ], false ], [ - 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false], + 'test', [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false], [ 'exact' => ['users' => [], 'groups' => [], 'remotes' => []], 'users' => [], @@ -150,66 +150,66 @@ class SearchTest extends TestCase { ], false ], [ - 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, [ - ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + 'test', [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE], 1, 2, [ + ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], ], [ - ['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']], + ['label' => 'testgroup1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'testgroup1']], ], [ - 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false, + 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false, ], [ 'exact' => ['users' => [], 'groups' => [], 'remotes' => []], 'users' => [ - ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], ], 'groups' => [ - ['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']], + ['label' => 'testgroup1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'testgroup1']], ], 'remotes' => [ - ['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']], + ['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']], ], ], true, ], // No groups requested [ - 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_REMOTE], 1, 2, [ - ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + 'test', [IShare::TYPE_USER, IShare::TYPE_REMOTE], 1, 2, [ + ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], ], [], [ - 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false + 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false ], [ 'exact' => ['users' => [], 'remotes' => []], 'users' => [ - ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], ], 'remotes' => [ - ['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']], + ['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']], ], ], false, ], // Share type restricted to user - Only one user [ - 'test', [Share::SHARE_TYPE_USER], 1, 2, [ - ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + 'test', [IShare::TYPE_USER], 1, 2, [ + ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], ], [], [], [ 'exact' => ['users' => []], 'users' => [ - ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], ], ], false, ], // Share type restricted to user - Multipage result [ - 'test', [Share::SHARE_TYPE_USER], 1, 2, [ - ['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], - ['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']], + 'test', [IShare::TYPE_USER], 1, 2, [ + ['label' => 'test 1', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'test 2', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']], ], [], [], [ 'exact' => ['users' => []], 'users' => [ - ['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], - ['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']], + ['label' => 'test 1', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'test 2', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']], ], ], true, ], diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php index 40813c82850..8ca612f6069 100644 --- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php @@ -32,7 +32,7 @@ use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; -use OCP\Share; +use OCP\Share\IShare; use Test\TestCase; class UserPluginTest extends TestCase { @@ -144,13 +144,13 @@ class UserPluginTest extends TestCase { [ 'test', false, true, [], [], [ - ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']], + ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']], ], [], true, $this->getUserMock('test', 'Test'), ], [ 'test', false, false, [], [], [ - ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']], + ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']], ], [], true, $this->getUserMock('test', 'Test'), ], [ @@ -164,13 +164,13 @@ class UserPluginTest extends TestCase { [ 'test', true, true, ['test-group'], [['test-group', 'test', 2, 0, []]], [ - ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']], + ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']], ], [], true, $this->getUserMock('test', 'Test'), ], [ 'test', true, false, ['test-group'], [['test-group', 'test', 2, 0, []]], [ - ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']], + ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']], ], [], true, $this->getUserMock('test', 'Test'), ], [ @@ -183,7 +183,7 @@ class UserPluginTest extends TestCase { ], [], [ - ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], ], true, false, @@ -212,8 +212,8 @@ class UserPluginTest extends TestCase { ], [], [ - ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], - ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']], + ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']], ], false, false, @@ -243,11 +243,11 @@ class UserPluginTest extends TestCase { $this->getUserMock('test2', 'Test Two'), ], [ - ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test0']], + ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test0']], ], [ - ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], - ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']], + ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']], ], false, false, @@ -263,7 +263,7 @@ class UserPluginTest extends TestCase { $this->getUserMock('test2', 'Test Two'), ], [ - ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test0']], + ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test0']], ], [], true, @@ -280,7 +280,7 @@ class UserPluginTest extends TestCase { ], [], [ - ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], ], true, false, @@ -318,8 +318,8 @@ class UserPluginTest extends TestCase { ], [], [ - ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], - ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']], + ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']], ], false, false, @@ -366,10 +366,10 @@ class UserPluginTest extends TestCase { ]], ], [ - ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']], + ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']], ], [ - ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']], + ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']], ], false, false, @@ -392,7 +392,7 @@ class UserPluginTest extends TestCase { ]], ], [ - ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']], + ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']], ], [], true, diff --git a/tests/lib/DB/schemDiffData/core.xml b/tests/lib/DB/schemDiffData/core.xml index 3775eb6cb37..d7edc7dc73e 100644 --- a/tests/lib/DB/schemDiffData/core.xml +++ b/tests/lib/DB/schemDiffData/core.xml @@ -526,7 +526,7 @@ <length>4</length> </field> - <!-- Constant OCP\Share::SHARE_TYPE_* --> + <!-- Constant OCP\Share\IShare::TYPE_* --> <field> <name>share_type</name> <type>integer</type> diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 9dbe2a4e10e..036fc038a60 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -21,7 +21,7 @@ use OCP\Files\FileInfo; use OCP\Files\Storage\IStorage; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; -use OCP\Share; +use OCP\Share\IShare; use OCP\Util; use Test\HookHelper; use Test\TestMoveableMountPoint; @@ -243,7 +243,7 @@ class ViewTest extends \Test\TestCase { $this->assertEquals('/foo.txt', $folderView->getPath($id2)); } - + public function testGetPathNotExisting() { $this->expectException(\OCP\Files\NotFoundException::class); @@ -1290,7 +1290,7 @@ class ViewTest extends \Test\TestCase { $this->assertNull($view->getRelativePath(null)); } - + public function testNullAsRoot() { $this->expectException(\InvalidArgumentException::class); @@ -1678,7 +1678,7 @@ class ViewTest extends \Test\TestCase { $share = $shareManager->newShare(); $share->setSharedWith('test2') ->setSharedBy($this->user) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setNode($shareDir); $shareManager->createShare($share); @@ -1687,7 +1687,7 @@ class ViewTest extends \Test\TestCase { $this->assertFalse($view->rename('mount1', 'shareddir/sub'), 'Cannot move mount point into shared folder'); $this->assertFalse($view->rename('mount1', 'shareddir/sub/sub2'), 'Cannot move mount point into shared subfolder'); - $this->assertTrue(\OC\Share\Share::unshare('folder', $fileId, Share::SHARE_TYPE_USER, 'test2')); + $this->assertTrue(\OC\Share\Share::unshare('folder', $fileId, IShare::TYPE_USER, 'test2')); $userObject->delete(); } diff --git a/tests/lib/Repair/OldGroupMembershipSharesTest.php b/tests/lib/Repair/OldGroupMembershipSharesTest.php index 331a86d01d0..dda23e8d3ab 100644 --- a/tests/lib/Repair/OldGroupMembershipSharesTest.php +++ b/tests/lib/Repair/OldGroupMembershipSharesTest.php @@ -9,8 +9,8 @@ namespace Test\Repair; use OC\Repair\OldGroupMembershipShares; -use OC\Share\Constants; use OCP\Migration\IOutput; +use OCP\Share\IShare; /** * Class OldGroupMembershipSharesTest @@ -66,9 +66,9 @@ class OldGroupMembershipSharesTest extends \Test\TestCase { ['not-a-member', 'group', false], ]); - $parent = $this->createShare(Constants::SHARE_TYPE_GROUP, 'group', null); - $group2 = $this->createShare(Constants::SHARE_TYPE_GROUP, 'group2', $parent); - $user1 = $this->createShare(Constants::SHARE_TYPE_USER, 'user1', $parent); + $parent = $this->createShare(IShare::TYPE_GROUP, 'group', null); + $group2 = $this->createShare(IShare::TYPE_GROUP, 'group2', $parent); + $user1 = $this->createShare(IShare::TYPE_USER, 'user1', $parent); // \OC\Share\Constant::$shareTypeGroupUserUnique === 2 $member = $this->createShare(2, 'member', $parent); diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php index 23e6b2dad5f..748ca7a6048 100644 --- a/tests/lib/Repair/RepairInvalidSharesTest.php +++ b/tests/lib/Repair/RepairInvalidSharesTest.php @@ -9,10 +9,10 @@ namespace Test\Repair; use OC\Repair\RepairInvalidShares; -use OC\Share\Constants; use OCP\IConfig; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use OCP\Share\IShare; use Test\TestCase; /** @@ -65,7 +65,7 @@ class RepairInvalidSharesTest extends TestCase { public function testSharesNonExistingParent() { $qb = $this->connection->getQueryBuilder(); $shareValues = [ - 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('recipientuser1'), 'uid_owner' => $qb->expr()->literal('user1'), 'item_type' => $qb->expr()->literal('folder'), @@ -159,7 +159,7 @@ class RepairInvalidSharesTest extends TestCase { $qb = $this->connection->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_LINK), + 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK), 'uid_owner' => $qb->expr()->literal('user1'), 'item_type' => $qb->expr()->literal($itemType), 'item_source' => $qb->expr()->literal(123), diff --git a/tests/lib/Share/ShareTest.php b/tests/lib/Share/ShareTest.php index fce963ec43a..85cb188cbb3 100644 --- a/tests/lib/Share/ShareTest.php +++ b/tests/lib/Share/ShareTest.php @@ -21,11 +21,11 @@ namespace Test\Share; -use OC\Share\Share; use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; +use OCP\Share\IShare; /** * Class Test_Share @@ -140,15 +140,15 @@ class ShareTest extends \Test\TestCase { $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (' .' `item_type`, `item_source`, `item_target`, `share_type`,' .' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)'); - $args = ['test', 99, 'target1', \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), $this->user1->getUID()]; + $args = ['test', 99, 'target1', IShare::TYPE_USER, $this->user2->getUID(), $this->user1->getUID()]; $query->execute($args); - $args = ['test', 99, 'target2', \OCP\Share::SHARE_TYPE_USER, $this->user4->getUID(), $this->user1->getUID()]; + $args = ['test', 99, 'target2', IShare::TYPE_USER, $this->user4->getUID(), $this->user1->getUID()]; $query->execute($args); - $args = ['test', 99, 'target3', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user2->getUID()]; + $args = ['test', 99, 'target3', IShare::TYPE_USER, $this->user3->getUID(), $this->user2->getUID()]; $query->execute($args); - $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user4->getUID()]; + $args = ['test', 99, 'target4', IShare::TYPE_USER, $this->user3->getUID(), $this->user4->getUID()]; $query->execute($args); - $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user6->getUID(), $this->user4->getUID()]; + $args = ['test', 99, 'target4', IShare::TYPE_USER, $this->user6->getUID(), $this->user4->getUID()]; $query->execute($args); @@ -180,13 +180,13 @@ class ShareTest extends \Test\TestCase { $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (' .' `item_type`, `item_source`, `item_target`, `share_type`,' .' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)'); - $args = ['test', 99, 'target1', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user1->getUID()]; + $args = ['test', 99, 'target1', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user1->getUID()]; $query->execute($args); - $args = ['test', 99, 'target2', \OCP\Share::SHARE_TYPE_GROUP, $this->group2->getGID(), $this->user1->getUID()]; + $args = ['test', 99, 'target2', IShare::TYPE_GROUP, $this->group2->getGID(), $this->user1->getUID()]; $query->execute($args); - $args = ['test', 99, 'target3', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user2->getUID()]; + $args = ['test', 99, 'target3', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user2->getUID()]; $query->execute($args); - $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user4->getUID()]; + $args = ['test', 99, 'target4', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user4->getUID()]; $query->execute($args); // user2 is in group1 and group2 diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index cb332ac186a..b3de9d05a52 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -189,7 +189,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -220,7 +220,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); $this->assertEquals($id, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $share->getShareType()); $this->assertEquals('sharedWith', $share->getSharedWith()); $this->assertEquals('sharedBy', $share->getSharedBy()); $this->assertEquals('shareOwner', $share->getShareOwner()); @@ -236,7 +236,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -256,7 +256,7 @@ class DefaultShareProviderTest extends \Test\TestCase { // We do not fetch the node so the rootfolder is never called. $this->assertEquals($id, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $share->getShareType()); $this->assertEquals('sharedWith', $share->getSharedWith()); $this->assertEquals('sharedBy', $share->getSharedBy()); $this->assertEquals('shareOwner', $share->getShareOwner()); @@ -271,7 +271,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -299,7 +299,7 @@ class DefaultShareProviderTest extends \Test\TestCase { // We fetch the node so the root folder is eventually called $this->assertEquals($id, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $share->getShareType()); $this->assertEquals('sharedWith', $share->getSharedWith()); $this->assertEquals('sharedBy', $share->getSharedBy()); $this->assertEquals('shareOwner', $share->getShareOwner()); @@ -315,7 +315,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -342,7 +342,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); $this->assertEquals($id, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); + $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType()); $this->assertEquals('sharedWith', $share->getSharedWith()); $this->assertEquals('sharedBy', $share->getSharedBy()); $this->assertEquals('shareOwner', $share->getShareOwner()); @@ -354,7 +354,7 @@ class DefaultShareProviderTest extends \Test\TestCase { } public function testGetShareByIdUserGroupShare() { - $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user0', 'user0', 'file', 42, 'myTarget', 31, null, null); + $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user0', 'user0', 'file', 42, 'myTarget', 31, null, null); $this->addShareToDB(2, 'user1', 'user0', 'user0', 'file', 42, 'userTarget', 0, null, null, $id); $user0 = $this->createMock(IUser::class); @@ -380,7 +380,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id, 'user1'); $this->assertEquals($id, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); + $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType()); $this->assertSame('group0', $share->getSharedWith()); $this->assertSame('user0', $share->getSharedBy()); $this->assertSame('user0', $share->getShareOwner()); @@ -396,7 +396,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK), + 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK), 'password' => $qb->expr()->literal('password'), 'password_by_talk' => $qb->expr()->literal(true), 'uid_owner' => $qb->expr()->literal('shareOwner'), @@ -425,7 +425,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); $this->assertEquals($id, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType()); + $this->assertEquals(IShare::TYPE_LINK, $share->getShareType()); $this->assertNull($share->getSharedWith()); $this->assertEquals('password', $share->getPassword()); $this->assertEquals(true, $share->getSendPasswordByTalk()); @@ -442,7 +442,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('sharedBy'), 'item_type' => $qb->expr()->literal('file'), @@ -490,7 +490,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -523,7 +523,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('sharedBy'), 'item_type' => $qb->expr()->literal('file'), @@ -550,7 +550,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->createMock(IShare::class); $share->method('getId')->willReturn($id); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); + $share->method('getShareType')->willReturn(IShare::TYPE_GROUP); /** @var DefaultShareProvider $provider */ $provider = $this->getMockBuilder(DefaultShareProvider::class) @@ -585,7 +585,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -602,7 +602,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('user1'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('user2'), @@ -617,7 +617,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('group1'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('user3'), @@ -647,7 +647,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertCount(2, $children); //Child1 - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $children[0]->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $children[0]->getShareType()); $this->assertEquals('user1', $children[0]->getSharedWith()); $this->assertEquals('user2', $children[0]->getSharedBy()); $this->assertEquals('shareOwner', $children[0]->getShareOwner()); @@ -658,7 +658,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals('myTarget1', $children[0]->getTarget()); //Child2 - $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $children[1]->getShareType()); + $this->assertEquals(IShare::TYPE_GROUP, $children[1]->getShareType()); $this->assertEquals('group1', $children[1]->getSharedWith()); $this->assertEquals('user3', $children[1]->getSharedBy()); $this->assertEquals('shareOwner', $children[1]->getShareOwner()); @@ -695,7 +695,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->with(100) ->willReturn([$path]); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER); + $share->setShareType(IShare::TYPE_USER); $share->setSharedWith('sharedWith'); $share->setSharedBy('sharedBy'); $share->setShareOwner('shareOwner'); @@ -709,7 +709,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertNotNull($share2->getId()); $this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId()); - $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share2->getShareType()); + $this->assertSame(IShare::TYPE_USER, $share2->getShareType()); $this->assertSame('sharedWith', $share2->getSharedWith()); $this->assertSame('sharedBy', $share2->getSharedBy()); $this->assertSame('shareOwner', $share2->getShareOwner()); @@ -751,7 +751,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->with(100) ->willReturn([$path]); - $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP); + $share->setShareType(IShare::TYPE_GROUP); $share->setSharedWith('sharedWith'); $share->setSharedBy('sharedBy'); $share->setShareOwner('shareOwner'); @@ -765,7 +765,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertNotNull($share2->getId()); $this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId()); - $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share2->getShareType()); + $this->assertSame(IShare::TYPE_GROUP, $share2->getShareType()); $this->assertSame('sharedWith', $share2->getSharedWith()); $this->assertSame('sharedBy', $share2->getSharedBy()); $this->assertSame('shareOwner', $share2->getShareOwner()); @@ -807,7 +807,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->with(100) ->willReturn([$path]); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK); + $share->setShareType(IShare::TYPE_LINK); $share->setSharedBy('sharedBy'); $share->setShareOwner('shareOwner'); $share->setNode($path); @@ -823,7 +823,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertNotNull($share2->getId()); $this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId()); - $this->assertSame(\OCP\Share::SHARE_TYPE_LINK, $share2->getShareType()); + $this->assertSame(IShare::TYPE_LINK, $share2->getShareType()); $this->assertSame('sharedBy', $share2->getSharedBy()); $this->assertSame('shareOwner', $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); @@ -841,7 +841,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK), + 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK), 'password' => $qb->expr()->literal('password'), 'password_by_talk' => $qb->expr()->literal(true), 'uid_owner' => $qb->expr()->literal('shareOwner'), @@ -921,7 +921,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -936,7 +936,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith2'), 'uid_owner' => $qb->expr()->literal('shareOwner2'), 'uid_initiator' => $qb->expr()->literal('sharedBy2'), @@ -951,7 +951,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with($fileId)->willReturn([$file]); - $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_USER, null, 1 , 0); + $share = $this->provider->getSharedWith('sharedWith', IShare::TYPE_USER, null, 1 , 0); $this->assertCount(1, $share); $share = $share[0]; @@ -959,7 +959,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals('sharedWith', $share->getSharedWith()); $this->assertEquals('shareOwner', $share->getShareOwner()); $this->assertEquals('sharedBy', $share->getSharedBy()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $share->getShareType()); } /** @@ -972,7 +972,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner2'), 'uid_initiator' => $qb->expr()->literal('sharedBy2'), @@ -986,7 +986,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -1023,7 +1023,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with($fileId)->willReturn([$file]); - $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_GROUP, null, 20 , 1); + $share = $this->provider->getSharedWith('sharedWith', IShare::TYPE_GROUP, null, 20 , 1); $this->assertCount(1, $share); $share = $share[0]; @@ -1031,7 +1031,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals('sharedWith', $share->getSharedWith()); $this->assertEquals('shareOwner', $share->getShareOwner()); $this->assertEquals('sharedBy', $share->getSharedBy()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); + $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType()); } /** @@ -1043,7 +1043,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -1111,7 +1111,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with($fileId)->willReturn([$file]); - $share = $this->provider->getSharedWith('user', \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0); + $share = $this->provider->getSharedWith('user', IShare::TYPE_GROUP, null, -1, 0); $this->assertCount(1, $share); $share = $share[0]; @@ -1119,7 +1119,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertSame('sharedWith', $share->getSharedWith()); $this->assertSame('shareOwner', $share->getShareOwner()); $this->assertSame('sharedBy', $share->getSharedBy()); - $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); + $this->assertSame(IShare::TYPE_GROUP, $share->getShareType()); $this->assertSame(0, $share->getPermissions()); $this->assertSame('userTarget', $share->getTarget()); } @@ -1131,9 +1131,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $storageId = $this->createTestStorageEntry($storageStringId); $fileId = $this->createTestFileEntry($fileName1, $storageId); $fileId2 = $this->createTestFileEntry($fileName2, $storageId); - $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1', + $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user1', 'file', $fileId, 'myTarget', 31, null, null, null); - $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1', + $id = $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user1', 'file', $fileId2, 'myTarget', 31, null, null, null); $user0 = $this->createMock(IUser::class); @@ -1154,7 +1154,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with($fileId2)->willReturn([$file]); - $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_USER, $file, -1, 0); + $share = $this->provider->getSharedWith('user0', IShare::TYPE_USER, $file, -1, 0); $this->assertCount(1, $share); $share = $share[0]; @@ -1163,7 +1163,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertSame('user1', $share->getShareOwner()); $this->assertSame('user1', $share->getSharedBy()); $this->assertSame($file, $share->getNode()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $share->getShareType()); } /** @@ -1173,9 +1173,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $storageId = $this->createTestStorageEntry($storageStringId); $fileId = $this->createTestFileEntry($fileName1, $storageId); $fileId2 = $this->createTestFileEntry($fileName2, $storageId); - $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1', + $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user1', 'file', $fileId, 'myTarget', 31, null, null, null); - $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1', + $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user1', 'file', $fileId2, 'myTarget', 31, null, null, null); $user0 = $this->createMock(IUser::class); @@ -1195,7 +1195,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with($fileId2)->willReturn([$node]); - $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0); + $share = $this->provider->getSharedWith('user0', IShare::TYPE_GROUP, $node, -1, 0); $this->assertCount(1, $share); $share = $share[0]; @@ -1204,15 +1204,15 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertSame('user1', $share->getShareOwner()); $this->assertSame('user1', $share->getSharedBy()); $this->assertSame($node, $share->getNode()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); + $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType()); } public function shareTypesProvider() { return [ - [\OCP\Share::SHARE_TYPE_USER, false], - [\OCP\Share::SHARE_TYPE_GROUP, false], - [\OCP\Share::SHARE_TYPE_USER, true], - [\OCP\Share::SHARE_TYPE_GROUP, true], + [IShare::TYPE_USER, false], + [IShare::TYPE_GROUP, false], + [IShare::TYPE_USER, true], + [IShare::TYPE_GROUP, true], ]; } @@ -1275,7 +1275,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -1290,7 +1290,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy2'), @@ -1306,7 +1306,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); - $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0); + $share = $this->provider->getSharesBy('sharedBy', IShare::TYPE_USER, null, false, 1, 0); $this->assertCount(1, $share); /** @var IShare $share */ @@ -1315,7 +1315,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals('sharedWith', $share->getSharedWith()); $this->assertEquals('shareOwner', $share->getShareOwner()); $this->assertEquals('sharedBy', $share->getSharedBy()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $share->getShareType()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals('myTarget', $share->getTarget()); } @@ -1324,7 +1324,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -1339,7 +1339,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -1356,7 +1356,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); - $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0); + $share = $this->provider->getSharesBy('sharedBy', IShare::TYPE_USER, $file, false, 1, 0); $this->assertCount(1, $share); /** @var IShare $share */ @@ -1365,7 +1365,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals('sharedWith', $share->getSharedWith()); $this->assertEquals('shareOwner', $share->getShareOwner()); $this->assertEquals('sharedBy', $share->getSharedBy()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $share->getShareType()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals('myTarget', $share->getTarget()); } @@ -1374,7 +1374,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('shareOwner'), @@ -1389,7 +1389,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('shareOwner'), 'uid_initiator' => $qb->expr()->literal('sharedBy'), @@ -1406,7 +1406,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); - $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0); + $shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_USER, null, true, -1, 0); $this->assertCount(2, $shares); /** @var IShare $share */ @@ -1415,7 +1415,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertSame('sharedWith', $share->getSharedWith()); $this->assertSame('shareOwner', $share->getShareOwner()); $this->assertSame('shareOwner', $share->getSharedBy()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $share->getShareType()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals('myTarget', $share->getTarget()); @@ -1424,7 +1424,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertSame('sharedWith', $share->getSharedWith()); $this->assertSame('shareOwner', $share->getShareOwner()); $this->assertSame('sharedBy', $share->getSharedBy()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $share->getShareType()); $this->assertEquals(0, $share->getPermissions()); $this->assertEquals('userTarget', $share->getTarget()); } @@ -1433,7 +1433,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('group'), 'uid_owner' => $qb->expr()->literal('user1'), 'uid_initiator' => $qb->expr()->literal('user1'), @@ -1489,7 +1489,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('group'), 'uid_owner' => $qb->expr()->literal('user1'), 'uid_initiator' => $qb->expr()->literal('user1'), @@ -1564,7 +1564,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('group'), 'uid_owner' => $qb->expr()->literal('user1'), 'uid_initiator' => $qb->expr()->literal('user1'), @@ -1609,7 +1609,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('group'), 'uid_owner' => $qb->expr()->literal('user1'), 'uid_initiator' => $qb->expr()->literal('user1'), @@ -1647,7 +1647,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('user2'), 'uid_owner' => $qb->expr()->literal('user1'), 'uid_initiator' => $qb->expr()->literal('user1'), @@ -1700,7 +1700,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('user2'), 'uid_owner' => $qb->expr()->literal('user1'), 'uid_initiator' => $qb->expr()->literal('user1'), @@ -1743,7 +1743,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK), + 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK), 'uid_owner' => $qb->expr()->literal('user1'), 'uid_initiator' => $qb->expr()->literal('user1'), 'item_type' => $qb->expr()->literal('file'), @@ -1773,7 +1773,7 @@ class DefaultShareProviderTest extends \Test\TestCase { } public function testUpdateUser() { - $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user2', + $id = $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user2', 'file', 42, 'target', 31, null, null); $users = []; @@ -1831,7 +1831,7 @@ class DefaultShareProviderTest extends \Test\TestCase { } public function testUpdateLink() { - $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_LINK, null, 'user1', 'user2', + $id = $this->addShareToDB(IShare::TYPE_LINK, null, 'user1', 'user2', 'file', 42, 'target', 31, null, null); $users = []; @@ -1891,7 +1891,7 @@ class DefaultShareProviderTest extends \Test\TestCase { } public function testUpdateLinkRemovePassword() { - $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_LINK, 'foo', 'user1', 'user2', + $id = $this->addShareToDB(IShare::TYPE_LINK, 'foo', 'user1', 'user2', 'file', 42, 'target', 31, null, null); $qb = $this->dbConn->getQueryBuilder(); @@ -1954,7 +1954,7 @@ class DefaultShareProviderTest extends \Test\TestCase { } public function testUpdateGroupNoSub() { - $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user2', + $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user2', 'file', 42, 'target', 31, null, null); $users = []; @@ -2026,7 +2026,7 @@ class DefaultShareProviderTest extends \Test\TestCase { } public function testUpdateGroupSubShares() { - $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user2', + $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user2', 'file', 42, 'target', 31, null, null); $id2 = $this->addShareToDB(2, 'user0', 'user1', 'user2', @@ -2126,7 +2126,7 @@ class DefaultShareProviderTest extends \Test\TestCase { } public function testMoveUserShare() { - $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1', 'file', + $id = $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user1', 'file', 42, 'mytaret', 31, null, null); $user0 = $this->createMock(IUser::class); @@ -2157,7 +2157,7 @@ class DefaultShareProviderTest extends \Test\TestCase { } public function testMoveGroupShare() { - $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1', 'file', + $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user1', 'file', 42, 'mytaret', 31, null, null); $user0 = $this->createMock(IUser::class); @@ -2199,20 +2199,20 @@ class DefaultShareProviderTest extends \Test\TestCase { public function dataDeleteUser() { return [ - [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'a', true], - [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'b', false], - [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'c', true], - [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'd', false], - [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'a', true], - [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'b', false], + [IShare::TYPE_USER, 'a', 'b', 'c', 'a', true], + [IShare::TYPE_USER, 'a', 'b', 'c', 'b', false], + [IShare::TYPE_USER, 'a', 'b', 'c', 'c', true], + [IShare::TYPE_USER, 'a', 'b', 'c', 'd', false], + [IShare::TYPE_GROUP, 'a', 'b', 'c', 'a', true], + [IShare::TYPE_GROUP, 'a', 'b', 'c', 'b', false], // The group c is still valid but user c is deleted so group share stays - [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'c', false], - [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'd', false], - [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'a', true], + [IShare::TYPE_GROUP, 'a', 'b', 'c', 'c', false], + [IShare::TYPE_GROUP, 'a', 'b', 'c', 'd', false], + [IShare::TYPE_LINK, 'a', 'b', 'c', 'a', true], // To avoid invisible link shares delete initiated link shares as well (see #22327) - [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'b', true], - [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'c', false], - [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'd', false], + [IShare::TYPE_LINK, 'a', 'b', 'c', 'b', true], + [IShare::TYPE_LINK, 'a', 'b', 'c', 'c', false], + [IShare::TYPE_LINK, 'a', 'b', 'c', 'd', false], ]; } @@ -2277,7 +2277,7 @@ class DefaultShareProviderTest extends \Test\TestCase { public function testDeleteUserGroup($owner, $initiator, $recipient, $deletedUser, $groupShareDeleted, $userGroupShareDeleted) { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') - ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)) + ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)) ->setValue('uid_owner', $qb->createNamedParameter($owner)) ->setValue('uid_initiator', $qb->createNamedParameter($initiator)) ->setValue('share_with', $qb->createNamedParameter('group')) @@ -2299,7 +2299,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->execute(); $userGroupId = $qb->getLastInsertId(); - $this->provider->userDeleted($deletedUser, \OCP\Share::SHARE_TYPE_GROUP); + $this->provider->userDeleted($deletedUser, IShare::TYPE_GROUP); $qb = $this->dbConn->getQueryBuilder(); $qb->select('*') @@ -2328,28 +2328,28 @@ class DefaultShareProviderTest extends \Test\TestCase { return [ [ [ - 'type' => \OCP\Share::SHARE_TYPE_USER, + 'type' => IShare::TYPE_USER, 'recipient' => 'user', 'children' => [] ], 'group', false ], [ [ - 'type' => \OCP\Share::SHARE_TYPE_USER, + 'type' => IShare::TYPE_USER, 'recipient' => 'user', 'children' => [] ], 'user', false ], [ [ - 'type' => \OCP\Share::SHARE_TYPE_LINK, + 'type' => IShare::TYPE_LINK, 'recipient' => 'user', 'children' => [] ], 'group', false ], [ [ - 'type' => \OCP\Share::SHARE_TYPE_GROUP, + 'type' => IShare::TYPE_GROUP, 'recipient' => 'group1', 'children' => [ 'foo', @@ -2359,7 +2359,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ], [ [ - 'type' => \OCP\Share::SHARE_TYPE_GROUP, + 'type' => IShare::TYPE_GROUP, 'recipient' => 'group1', 'children' => [ 'foo', @@ -2440,7 +2440,7 @@ class DefaultShareProviderTest extends \Test\TestCase { public function testUserDeletedFromGroup($group, $user, $toDelete) { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') - ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)) + ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)) ->setValue('uid_owner', $qb->createNamedParameter('owner')) ->setValue('uid_initiator', $qb->createNamedParameter('initiator')) ->setValue('share_with', $qb->createNamedParameter('group1')) @@ -2512,7 +2512,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->setSharedBy($u1->getUID()) ->setSharedWith($u2->getUID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_ALL); $share1 = $this->provider->create($share1); @@ -2521,7 +2521,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->setSharedBy($u2->getUID()) ->setSharedWith($u3->getUID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_READ); $share2 = $this->provider->create($share2); @@ -2529,7 +2529,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share3->setNode($folder2) ->setSharedBy($u2->getUID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(\OCP\Constants::PERMISSION_READ); $share3 = $this->provider->create($share3); @@ -2538,7 +2538,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->setSharedBy($u1->getUID()) ->setSharedWith($g1->getGID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setPermissions(\OCP\Constants::PERMISSION_READ); $share4 = $this->provider->create($share4); @@ -2554,14 +2554,14 @@ class DefaultShareProviderTest extends \Test\TestCase { $file_shares = $result[$file1->getId()]; $this->assertCount(1, $file_shares); $this->assertSame($file1->getId(), $file_shares[0]->getNodeId()); - $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $file_shares[0]->getShareType()); + $this->assertSame(IShare::TYPE_USER, $file_shares[0]->getShareType()); $folder_shares = $result[$folder2->getId()]; $this->assertCount(2, $folder_shares); $this->assertSame($folder2->getId(), $folder_shares[0]->getNodeId()); $this->assertSame($folder2->getId(), $folder_shares[1]->getNodeId()); - $this->assertSame(\OCP\Share::SHARE_TYPE_LINK, $folder_shares[0]->getShareType()); - $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $folder_shares[1]->getShareType()); + $this->assertSame(IShare::TYPE_LINK, $folder_shares[0]->getShareType()); + $this->assertSame(IShare::TYPE_GROUP, $folder_shares[1]->getShareType()); $provider->delete($share1); $provider->delete($share2); @@ -2616,7 +2616,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->setSharedBy($u1->getUID()) ->setSharedWith($u2->getUID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_ALL); $share1 = $this->provider->create($share1); @@ -2625,7 +2625,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->setSharedBy($u2->getUID()) ->setSharedWith($g1->getGID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setPermissions(\OCP\Constants::PERMISSION_ALL); $share2 = $this->provider->create($share2); @@ -2635,7 +2635,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share3->setNode($file1) ->setSharedBy($u3->getUID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(\OCP\Constants::PERMISSION_READ); $share3 = $this->provider->create($share3); @@ -2644,7 +2644,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->setSharedBy($u3->getUID()) ->setSharedWith($u5->getUID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_READ); $share4 = $this->provider->create($share4); @@ -2712,7 +2712,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->setSharedBy($u1->getUID()) ->setSharedWith($u2->getUID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_ALL); $share1 = $this->provider->create($share1); @@ -2721,7 +2721,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->setSharedBy($u2->getUID()) ->setSharedWith($g1->getGID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setPermissions(\OCP\Constants::PERMISSION_ALL); $share2 = $this->provider->create($share2); @@ -2731,7 +2731,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share3->setNode($file1) ->setSharedBy($u3->getUID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(\OCP\Constants::PERMISSION_READ); $share3 = $this->provider->create($share3); @@ -2740,7 +2740,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ->setSharedBy($u3->getUID()) ->setSharedWith($u5->getUID()) ->setShareOwner($u1->getUID()) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_READ); $share4 = $this->provider->create($share4); @@ -2770,7 +2770,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_type' => $qb->expr()->literal(IShare::TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith1'), 'uid_owner' => $qb->expr()->literal('shareOwner1'), 'uid_initiator' => $qb->expr()->literal('sharedBy1'), @@ -2785,7 +2785,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP), 'share_with' => $qb->expr()->literal('sharedWith2'), 'uid_owner' => $qb->expr()->literal('shareOwner2'), 'uid_initiator' => $qb->expr()->literal('sharedBy2'), @@ -2800,7 +2800,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK), + 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK), 'token' => $qb->expr()->literal('token3'), 'uid_owner' => $qb->expr()->literal('shareOwner3'), 'uid_initiator' => $qb->expr()->literal('sharedBy3'), @@ -2815,7 +2815,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_EMAIL), + 'share_type' => $qb->expr()->literal(IShare::TYPE_EMAIL), 'share_with' => $qb->expr()->literal('shareOwner4'), 'token' => $qb->expr()->literal('token4'), 'uid_owner' => $qb->expr()->literal('shareOwner4'), @@ -2831,7 +2831,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->insert('share') ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK), + 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK), 'token' => $qb->expr()->literal('token5'), 'uid_owner' => $qb->expr()->literal('shareOwner5'), 'uid_initiator' => $qb->expr()->literal('sharedBy5'), @@ -2884,7 +2884,7 @@ class DefaultShareProviderTest extends \Test\TestCase { // We fetch the node so the root folder is eventually called $this->assertEquals($id1, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals(IShare::TYPE_USER, $share->getShareType()); $this->assertEquals('sharedWith1', $share->getSharedWith()); $this->assertEquals('sharedBy1', $share->getSharedBy()); $this->assertEquals('shareOwner1', $share->getShareOwner()); @@ -2896,7 +2896,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $shares[1]; $this->assertEquals($id2, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); + $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType()); $this->assertEquals('sharedWith2', $share->getSharedWith()); $this->assertEquals('sharedBy2', $share->getSharedBy()); $this->assertEquals('shareOwner2', $share->getShareOwner()); @@ -2908,7 +2908,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $shares[2]; $this->assertEquals($id3, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType()); + $this->assertEquals(IShare::TYPE_LINK, $share->getShareType()); $this->assertEquals(null, $share->getSharedWith()); $this->assertEquals('sharedBy3', $share->getSharedBy()); $this->assertEquals('shareOwner3', $share->getShareOwner()); @@ -2920,7 +2920,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $shares[3]; $this->assertEquals($id5, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType()); + $this->assertEquals(IShare::TYPE_LINK, $share->getShareType()); $this->assertEquals(null, $share->getSharedWith()); $this->assertEquals('sharedBy5', $share->getSharedBy()); $this->assertEquals('shareOwner5', $share->getShareOwner()); diff --git a/tests/lib/Share20/LegacyHooksTest.php b/tests/lib/Share20/LegacyHooksTest.php index 2b062e592ba..66dbafe7691 100644 --- a/tests/lib/Share20/LegacyHooksTest.php +++ b/tests/lib/Share20/LegacyHooksTest.php @@ -27,6 +27,7 @@ use OC\Share20\LegacyHooks; use OC\Share20\Manager; use OCP\Constants; use OCP\Files\File; +use OCP\Share\IShare; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\GenericEvent; use Test\TestCase; @@ -57,7 +58,7 @@ class LegacyHooksTest extends TestCase { $share = $this->manager->newShare(); $share->setId(42) ->setProviderId('prov') - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith('awesomeUser') ->setSharedBy('sharedBy') ->setNode($path) @@ -70,7 +71,7 @@ class LegacyHooksTest extends TestCase { 'id' => 42, 'itemType' => 'file', 'itemSource' => 1, - 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => 'awesomeUser', 'itemparent' => null, 'uidOwner' => 'sharedBy', @@ -94,7 +95,7 @@ class LegacyHooksTest extends TestCase { $share = $this->manager->newShare(); $share->setId(42) ->setProviderId('prov') - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith('awesomeUser') ->setSharedBy('sharedBy') ->setNode($path) @@ -107,7 +108,7 @@ class LegacyHooksTest extends TestCase { 'id' => 42, 'itemType' => 'file', 'itemSource' => 1, - 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => 'awesomeUser', 'itemparent' => null, 'uidOwner' => 'sharedBy', @@ -118,7 +119,7 @@ class LegacyHooksTest extends TestCase { 'id' => 42, 'itemType' => 'file', 'itemSource' => 1, - 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => 'awesomeUser', 'itemparent' => null, 'uidOwner' => 'sharedBy', @@ -145,7 +146,7 @@ class LegacyHooksTest extends TestCase { $share = $this->manager->newShare(); $share->setId(42) ->setProviderId('prov') - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith('awesomeUser') ->setSharedBy('sharedBy') ->setNode($path) @@ -158,7 +159,7 @@ class LegacyHooksTest extends TestCase { 'id' => 42, 'itemType' => 'file', 'itemSource' => 1, - 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => 'awesomeUser', 'itemparent' => null, 'uidOwner' => 'sharedBy', @@ -170,7 +171,7 @@ class LegacyHooksTest extends TestCase { 'id' => 42, 'itemType' => 'file', 'itemSource' => 1, - 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => 'awesomeUser', 'itemparent' => null, 'uidOwner' => 'sharedBy', @@ -197,7 +198,7 @@ class LegacyHooksTest extends TestCase { $date = new \DateTime(); $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $share->setShareType(IShare::TYPE_LINK) ->setSharedWith('awesomeUser') ->setSharedBy('sharedBy') ->setNode($path) @@ -217,7 +218,7 @@ class LegacyHooksTest extends TestCase { $expected = [ 'itemType' => 'file', 'itemSource' => 1, - 'shareType' => \OCP\Share::SHARE_TYPE_LINK, + 'shareType' => IShare::TYPE_LINK, 'shareWith' => 'awesomeUser', 'uidOwner' => 'sharedBy', 'fileSource' => 1, @@ -245,7 +246,7 @@ class LegacyHooksTest extends TestCase { $date = new \DateTime(); $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $share->setShareType(IShare::TYPE_LINK) ->setSharedWith('awesomeUser') ->setSharedBy('sharedBy') ->setNode($path) @@ -265,7 +266,7 @@ class LegacyHooksTest extends TestCase { $expected = [ 'itemType' => 'file', 'itemSource' => 1, - 'shareType' => \OCP\Share::SHARE_TYPE_LINK, + 'shareType' => IShare::TYPE_LINK, 'shareWith' => 'awesomeUser', 'uidOwner' => 'sharedBy', 'fileSource' => 1, @@ -301,7 +302,7 @@ class LegacyHooksTest extends TestCase { $share = $this->manager->newShare(); $share->setId(42) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setSharedWith('awesomeUser') ->setSharedBy('sharedBy') ->setNode($path) @@ -319,7 +320,7 @@ class LegacyHooksTest extends TestCase { 'id' => 42, 'itemType' => 'file', 'itemSource' => 1, - 'shareType' => \OCP\Share::SHARE_TYPE_LINK, + 'shareType' => IShare::TYPE_LINK, 'shareWith' => 'awesomeUser', 'uidOwner' => 'sharedBy', 'fileSource' => 1, diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index e66ac51aeea..65a5ff8946d 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -194,10 +194,10 @@ class ManagerTest extends \Test\TestCase { $group->method('getGID')->willReturn('sharedWithGroup'); return [ - [\OCP\Share::SHARE_TYPE_USER, 'sharedWithUser'], - [\OCP\Share::SHARE_TYPE_GROUP, 'sharedWithGroup'], - [\OCP\Share::SHARE_TYPE_LINK, ''], - [\OCP\Share::SHARE_TYPE_REMOTE, 'foo@bar.com'], + [IShare::TYPE_USER, 'sharedWithUser'], + [IShare::TYPE_GROUP, 'sharedWithGroup'], + [IShare::TYPE_LINK, ''], + [IShare::TYPE_REMOTE, 'foo@bar.com'], ]; } @@ -257,7 +257,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setId(42) ->setProviderId('prov') - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith('sharedWith') ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') @@ -306,7 +306,7 @@ class ManagerTest extends \Test\TestCase { $share1 = $this->manager->newShare(); $share1->setId(42) ->setProviderId('prov') - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith('sharedWith1') ->setSharedBy('sharedBy1') ->setNode($path) @@ -315,7 +315,7 @@ class ManagerTest extends \Test\TestCase { $share2 = $this->manager->newShare(); $share2->setId(43) ->setProviderId('prov') - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('sharedWith2') ->setSharedBy('sharedBy2') ->setNode($path) @@ -325,7 +325,7 @@ class ManagerTest extends \Test\TestCase { $share3 = $this->manager->newShare(); $share3->setId(44) ->setProviderId('prov') - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setSharedBy('sharedBy3') ->setNode($path) ->setTarget('myTarget3') @@ -373,7 +373,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setId(42) ->setProviderId('prov') - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith('sharedWith') ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') @@ -404,14 +404,14 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $share->method('getShareType')->willReturn(IShare::TYPE_USER); $child1 = $this->createMock(IShare::class); - $child1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $child1->method('getShareType')->willReturn(IShare::TYPE_USER); $child2 = $this->createMock(IShare::class); - $child2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $child2->method('getShareType')->willReturn(IShare::TYPE_USER); $child3 = $this->createMock(IShare::class); - $child3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $child3->method('getShareType')->willReturn(IShare::TYPE_USER); $shares = [ $child1, @@ -463,7 +463,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setExpirationDate($date) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK); + ->setShareType(IShare::TYPE_LINK); $this->defaultProvider->expects($this->once()) ->method('getShareById') @@ -572,30 +572,30 @@ class ManagerTest extends \Test\TestCase { ->willReturn($storage); $data = [ - [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith should be empty', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith should be empty', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith should be empty', true], + [$this->createShare(null, IShare::TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true], + [$this->createShare(null, IShare::TYPE_USER, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true], + [$this->createShare(null, IShare::TYPE_USER, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true], + [$this->createShare(null, IShare::TYPE_GROUP, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true], + [$this->createShare(null, IShare::TYPE_GROUP, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true], + [$this->createShare(null, IShare::TYPE_GROUP, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true], + [$this->createShare(null, IShare::TYPE_LINK, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith should be empty', true], + [$this->createShare(null, IShare::TYPE_LINK, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith should be empty', true], + [$this->createShare(null, IShare::TYPE_LINK, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith should be empty', true], [$this->createShare(null, -1, $file, null, $user0, $user0, 31, null, null), 'unknown share type', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user2, null, $user0, 31, null, null), 'SharedBy should be set', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $group0, null, $user0, 31, null, null), 'SharedBy should be set', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, null, null, $user0, 31, null, null), 'SharedBy should be set', true], + [$this->createShare(null, IShare::TYPE_USER, $file, $user2, null, $user0, 31, null, null), 'SharedBy should be set', true], + [$this->createShare(null, IShare::TYPE_GROUP, $file, $group0, null, $user0, 31, null, null), 'SharedBy should be set', true], + [$this->createShare(null, IShare::TYPE_LINK, $file, null, null, $user0, 31, null, null), 'SharedBy should be set', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user0, $user0, $user0, 31, null, null), 'Can’t share with yourself', true], + [$this->createShare(null, IShare::TYPE_USER, $file, $user0, $user0, $user0, 31, null, null), 'Can’t share with yourself', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, null, $user2, $user0, $user0, 31, null, null), 'Path should be set', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, null, $group0, $user0, $user0, 31, null, null), 'Path should be set', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, null, null, $user0, $user0, 31, null, null), 'Path should be set', true], + [$this->createShare(null, IShare::TYPE_USER, null, $user2, $user0, $user0, 31, null, null), 'Path should be set', true], + [$this->createShare(null, IShare::TYPE_GROUP, null, $group0, $user0, $user0, 31, null, null), 'Path should be set', true], + [$this->createShare(null, IShare::TYPE_LINK, null, null, $user0, $user0, 31, null, null), 'Path should be set', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $node, $user2, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $node, $group0, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true], - [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $node, null, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true], + [$this->createShare(null, IShare::TYPE_USER, $node, $user2, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true], + [$this->createShare(null, IShare::TYPE_GROUP, $node, $group0, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true], + [$this->createShare(null, IShare::TYPE_LINK, $node, null, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true], ]; $nonShareAble = $this->createMock(Folder::class); @@ -606,9 +606,9 @@ class ManagerTest extends \Test\TestCase { $nonShareAble->method('getStorage') ->willReturn($storage); - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share path', true]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share path', true]; + $data[] = [$this->createShare(null, IShare::TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share path', true]; + $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true]; + $data[] = [$this->createShare(null, IShare::TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share path', true]; $limitedPermssions = $this->createMock(File::class); $limitedPermssions->method('isShareable')->willReturn(true); @@ -619,17 +619,17 @@ class ManagerTest extends \Test\TestCase { $limitedPermssions->method('getStorage') ->willReturn($storage); - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, null, null, null), 'A share requires permissions', true]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, null, null, null), 'A share requires permissions', true]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, null, null, null), 'A share requires permissions', true]; + $data[] = [$this->createShare(null, IShare::TYPE_USER, $limitedPermssions, $user2, $user0, $user0, null, null, null), 'A share requires permissions', true]; + $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, null, null, null), 'A share requires permissions', true]; + $data[] = [$this->createShare(null, IShare::TYPE_LINK, $limitedPermssions, null, $user0, $user0, null, null, null), 'A share requires permissions', true]; $mount = $this->createMock(MoveableMount::class); $limitedPermssions->method('getMountPoint')->willReturn($mount); - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of path', true]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Can’t increase permissions of path', true]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Can’t increase permissions of path', true]; + $data[] = [$this->createShare(null, IShare::TYPE_USER, $limitedPermssions, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of path', true]; + $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Can’t increase permissions of path', true]; + $data[] = [$this->createShare(null, IShare::TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Can’t increase permissions of path', true]; $nonMoveableMountPermssions = $this->createMock(Folder::class); $nonMoveableMountPermssions->method('isShareable')->willReturn(true); @@ -640,17 +640,17 @@ class ManagerTest extends \Test\TestCase { $nonMoveableMountPermssions->method('getStorage') ->willReturn($storage); - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonMoveableMountPermssions, $user2, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonMoveableMountPermssions, $group0, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false]; + $data[] = [$this->createShare(null, IShare::TYPE_USER, $nonMoveableMountPermssions, $user2, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false]; + $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $nonMoveableMountPermssions, $group0, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false]; $rootFolder = $this->createMock(Folder::class); $rootFolder->method('isShareable')->willReturn(true); $rootFolder->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL); $rootFolder->method('getId')->willReturn(42); - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $rootFolder, $user2, $user0, $user0, 30, null, null), 'You can’t share your root folder', true]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $rootFolder, $group0, $user0, $user0, 2, null, null), 'You can’t share your root folder', true]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $rootFolder, null, $user0, $user0, 16, null, null), 'You can’t share your root folder', true]; + $data[] = [$this->createShare(null, IShare::TYPE_USER, $rootFolder, $user2, $user0, $user0, 30, null, null), 'You can’t share your root folder', true]; + $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $rootFolder, $group0, $user0, $user0, 2, null, null), 'You can’t share your root folder', true]; + $data[] = [$this->createShare(null, IShare::TYPE_LINK, $rootFolder, null, $user0, $user0, 16, null, null), 'You can’t share your root folder', true]; $allPermssions = $this->createMock(Folder::class); $allPermssions->method('isShareable')->willReturn(true); @@ -660,12 +660,12 @@ class ManagerTest extends \Test\TestCase { $allPermssions->method('getStorage') ->willReturn($storage); - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 30, null, null), 'Shares need at least read permissions', true]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 2, null, null), 'Shares need at least read permissions', true]; + $data[] = [$this->createShare(null, IShare::TYPE_USER, $allPermssions, $user2, $user0, $user0, 30, null, null), 'Shares need at least read permissions', true]; + $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 2, null, null), 'Shares need at least read permissions', true]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 31, null, null), null, false]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 3, null, null), null, false]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user0, $user0, 17, null, null), null, false]; + $data[] = [$this->createShare(null, IShare::TYPE_USER, $allPermssions, $user2, $user0, $user0, 31, null, null), null, false]; + $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 3, null, null), null, false]; + $data[] = [$this->createShare(null, IShare::TYPE_LINK, $allPermssions, null, $user0, $user0, 17, null, null), null, false]; $remoteStorage = $this->createMock(Storage\IStorage::class); @@ -679,9 +679,9 @@ class ManagerTest extends \Test\TestCase { ->willReturn($owner); $remoteFile->method('getStorage') ->willReturn($storage); - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 1, null, null), null, false]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 3, null, null), null, false]; - $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of ', true]; + $data[] = [$this->createShare(null, IShare::TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 1, null, null), null, false]; + $data[] = [$this->createShare(null, IShare::TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 3, null, null), null, false]; + $data[] = [$this->createShare(null, IShare::TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of ', true]; return $data; } @@ -747,7 +747,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setSharedWith('user0') ->setSharedBy('user1') ->setNode($userFolder); @@ -1118,7 +1118,7 @@ class ManagerTest extends \Test\TestCase { ->setId('bar'); $share2 = $this->manager->newShare(); - $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $share2->setShareType(IShare::TYPE_GROUP) ->setShareOwner('shareOwner2') ->setProviderId('foo') ->setId('baz') @@ -1156,7 +1156,7 @@ class ManagerTest extends \Test\TestCase { ->setId('bar'); $share2 = $this->manager->newShare(); - $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $share2->setShareType(IShare::TYPE_GROUP) ->setShareOwner('shareOwner2') ->setProviderId('foo') ->setId('baz') @@ -1185,7 +1185,7 @@ class ManagerTest extends \Test\TestCase { $this->userManager->method('get')->with('sharedWith')->willReturn($sharedWith); $share2 = $this->manager->newShare(); - $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $share2->setShareType(IShare::TYPE_GROUP) ->setShareOwner('shareOwner2') ->setProviderId('foo') ->setId('baz'); @@ -1598,7 +1598,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->createShare( null, - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $path, 'sharedWith', 'sharedBy', @@ -1653,7 +1653,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->createShare( null, - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, $path, 'sharedWith', 'sharedBy', @@ -1718,7 +1718,7 @@ class ManagerTest extends \Test\TestCase { $date = new \DateTime(); $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $share->setShareType(IShare::TYPE_LINK) ->setNode($path) ->setSharedBy('sharedBy') ->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1776,7 +1776,7 @@ class ManagerTest extends \Test\TestCase { /** @var IShare $share */ $share = $e->getSubject(); - return $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + return $share->getShareType() === IShare::TYPE_LINK && $share->getNode() === $path && $share->getSharedBy() === 'sharedBy' && $share->getPermissions() === \OCP\Constants::PERMISSION_ALL && @@ -1795,7 +1795,7 @@ class ManagerTest extends \Test\TestCase { /** @var IShare $share */ $share = $e->getSubject(); - return $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + return $share->getShareType() === IShare::TYPE_LINK && $share->getNode() === $path && $share->getSharedBy() === 'sharedBy' && $share->getPermissions() === \OCP\Constants::PERMISSION_ALL && @@ -1841,7 +1841,7 @@ class ManagerTest extends \Test\TestCase { $path->method('getStorage')->willReturn($storage); $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $share->setShareType(IShare::TYPE_EMAIL) ->setNode($path) ->setSharedBy('sharedBy') ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -1886,7 +1886,7 @@ class ManagerTest extends \Test\TestCase { /** @var IShare $share */ $share = $e->getSubject(); - return $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL && + return $share->getShareType() === IShare::TYPE_EMAIL && $share->getNode() === $path && $share->getSharedBy() === 'sharedBy' && $share->getPermissions() === \OCP\Constants::PERMISSION_ALL && @@ -1905,7 +1905,7 @@ class ManagerTest extends \Test\TestCase { /** @var IShare $share */ $share = $e->getSubject(); - return $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL && + return $share->getShareType() === IShare::TYPE_EMAIL && $share->getNode() === $path && $share->getSharedBy() === 'sharedBy' && $share->getPermissions() === \OCP\Constants::PERMISSION_ALL && @@ -1950,7 +1950,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->createShare( null, - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $path, 'sharedWith', 'sharedBy', @@ -2030,7 +2030,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->createShare( null, - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $path, 'sharedWith', 'sharedBy', @@ -2078,14 +2078,14 @@ class ManagerTest extends \Test\TestCase { ->method('getSharesBy') ->with( $this->equalTo('user'), - $this->equalTo(\OCP\Share::SHARE_TYPE_USER), + $this->equalTo(IShare::TYPE_USER), $this->equalTo($node), $this->equalTo(true), $this->equalTo(1), $this->equalTo(1) )->willReturn([$share]); - $shares = $this->manager->getSharesBy('user', \OCP\Share::SHARE_TYPE_USER, $node, true, 1, 1); + $shares = $this->manager->getSharesBy('user', IShare::TYPE_USER, $node, true, 1, 1); $this->assertCount(1, $shares); $this->assertSame($share, $shares[0]); @@ -2157,7 +2157,7 @@ class ManagerTest extends \Test\TestCase { } }); - $res = $manager->getSharesBy('user', \OCP\Share::SHARE_TYPE_LINK, $node, true, 3, 0); + $res = $manager->getSharesBy('user', IShare::TYPE_LINK, $node, true, 3, 0); $this->assertCount(3, $res); $this->assertEquals($shares[0]->getId(), $res[0]->getId()); @@ -2204,7 +2204,7 @@ class ManagerTest extends \Test\TestCase { $factory->expects($this->once()) ->method('getProviderForType') - ->with(\OCP\Share::SHARE_TYPE_LINK) + ->with(IShare::TYPE_LINK) ->willReturn($this->defaultProvider); $this->defaultProvider->expects($this->once()) @@ -2251,7 +2251,7 @@ class ManagerTest extends \Test\TestCase { $factory->expects($this->any()) ->method('getProviderForType') ->willReturnCallback(function ($shareType) use ($roomShareProvider) { - if ($shareType !== \OCP\Share::SHARE_TYPE_ROOM) { + if ($shareType !== IShare::TYPE_ROOM) { throw new Exception\ProviderException(); } @@ -2299,11 +2299,11 @@ class ManagerTest extends \Test\TestCase { $factory->expects($this->at(0)) ->method('getProviderForType') - ->with(\OCP\Share::SHARE_TYPE_LINK) + ->with(IShare::TYPE_LINK) ->willReturn($this->defaultProvider); $factory->expects($this->at(1)) ->method('getProviderForType') - ->with(\OCP\Share::SHARE_TYPE_REMOTE) + ->with(IShare::TYPE_REMOTE) ->willReturn($this->defaultProvider); $this->defaultProvider->expects($this->at(0)) @@ -2398,7 +2398,7 @@ class ManagerTest extends \Test\TestCase { ->willReturn('yes'); $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $share->setShareType(IShare::TYPE_LINK) ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE); $this->config @@ -2420,13 +2420,13 @@ class ManagerTest extends \Test\TestCase { public function testCheckPasswordNoLinkShare() { $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $share->method('getShareType')->willReturn(IShare::TYPE_USER); $this->assertFalse($this->manager->checkPassword($share, 'password')); } public function testCheckPasswordNoPassword() { $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $this->assertFalse($this->manager->checkPassword($share, 'password')); $share->method('getPassword')->willReturn('password'); @@ -2435,7 +2435,7 @@ class ManagerTest extends \Test\TestCase { public function testCheckPasswordInvalidPassword() { $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $share->method('getPassword')->willReturn('password'); $this->hasher->method('verify')->with('invalidpassword', 'password', '')->willReturn(false); @@ -2445,7 +2445,7 @@ class ManagerTest extends \Test\TestCase { public function testCheckPasswordValidPassword() { $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $share->method('getPassword')->willReturn('passwordHash'); $this->hasher->method('verify')->with('password', 'passwordHash', '')->willReturn(true); @@ -2455,7 +2455,7 @@ class ManagerTest extends \Test\TestCase { public function testCheckPasswordUpdateShare() { $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $share->setShareType(IShare::TYPE_LINK) ->setPassword('passwordHash'); $this->hasher->method('verify')->with('password', 'passwordHash', '') @@ -2487,7 +2487,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP); + $originalShare->setShareType(IShare::TYPE_GROUP); $manager->expects($this->once())->method('canShare')->willReturn(true); $manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare); @@ -2495,7 +2495,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_USER); + ->setShareType(IShare::TYPE_USER); $manager->updateShare($share); } @@ -2513,7 +2513,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $originalShare->setShareType(IShare::TYPE_GROUP) ->setSharedWith('origGroup'); $manager->expects($this->once())->method('canShare')->willReturn(true); @@ -2522,7 +2522,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('newGroup'); $manager->updateShare($share); @@ -2541,7 +2541,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER) + $originalShare->setShareType(IShare::TYPE_USER) ->setSharedWith('sharedWith'); $manager->expects($this->once())->method('canShare')->willReturn(true); @@ -2550,7 +2550,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith('newUser') ->setShareOwner('newUser'); @@ -2571,7 +2571,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER) + $originalShare->setShareType(IShare::TYPE_USER) ->setSharedWith('origUser') ->setPermissions(1); @@ -2585,7 +2585,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith('origUser') ->setShareOwner('newUser') ->setSharedBy('sharer') @@ -2609,7 +2609,7 @@ class ManagerTest extends \Test\TestCase { $hookListner2->expects($this->once())->method('post')->with([ 'itemType' => 'file', 'itemSource' => 100, - 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'shareWith' => 'origUser', 'uidOwner' => 'sharer', 'permissions' => 31, @@ -2631,7 +2631,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $originalShare->setShareType(IShare::TYPE_GROUP) ->setSharedWith('origUser') ->setPermissions(31); @@ -2643,7 +2643,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('origUser') ->setShareOwner('owner') ->setNode($node) @@ -2679,7 +2679,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $originalShare->setShareType(IShare::TYPE_LINK) ->setPermissions(15); $tomorrow = new \DateTime(); @@ -2692,7 +2692,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -2760,7 +2760,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $originalShare->setShareType(IShare::TYPE_LINK) ->setPermissions(15); $tomorrow = new \DateTime(); @@ -2773,7 +2773,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -2826,7 +2826,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $originalShare->setShareType(IShare::TYPE_EMAIL) ->setPermissions(\OCP\Constants::PERMISSION_ALL); $tomorrow = new \DateTime(); @@ -2839,7 +2839,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + ->setShareType(IShare::TYPE_EMAIL) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -2901,7 +2901,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $originalShare->setShareType(IShare::TYPE_EMAIL) ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setPassword(null) ->setSendPasswordByTalk(false); @@ -2916,7 +2916,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + ->setShareType(IShare::TYPE_EMAIL) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -2979,7 +2979,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $originalShare->setShareType(IShare::TYPE_EMAIL) ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setPassword('anotherPasswordHash') ->setSendPasswordByTalk(false); @@ -2994,7 +2994,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + ->setShareType(IShare::TYPE_EMAIL) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -3065,7 +3065,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $originalShare->setShareType(IShare::TYPE_EMAIL) ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setPassword(null) ->setSendPasswordByTalk(false); @@ -3080,7 +3080,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + ->setShareType(IShare::TYPE_EMAIL) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -3137,7 +3137,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $originalShare->setShareType(IShare::TYPE_EMAIL) ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setPassword('passwordHash') ->setSendPasswordByTalk(false); @@ -3152,7 +3152,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + ->setShareType(IShare::TYPE_EMAIL) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -3209,7 +3209,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $originalShare->setShareType(IShare::TYPE_EMAIL) ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setPassword('passwordHash') ->setSendPasswordByTalk(false); @@ -3224,7 +3224,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + ->setShareType(IShare::TYPE_EMAIL) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -3281,7 +3281,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $originalShare->setShareType(IShare::TYPE_EMAIL) ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setPassword('passwordHash') ->setSendPasswordByTalk(false); @@ -3296,7 +3296,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + ->setShareType(IShare::TYPE_EMAIL) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -3357,7 +3357,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $originalShare->setShareType(IShare::TYPE_EMAIL) ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setPassword('passwordHash') ->setSendPasswordByTalk(true); @@ -3372,7 +3372,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + ->setShareType(IShare::TYPE_EMAIL) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -3433,7 +3433,7 @@ class ManagerTest extends \Test\TestCase { ->getMock(); $originalShare = $this->manager->newShare(); - $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $originalShare->setShareType(IShare::TYPE_EMAIL) ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setPassword('passwordHash') ->setSendPasswordByTalk(true); @@ -3448,7 +3448,7 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $share->setProviderId('foo') ->setId('42') - ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + ->setShareType(IShare::TYPE_EMAIL) ->setToken('token') ->setSharedBy('owner') ->setShareOwner('owner') @@ -3495,7 +3495,7 @@ class ManagerTest extends \Test\TestCase { $this->expectExceptionMessage('Can’t change target of link share'); $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK); + $share->setShareType(IShare::TYPE_LINK); $recipient = $this->createMock(IUser::class); @@ -3508,7 +3508,7 @@ class ManagerTest extends \Test\TestCase { $this->expectExceptionMessage('Invalid recipient'); $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER); + $share->setShareType(IShare::TYPE_USER); $share->setSharedWith('sharedWith'); @@ -3517,7 +3517,7 @@ class ManagerTest extends \Test\TestCase { public function testMoveShareUser() { $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setId('42') ->setProviderId('foo'); @@ -3535,7 +3535,7 @@ class ManagerTest extends \Test\TestCase { $this->expectExceptionMessage('Invalid recipient'); $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP); + $share->setShareType(IShare::TYPE_GROUP); $sharedWith = $this->createMock(IGroup::class); $share->setSharedWith('shareWith'); @@ -3555,7 +3555,7 @@ class ManagerTest extends \Test\TestCase { $this->expectExceptionMessage('Group "shareWith" does not exist'); $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP); + $share->setShareType(IShare::TYPE_GROUP); $share->setSharedWith('shareWith'); $recipient = $this->createMock(IUser::class); @@ -3568,7 +3568,7 @@ class ManagerTest extends \Test\TestCase { public function testMoveShareGroup() { $share = $this->manager->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $share->setShareType(IShare::TYPE_GROUP) ->setId('42') ->setProviderId('foo'); @@ -3594,7 +3594,7 @@ class ManagerTest extends \Test\TestCase { $factory = $this->getMockBuilder('OCP\Share\IProviderFactory')->getMock(); $factory->expects($this->any())->method('getProviderForType') ->willReturnCallback(function ($id) { - if ($id === \OCP\Share::SHARE_TYPE_USER) { + if ($id === IShare::TYPE_USER) { return true; } throw new Exception\ProviderException(); @@ -3625,7 +3625,7 @@ class ManagerTest extends \Test\TestCase { public function dataTestShareProviderExists() { return [ - [\OCP\Share::SHARE_TYPE_USER, true], + [IShare::TYPE_USER, true], [42, false], ]; } diff --git a/tests/lib/TagsTest.php b/tests/lib/TagsTest.php index fd6283d2f27..38d3d611bb8 100644 --- a/tests/lib/TagsTest.php +++ b/tests/lib/TagsTest.php @@ -24,6 +24,7 @@ namespace Test; use OCP\IUser; use OCP\IUserSession; +use OCP\Share\IShare; /** * Class TagsTest @@ -314,7 +315,7 @@ class TagsTest extends \Test\TestCase { \OC_User::setUserId($this->user->getUID()); // TODO new sharing - \OC\Share\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ); + \OC\Share\Share::shareItem('test', 1, IShare::TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ); \OC_User::setUserId($otherUserId); $otherTagger = $otherTagMgr->load('test', [], true); // Update tags, load shared ones. |