summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-01-27 20:51:26 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-01-28 07:54:09 +0100
commit34e912ab6b7b95660bbbdf7cec4074b272ce5d1a (patch)
treedb87885f8cd928913f50070c2b13307052359327 /tests/lib
parentf2e70441e42a17b27248b93a05b0008717b124b1 (diff)
downloadnextcloud-server-34e912ab6b7b95660bbbdf7cec4074b272ce5d1a.tar.gz
nextcloud-server-34e912ab6b7b95660bbbdf7cec4074b272ce5d1a.zip
[Share 2.0] Fix interfaces and comments
* Made comments more clear * Removed unneeded methods * IShares shareTime is now a proper DateTime object * IShares getPath -> getNode & setPath -> setNode * Fix unit tests
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/share20/defaultshareprovidertest.php38
-rw-r--r--tests/lib/share20/managertest.php108
2 files changed, 73 insertions, 73 deletions
diff --git a/tests/lib/share20/defaultshareprovidertest.php b/tests/lib/share20/defaultshareprovidertest.php
index 565c5e97aa2..eb3be0bde14 100644
--- a/tests/lib/share20/defaultshareprovidertest.php
+++ b/tests/lib/share20/defaultshareprovidertest.php
@@ -172,7 +172,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($sharedWith, $share->getSharedWith());
$this->assertEquals($sharedBy, $share->getSharedBy());
$this->assertEquals($shareOwner, $share->getShareOwner());
- $this->assertEquals($ownerPath, $share->getPath());
+ $this->assertEquals($ownerPath, $share->getNode());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals(null, $share->getToken());
$this->assertEquals(null, $share->getExpirationDate());
@@ -240,7 +240,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($sharedWith, $share->getSharedWith());
$this->assertEquals($sharedBy, $share->getSharedBy());
$this->assertEquals($shareOwner, $share->getShareOwner());
- $this->assertEquals($ownerPath, $share->getPath());
+ $this->assertEquals($ownerPath, $share->getNode());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals(null, $share->getToken());
$this->assertEquals(null, $share->getExpirationDate());
@@ -303,7 +303,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals('sharedWith', $share->getPassword());
$this->assertEquals($sharedBy, $share->getSharedBy());
$this->assertEquals($shareOwner, $share->getShareOwner());
- $this->assertEquals($ownerPath, $share->getPath());
+ $this->assertEquals($ownerPath, $share->getNode());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('token', $share->getToken());
$this->assertEquals(\DateTime::createFromFormat('Y-m-d H:i:s', '2000-01-02 00:00:00'), $share->getExpirationDate());
@@ -522,7 +522,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($user1, $children[0]->getSharedWith());
$this->assertEquals($user2, $children[0]->getSharedBy());
$this->assertEquals($shareOwner, $children[0]->getShareOwner());
- $this->assertEquals($ownerPath, $children[0]->getPath());
+ $this->assertEquals($ownerPath, $children[0]->getNode());
$this->assertEquals(2, $children[0]->getPermissions());
$this->assertEquals(null, $children[0]->getToken());
$this->assertEquals(null, $children[0]->getExpirationDate());
@@ -533,7 +533,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($group1, $children[1]->getSharedWith());
$this->assertEquals($user3, $children[1]->getSharedBy());
$this->assertEquals($shareOwner, $children[1]->getShareOwner());
- $this->assertEquals($ownerPath, $children[1]->getPath());
+ $this->assertEquals($ownerPath, $children[1]->getNode());
$this->assertEquals(4, $children[1]->getPermissions());
$this->assertEquals(null, $children[1]->getToken());
$this->assertEquals(null, $children[1]->getExpirationDate());
@@ -582,7 +582,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->setSharedWith($sharedWith);
$share->setSharedBy($sharedBy);
$share->setShareOwner($shareOwner);
- $share->setPath($path);
+ $share->setNode($path);
$share->setPermissions(1);
$share->setTarget('/target');
@@ -596,8 +596,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame($shareOwner, $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
$this->assertSame('/target', $share2->getTarget());
- $this->assertLessThanOrEqual(time(), $share2->getShareTime());
- $this->assertSame($path, $share2->getPath());
+ $this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
+ $this->assertSame($path, $share2->getNode());
}
public function testCreateGroupShare() {
@@ -645,7 +645,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->setSharedWith($sharedWith);
$share->setSharedBy($sharedBy);
$share->setShareOwner($shareOwner);
- $share->setPath($path);
+ $share->setNode($path);
$share->setPermissions(1);
$share->setTarget('/target');
@@ -659,8 +659,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame($shareOwner, $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
$this->assertSame('/target', $share2->getTarget());
- $this->assertLessThanOrEqual(time(), $share2->getShareTime());
- $this->assertSame($path, $share2->getPath());
+ $this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
+ $this->assertSame($path, $share2->getNode());
}
public function testCreateLinkShare() {
@@ -701,7 +701,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->setShareType(\OCP\Share::SHARE_TYPE_LINK);
$share->setSharedBy($sharedBy);
$share->setShareOwner($shareOwner);
- $share->setPath($path);
+ $share->setNode($path);
$share->setPermissions(1);
$share->setPassword('password');
$share->setToken('token');
@@ -718,8 +718,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame($shareOwner, $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
$this->assertSame('/target', $share2->getTarget());
- $this->assertLessThanOrEqual(time(), $share2->getShareTime());
- $this->assertSame($path, $share2->getPath());
+ $this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
+ $this->assertSame($path, $share2->getNode());
$this->assertSame('password', $share2->getPassword());
$this->assertSame('token', $share2->getToken());
$this->assertEquals($expireDate, $share2->getExpirationDate());
@@ -1518,7 +1518,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->setSharedWith($users['user3']);
$share->setSharedBy($users['user4']);
$share->setShareOwner($users['user5']);
- $share->setPath($file2);
+ $share->setNode($file2);
$share->setPermissions(1);
$share2 = $this->provider->update($share);
@@ -1567,7 +1567,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->setPassword('password');
$share->setSharedBy($users['user4']);
$share->setShareOwner($users['user5']);
- $share->setPath($file2);
+ $share->setNode($file2);
$share->setPermissions(1);
$share2 = $this->provider->update($share);
@@ -1616,7 +1616,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->setPassword(null);
$share->setSharedBy($users['user4']);
$share->setShareOwner($users['user5']);
- $share->setPath($file2);
+ $share->setNode($file2);
$share->setPermissions(1);
$share2 = $this->provider->update($share);
@@ -1678,7 +1678,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->setSharedWith($groups['group0']);
$share->setSharedBy($users['user4']);
$share->setShareOwner($users['user5']);
- $share->setPath($file2);
+ $share->setNode($file2);
$share->setPermissions(1);
$share2 = $this->provider->update($share);
@@ -1747,7 +1747,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->setSharedWith($groups['group0']);
$share->setSharedBy($users['user4']);
$share->setShareOwner($users['user5']);
- $share->setPath($file2);
+ $share->setNode($file2);
$share->setPermissions(1);
$share2 = $this->provider->update($share);
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php
index 6dcfb37e126..53b1374eade 100644
--- a/tests/lib/share20/managertest.php
+++ b/tests/lib/share20/managertest.php
@@ -172,14 +172,14 @@ class ManagerTest extends \Test\TestCase {
$path = $this->getMock('\OCP\Files\File');
$path->method('getId')->willReturn(1);
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn(42);
- $share->method('getFullId')->willReturn('prov:42');
- $share->method('getShareType')->willReturn($shareType);
- $share->method('getSharedWith')->willReturn($sharedWith);
- $share->method('getSharedBy')->willReturn($sharedBy);
- $share->method('getPath')->willReturn($path);
- $share->method('getTarget')->willReturn('myTarget');
+ $share = $this->manager->newShare();
+ $share->setId(42)
+ ->setProviderId('prov')
+ ->setShareType($shareType)
+ ->setSharedWith($sharedWith)
+ ->setSharedBy($sharedBy)
+ ->setNode($path)
+ ->setTarget('myTarget');
$manager->expects($this->once())->method('getShareById')->with('prov:42')->willReturn($share);
$manager->expects($this->once())->method('deleteChildren')->with($share);
@@ -263,33 +263,33 @@ class ManagerTest extends \Test\TestCase {
$path = $this->getMock('\OCP\Files\File');
$path->method('getId')->willReturn(1);
- $share1 = $this->getMock('\OCP\Share\IShare');
- $share1->method('getId')->willReturn(42);
- $share1->method('getFullId')->willReturn('prov:42');
- $share1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
- $share1->method('getSharedWith')->willReturn($sharedWith1);
- $share1->method('getSharedBy')->willReturn($sharedBy1);
- $share1->method('getPath')->willReturn($path);
- $share1->method('getTarget')->willReturn('myTarget1');
-
- $share2 = $this->getMock('\OCP\Share\IShare');
- $share2->method('getId')->willReturn(43);
- $share2->method('getFullId')->willReturn('prov:43');
- $share2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
- $share2->method('getSharedWith')->willReturn($sharedWith2);
- $share2->method('getSharedBy')->willReturn($sharedBy2);
- $share2->method('getPath')->willReturn($path);
- $share2->method('getTarget')->willReturn('myTarget2');
- $share2->method('getParent')->willReturn(42);
-
- $share3 = $this->getMock('\OCP\Share\IShare');
- $share3->method('getId')->willReturn(44);
- $share3->method('getFullId')->willReturn('prov:44');
- $share3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
- $share3->method('getSharedBy')->willReturn($sharedBy3);
- $share3->method('getPath')->willReturn($path);
- $share3->method('getTarget')->willReturn('myTarget3');
- $share3->method('getParent')->willReturn(43);
+ $share1 = $this->manager->newShare();
+ $share1->setId(42)
+ ->setProviderId('prov')
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith($sharedWith1)
+ ->setSharedBy($sharedBy1)
+ ->setNode($path)
+ ->setTarget('myTarget1');
+
+ $share2 = $this->manager->newShare();
+ $share2->setId(43)
+ ->setProviderId('prov')
+ ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setSharedWith($sharedWith2)
+ ->setSharedBy($sharedBy2)
+ ->setNode($path)
+ ->setTarget('myTarget2')
+ ->setParent(42);
+
+ $share3 = $this->manager->newShare();
+ $share3->setId(44)
+ ->setProviderId('prov')
+ ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setSharedBy($sharedBy3)
+ ->setNode($path)
+ ->setTarget('myTarget3')
+ ->setParent(43);
$manager->expects($this->once())->method('getShareById')->with('prov:42')->willReturn($share1);
@@ -495,7 +495,7 @@ class ManagerTest extends \Test\TestCase {
$share->method('getSharedWith')->willReturn($sharedWith);
$share->method('getSharedBy')->willReturn($sharedBy);
$share->method('getSharedOwner')->willReturn($shareOwner);
- $share->method('getPath')->willReturn($path);
+ $share->method('getNode')->willReturn($path);
$share->method('getPermissions')->willReturn($permissions);
$share->method('getExpirationDate')->willReturn($expireDate);
$share->method('getPassword')->willReturn($password);
@@ -730,7 +730,7 @@ class ManagerTest extends \Test\TestCase {
$share->setSharedBy($sharedBy)->setSharedWith($sharedWith);
$path = $this->getMock('\OCP\Files\Node');
- $share->setPath($path);
+ $share->setNode($path);
$this->groupManager
->method('getUserGroupIds')
@@ -760,16 +760,16 @@ class ManagerTest extends \Test\TestCase {
* @expectedExceptionMessage Path already shared with this user
*/
public function testUserCreateChecksIdenticalShareExists() {
- $share = new \OC\Share20\Share();
- $share2 = new \OC\Share20\Share();
+ $share = $this->manager->newShare();
+ $share2 = $this->manager->newShare();
$sharedWith = $this->getMock('\OCP\IUser');
$path = $this->getMock('\OCP\Files\Node');
- $share->setSharedWith($sharedWith)->setPath($path)
+ $share->setSharedWith($sharedWith)->setNode($path)
->setProviderId('foo')->setId('bar');
- $share2->setSharedWith($sharedWith)->setPath($path)
+ $share2->setSharedWith($sharedWith)->setNode($path)
->setProviderId('foo')->setId('baz');
$this->defaultProvider
@@ -785,14 +785,14 @@ class ManagerTest extends \Test\TestCase {
* @expectedExceptionMessage Path already shared with this user
*/
public function testUserCreateChecksIdenticalPathSharedViaGroup() {
- $share = new \OC\Share20\Share();
+ $share = $this->manager->newShare();
$sharedWith = $this->getMock('\OCP\IUser');
$owner = $this->getMock('\OCP\IUser');
$path = $this->getMock('\OCP\Files\Node');
$share->setSharedWith($sharedWith)
- ->setPath($path)
+ ->setNode($path)
->setShareOwner($owner)
->setProviderId('foo')
->setId('bar');
@@ -825,7 +825,7 @@ class ManagerTest extends \Test\TestCase {
$owner = $this->getMock('\OCP\IUser');
$path = $this->getMock('\OCP\Files\Node');
$share->setSharedWith($sharedWith)
- ->setPath($path)
+ ->setNode($path)
->setShareOwner($owner)
->setProviderId('foo')
->setId('bar');
@@ -884,7 +884,7 @@ class ManagerTest extends \Test\TestCase {
$sharedWith->method('inGroup')->with($sharedBy)->willReturn(true);
$path = $this->getMock('\OCP\Files\Node');
- $share->setPath($path);
+ $share->setNode($path);
$this->defaultProvider->method('getSharesByPath')
->with($path)
@@ -904,12 +904,12 @@ class ManagerTest extends \Test\TestCase {
* @expectedExceptionMessage Path already shared with this group
*/
public function testGroupCreateChecksPathAlreadySharedWithSameGroup() {
- $share = new \OC\Share20\Share();
+ $share = $this->manager->newShare();
$sharedWith = $this->getMock('\OCP\IGroup');
$path = $this->getMock('\OCP\Files\Node');
$share->setSharedWith($sharedWith)
- ->setPath($path)
+ ->setNode($path)
->setProviderId('foo')
->setId('bar');
@@ -932,7 +932,7 @@ class ManagerTest extends \Test\TestCase {
$share->setSharedWith($sharedWith);
$path = $this->getMock('\OCP\Files\Node');
- $share->setPath($path);
+ $share->setNode($path);
$share2 = new \OC\Share20\Share();
$sharedWith2 = $this->getMock('\OCP\IGroup');
@@ -1145,7 +1145,7 @@ class ManagerTest extends \Test\TestCase {
->with($user)
->willReturn($groupIds);
- $res = $this->manager->isSharingDisabledForUser($user);
+ $res = $this->manager->sharingDisabledForUser($user);
$this->assertEquals($expected, $res);
}
@@ -1178,13 +1178,13 @@ class ManagerTest extends \Test\TestCase {
]));
$manager = $this->createManagerMock()
- ->setMethods(['isSharingDisabledForUser'])
+ ->setMethods(['sharingDisabledForUser'])
->getMock();
- $manager->method('isSharingDisabledForUser')->willReturn($disabledForUser);
+ $manager->method('sharingDisabledForUser')->willReturn($disabledForUser);
$user = $this->getMock('\OCP\IUser');
- $share = new \OC\Share20\Share();
+ $share = $this->manager->newShare();
$share->setSharedBy($user);
$res = $this->invokePrivate($manager, 'canShare', [$share]);
@@ -1334,7 +1334,7 @@ class ManagerTest extends \Test\TestCase {
$share = new \OC\Share20\Share();
$share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
- ->setPath($path)
+ ->setNode($path)
->setSharedBy($sharedBy)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setExpirationDate($date)
@@ -1776,7 +1776,7 @@ class ManagerTest extends \Test\TestCase {
->setShareOwner($user)
->setPassword('password')
->setExpirationDate($tomorrow)
- ->setPath($file);
+ ->setNode($file);
$this->defaultProvider->expects($this->once())
->method('update')