diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-27 12:13:53 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-27 22:04:37 +0100 |
commit | 185b9c6edd56157f45c72800fdea104bd360925a (patch) | |
tree | d47fc798513a5d1e680451d24f81e43c1a5bc28e /apps | |
parent | 0832cca54e09c9b1f04f3133cc1780ca6ab1ae3b (diff) | |
download | nextcloud-server-185b9c6edd56157f45c72800fdea104bd360925a.tar.gz nextcloud-server-185b9c6edd56157f45c72800fdea104bd360925a.zip |
[Share 2.0] Move IShare to OCP
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/api/share20ocs.php | 12 | ||||
-rw-r--r-- | apps/files_sharing/lib/controllers/sharecontroller.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/tests/api/share20ocstest.php | 38 | ||||
-rw-r--r-- | apps/files_sharing/tests/controller/sharecontroller.php | 16 |
4 files changed, 35 insertions, 36 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php index 3048eb7cd1a..8e216c8c3c8 100644 --- a/apps/files_sharing/api/share20ocs.php +++ b/apps/files_sharing/api/share20ocs.php @@ -20,8 +20,6 @@ */ namespace OCA\Files_Sharing\API; -use OC\Share20\IShare; - use OCP\IGroupManager; use OCP\IUserManager; use OCP\IRequest; @@ -73,10 +71,10 @@ class Share20OCS { /** * Convert an IShare to an array for OCS output * - * @param IShare $share + * @param \OCP\Share\IShare $share * @return array */ - protected function formatShare($share) { + protected function formatShare(\OCP\Share\IShare $share) { $result = [ 'id' => $share->getId(), 'share_type' => $share->getShareType(), @@ -353,7 +351,7 @@ class Share20OCS { } $nodes = $folder->getDirectoryListing(); - /** @var IShare[] $shares */ + /** @var \OCP\Share\IShare[] $shares */ $shares = []; foreach ($nodes as $node) { $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0)); @@ -494,10 +492,10 @@ class Share20OCS { } /** - * @param IShare $share + * @param \OCP\Share\IShare $share * @return bool */ - protected function canAccessShare(IShare $share) { + protected function canAccessShare(\OCP\Share\IShare $share) { // A file with permissions 0 can't be accessed by us. So Don't show it if ($share->getPermissions() === 0) { return false; diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php index 6f9a8d742cc..407207c0efc 100644 --- a/apps/files_sharing/lib/controllers/sharecontroller.php +++ b/apps/files_sharing/lib/controllers/sharecontroller.php @@ -51,7 +51,6 @@ use OCA\Files_Sharing\Helper; use OCP\Util; use OCA\Files_Sharing\Activity; use \OCP\Files\NotFoundException; -use \OC\Share20\IShare; use OCP\Files\IRootFolder; /** @@ -168,11 +167,11 @@ class ShareController extends Controller { * This is a modified version of Helper::authenticate * TODO: Try to merge back eventually with Helper::authenticate * - * @param IShare $share + * @param \OCP\Share\IShare $share * @param string|null $password * @return bool */ - private function linkShareAuth(IShare $share, $password = null) { + private function linkShareAuth(\OCP\Share\IShare $share, $password = null) { if ($password !== null) { if ($this->shareManager->checkPassword($share, $password)) { $this->session->set('public_link_authenticated', (string)$share->getId()); diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php index f38af988155..ebacf6c20fe 100644 --- a/apps/files_sharing/tests/api/share20ocstest.php +++ b/apps/files_sharing/tests/api/share20ocstest.php @@ -20,7 +20,6 @@ */ namespace OCA\Files_Sharing\Tests\API; -use OC\Share20\IShare; use OCA\Files_Sharing\API\Share20OCS; use OCP\IGroupManager; use OCP\IUserManager; @@ -90,7 +89,7 @@ class Share20OCSTest extends \Test\TestCase { } public function testDeleteShareCouldNotDelete() { - $share = $this->getMock('OC\Share20\IShare'); + $share = $this->getMock('OCP\Share\IShare'); $share->method('getShareOwner')->willReturn($this->currentUser); $this->shareManager ->expects($this->once()) @@ -109,7 +108,7 @@ class Share20OCSTest extends \Test\TestCase { } public function testDeleteShare() { - $share = $this->getMock('OC\Share20\IShare'); + $share = $this->getMock('OCP\Share\IShare'); $share->method('getSharedBy')->willReturn($this->currentUser); $this->shareManager ->expects($this->once()) @@ -143,7 +142,7 @@ class Share20OCSTest extends \Test\TestCase { public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions, $shareTime, $expiration, $parent, $target, $mail_send, $token=null, $password=null) { - $share = $this->getMock('OC\Share20\IShare'); + $share = $this->getMock('OCP\Share\IShare'); $share->method('getId')->willReturn($id); $share->method('getShareType')->willReturn($shareType); $share->method('getSharedWith')->willReturn($sharedWith); @@ -345,7 +344,7 @@ class Share20OCSTest extends \Test\TestCase { /** * @dataProvider dataGetShare */ - public function testGetShare(\OC\Share20\IShare $share, array $result) { + public function testGetShare(\OCP\Share\IShare $share, array $result) { $ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS') ->setConstructorArgs([ $this->shareManager, @@ -384,39 +383,39 @@ class Share20OCSTest extends \Test\TestCase { } public function testCanAccessShare() { - $share = $this->getMock('OC\Share20\IShare'); + $share = $this->getMock('OCP\Share\IShare'); $share->method('getShareOwner')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMock('OC\Share20\IShare'); + $share = $this->getMock('OCP\Share\IShare'); $share->method('getSharedBy')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMock('OC\Share20\IShare'); + $share = $this->getMock('OCP\Share\IShare'); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $share->method('getSharedWith')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMock('OC\Share20\IShare'); + $share = $this->getMock('OCP\Share\IShare'); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $share->method('getSharedWith')->willReturn($this->getMock('OCP\IUser')); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMock('OC\Share20\IShare'); + $share = $this->getMock('OCP\Share\IShare'); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); $group = $this->getMock('OCP\IGroup'); $group->method('inGroup')->with($this->currentUser)->willReturn(true); $share->method('getSharedWith')->willReturn($group); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMock('OC\Share20\IShare'); + $share = $this->getMock('OCP\Share\IShare'); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); $group = $this->getMock('OCP\IGroup'); $group->method('inGroup')->with($this->currentUser)->willReturn(false); $share->method('getSharedWith')->willReturn($group); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMock('OC\Share20\IShare'); + $share = $this->getMock('OCP\Share\IShare'); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); } @@ -457,7 +456,7 @@ class Share20OCSTest extends \Test\TestCase { } public function testCreateShareInvalidPermissions() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $this->shareManager->method('newShare')->willReturn($share); $this->request @@ -488,7 +487,7 @@ class Share20OCSTest extends \Test\TestCase { } public function testCreateShareUserNoShareWith() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $this->shareManager->method('newShare')->willReturn($share); $this->request @@ -520,7 +519,7 @@ class Share20OCSTest extends \Test\TestCase { } public function testCreateShareUserNoValidShareWith() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $this->shareManager->method('newShare')->willReturn($share); $this->request @@ -553,8 +552,9 @@ class Share20OCSTest extends \Test\TestCase { } public function testCreateShareUser() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $this->shareManager->method('newShare')->willReturn($share); + $this->shareManager->method('createShare')->will($this->returnArgument(0)); $ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS') ->setConstructorArgs([ @@ -611,8 +611,9 @@ class Share20OCSTest extends \Test\TestCase { } public function testCreateShareGroupNoValidShareWith() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $this->shareManager->method('newShare')->willReturn($share); + $this->shareManager->method('createShare')->will($this->returnArgument(0)); $this->request ->method('getParam') @@ -644,8 +645,9 @@ class Share20OCSTest extends \Test\TestCase { } public function testCreateShareGroup() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $this->shareManager->method('newShare')->willReturn($share); + $this->shareManager->method('createShare')->will($this->returnArgument(0)); $ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS') ->setConstructorArgs([ diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php index 43db17f5abc..7d13753d322 100644 --- a/apps/files_sharing/tests/controller/sharecontroller.php +++ b/apps/files_sharing/tests/controller/sharecontroller.php @@ -116,7 +116,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testShowAuthenticateNotAuthenticated() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $this->shareManager ->expects($this->once()) @@ -130,7 +130,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testShowAuthenticateAuthenticatedForDifferentShare() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $share->method('getId')->willReturn(1); $this->shareManager @@ -148,7 +148,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testShowAuthenticateCorrectShare() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $share->method('getId')->willReturn(1); $this->shareManager @@ -183,7 +183,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testAuthenticateValidPassword() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $share->method('getId')->willReturn(42); $this->shareManager @@ -214,7 +214,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testAuthenticateInvalidPassword() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $share->method('getId')->willReturn(42); $this->shareManager @@ -252,7 +252,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testShowShareNotAuthenticated() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $share->method('getPassword')->willReturn('password'); $this->shareManager @@ -283,7 +283,7 @@ class ShareControllerTest extends \Test\TestCase { $file->method('getMimetype')->willReturn('text/plain'); $file->method('getSize')->willReturn(33); - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $share->method('getId')->willReturn('42'); $share->method('getPassword')->willReturn('password'); $share->method('getShareOwner')->willReturn($owner); @@ -340,7 +340,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testDownloadShare() { - $share = $this->getMock('\OC\Share20\IShare'); + $share = $this->getMock('\OCP\Share\IShare'); $share->method('getPassword')->willReturn('password'); $this->shareManager |