aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2018-07-04 10:39:13 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2018-07-11 10:11:48 +0200
commit3942d731d21e6369c395358699a9561519992069 (patch)
tree0f310ce8856af82c1f279a1e1e6f323cba9f1483 /apps/files_sharing/tests
parent5b06a7d773d303a9b01c98eb714fd1829129646f (diff)
downloadnextcloud-server-3942d731d21e6369c395358699a9561519992069.tar.gz
nextcloud-server-3942d731d21e6369c395358699a9561519992069.zip
update unit tests
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php78
-rw-r--r--apps/files_sharing/tests/External/ManagerTest.php13
2 files changed, 59 insertions, 32 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
index 98ae953a318..d8c706da03c 100644
--- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
@@ -85,120 +85,125 @@ 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_EMAIL];
+ $allTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_REMOTE_GROUP, Share::SHARE_TYPE_EMAIL];
return [
- [[], '', 'yes', true, true, $noRemote, false, true, true],
+ [[], '', 'yes', true, true, true, $noRemote, false, true, true],
// Test itemType
[[
'search' => '',
- ], '', 'yes', true, true, $noRemote, false, true, true],
+ ], '', 'yes', true, true, true, $noRemote, false, true, true],
[[
'search' => 'foobar',
- ], '', 'yes', true, true, $noRemote, false, true, true],
+ ], '', 'yes', true, true, true, $noRemote, false, true, true],
[[
'search' => 0,
- ], '', 'yes', true, true, $noRemote, false, true, true],
+ ], '', 'yes', true, true, true, $noRemote, false, true, true],
// Test itemType
[[
'itemType' => '',
- ], '', 'yes', true, true, $noRemote, false, true, true],
+ ], '', 'yes', true, true, true, $noRemote, false, true, true],
[[
'itemType' => 'folder',
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, true, $allTypes, false, true, true],
[[
'itemType' => 0,
- ], '', 'yes', true, true, $noRemote, false, true, true],
-
+ ], '', 'yes', true, true , true, $noRemote, false, true, true],
// Test shareType
[[
'itemType' => 'call',
- ], '', 'yes', true, true, $noRemote, false, true, true],
+ ], '', 'yes', true, true, true, $noRemote, false, true, true],
[[
'itemType' => 'folder',
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, true, $allTypes, false, true, true],
[[
'itemType' => 'folder',
'shareType' => 0,
- ], '', 'yes', true, false, [0], false, true, true],
+ ], '', 'yes', true, true, false, [0], false, true, true],
[[
'itemType' => 'folder',
'shareType' => '0',
- ], '', 'yes', true, false, [0], false, true, true],
+ ], '', 'yes', true, true, false, [0], false, true, true],
[[
'itemType' => 'folder',
'shareType' => 1,
- ], '', 'yes', true, false, [1], false, true, true],
+ ], '', 'yes', true, true, false, [1], false, true, true],
[[
'itemType' => 'folder',
'shareType' => 12,
- ], '', 'yes', true, false, [], false, true, true],
+ ], '', 'yes', true, true, false, [], false, true, true],
[[
'itemType' => 'folder',
'shareType' => 'foobar',
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, true, $allTypes, false, true, true],
+
[[
'itemType' => 'folder',
'shareType' => [0, 1, 2],
- ], '', 'yes', false, false, [0, 1], false, true, true],
+ ], '', 'yes', false, false, false, [0, 1], false, true, true],
[[
'itemType' => 'folder',
'shareType' => [0, 1],
- ], '', 'yes', false, false, [0, 1], false, true, true],
+ ], '', 'yes', false, false, false, [0, 1], false, true, true],
+ [[
+ 'itemType' => 'folder',
+ 'shareType' => $allTypes,
+ ], '', 'yes', true, true, true, $allTypes, false, true, true],
[[
'itemType' => 'folder',
'shareType' => $allTypes,
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', false, false, false, [0, 1], false, true, true],
[[
'itemType' => 'folder',
'shareType' => $allTypes,
- ], '', 'yes', false, false, [0, 1], false, true, true],
+ ], '', 'yes', true, false, false, [0, 6], false, true, false],
[[
'itemType' => 'folder',
'shareType' => $allTypes,
- ], '', 'yes', true, false, [0, 6], false, true, false],
+ ], '', 'yes', false, false, true, [0, 4], false, true, false],
[[
'itemType' => 'folder',
'shareType' => $allTypes,
- ], '', 'yes', false, true, [0, 4], false, true, false],
+ ], '', 'yes', true, true, false, [0, 6, 9], false, true, false],
// Test pagination
[[
'itemType' => 'folder',
'page' => 1,
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, true, $allTypes, false, true, true],
[[
'itemType' => 'folder',
'page' => 10,
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, true, $allTypes, false, true, true],
// Test perPage
[[
'itemType' => 'folder',
'perPage' => 1,
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, true, $allTypes, false, true, true],
[[
'itemType' => 'folder',
'perPage' => 10,
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, true, $allTypes, false, true, true],
// Test $shareWithGroupOnly setting
[[
'itemType' => 'folder',
- ], 'no', 'yes', true, true, $allTypes, false, true, true],
+ ], 'no', 'yes', true, true, true, $allTypes, false, true, true],
[[
'itemType' => 'folder',
- ], 'yes', 'yes', true, true, $allTypes, true, true, true],
+ ], 'yes', 'yes', true, true, true, $allTypes, true, true, true],
// Test $shareeEnumeration setting
[[
'itemType' => 'folder',
- ], 'no', 'yes', true, true, $allTypes, false, true, true],
+ ], 'no', 'yes', true, true, true, $allTypes, false, true, true],
[[
'itemType' => 'folder',
- ], 'no', 'no', true, true, $allTypes, false, false, true],
+ ], 'no', 'no', true, true, true, $allTypes, false, false, true],
+
];
}
@@ -209,13 +214,15 @@ class ShareesAPIControllerTest extends TestCase {
* @param string $apiSetting
* @param string $enumSetting
* @param bool $remoteSharingEnabled
+ * @param bool $isRemoteGroupSharingEnabled
* @param bool $emailSharingEnabled
* @param array $shareTypes
* @param bool $shareWithGroupOnly
* @param bool $shareeEnumeration
* @param bool $allowGroupSharing
+ * @throws OCSBadRequestException
*/
- public function testSearch($getData, $apiSetting, $enumSetting, $remoteSharingEnabled, $emailSharingEnabled, $shareTypes, $shareWithGroupOnly, $shareeEnumeration, $allowGroupSharing) {
+ public function testSearch($getData, $apiSetting, $enumSetting, $remoteSharingEnabled, $isRemoteGroupSharingEnabled, $emailSharingEnabled, $shareTypes, $shareWithGroupOnly, $shareeEnumeration, $allowGroupSharing) {
$search = isset($getData['search']) ? $getData['search'] : '';
$itemType = isset($getData['itemType']) ? $getData['itemType'] : 'irrelevant';
$page = isset($getData['page']) ? $getData['page'] : 1;
@@ -251,7 +258,7 @@ class ShareesAPIControllerTest extends TestCase {
$this->shareManager,
$this->collaboratorSearch
])
- ->setMethods(['isRemoteSharingAllowed', 'shareProviderExists'])
+ ->setMethods(['isRemoteSharingAllowed', 'shareProviderExists', 'isRemoteGroupSharingAllowed'])
->getMock();
$this->collaboratorSearch->expects($this->once())
@@ -264,6 +271,13 @@ class ShareesAPIControllerTest extends TestCase {
->with($itemType)
->willReturn($remoteSharingEnabled);
+
+ $sharees->expects($this->any())
+ ->method('isRemoteGroupSharingAllowed')
+ ->with($itemType)
+ ->willReturn($isRemoteGroupSharingEnabled);
+
+
$this->shareManager->expects($this->any())
->method('shareProviderExists')
->with(\OCP\Share::SHARE_TYPE_EMAIL)
diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php
index 2cc88160a8c..753836dd58e 100644
--- a/apps/files_sharing/tests/External/ManagerTest.php
+++ b/apps/files_sharing/tests/External/ManagerTest.php
@@ -35,6 +35,8 @@ use OCA\Files_Sharing\Tests\TestCase;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Http\Client\IClientService;
+use OCP\IGroupManager;
+use OCP\IUserManager;
use Test\Traits\UserTrait;
/**
@@ -62,6 +64,12 @@ class ManagerTest extends TestCase {
/** @var ICloudFederationFactory|\PHPUnit_Framework_MockObject_MockObject */
private $cloudFederationFactory;
+ /** @var \PHPUnit_Framework_MockObject_MockObject|IGroupManager */
+ private $groupManager;
+
+ /** @var \PHPUnit_Framework_MockObject_MockObject|IUserManager */
+ private $userManager;
+
private $uid;
/**
@@ -81,6 +89,8 @@ class ManagerTest extends TestCase {
->disableOriginalConstructor()->getMock();
$this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class);
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
+ $this->userManager = $this->createMock(IUserManager::class);
$this->manager = $this->getMockBuilder(Manager::class)
->setConstructorArgs(
@@ -93,6 +103,8 @@ class ManagerTest extends TestCase {
\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
$this->cloudFederationProviderManager,
$this->cloudFederationFactory,
+ $this->groupManager,
+ $this->userManager,
$this->uid
]
)->setMethods(['tryOCMEndPoint'])->getMock();
@@ -117,6 +129,7 @@ class ManagerTest extends TestCase {
'password' => '',
'name' => '/SharedFolder',
'owner' => 'foobar',
+ 'shareType' => \OCP\Share::SHARE_TYPE_USER,
'accepted' => false,
'user' => $this->uid,
];