summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-09-13 14:29:57 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-09-26 23:10:24 +0200
commita28b1d91f95f421c6efbb7752d9404c6719c0688 (patch)
tree6a7db1eb763d4ec480e898046971db56d3a23768 /apps/files_sharing
parent4a315ede819b700b6f55fa1c6dc70c60ea728ea4 (diff)
downloadnextcloud-server-a28b1d91f95f421c6efbb7752d9404c6719c0688.tar.gz
nextcloud-server-a28b1d91f95f421c6efbb7752d9404c6719c0688.zip
split off former searchSharee unit test
also moves registering default plugins to Server for proper unit testing Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php176
1 files changed, 0 insertions, 176 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
index ccacd382935..529a8754b83 100644
--- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
@@ -399,182 +399,6 @@ class ShareesAPIControllerTest extends TestCase {
$this->assertSame($expected, $this->invokePrivate($this->sharees, 'isRemoteSharingAllowed', [$itemType]));
}
- public function dataSearchSharees() {
- return [
- ['test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
- [
- 'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
- 'users' => [],
- 'groups' => [],
- 'remotes' => [],
- 'emails' => [],
- 'circles' => [],
- 'lookup' => [],
- ], false],
- ['test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
- [
- 'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
- 'users' => [],
- 'groups' => [],
- 'remotes' => [],
- 'emails' => [],
- 'circles' => [],
- 'lookup' => [],
- ], false],
- [
- 'test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ], [
- ['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']],
- ], [
- 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false,
- ],
- [
- 'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
- 'users' => [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ],
- 'groups' => [
- ['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']],
- ],
- 'remotes' => [
- ['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
- ],
- 'emails' => [],
- 'circles' => [],
- 'lookup' => [],
- ], true,
- ],
- // No groups requested
- [
- 'test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_REMOTE], 1, 2, false, [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ], null, [
- 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false
- ],
- [
- 'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
- 'users' => [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ],
- 'groups' => [],
- 'remotes' => [
- ['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
- ],
- 'emails' => [],
- 'circles' => [],
- 'lookup' => [],
- ], false,
- ],
- // Share type restricted to user - Only one user
- [
- 'test', 'folder', [Share::SHARE_TYPE_USER], 1, 2, false, [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ], null, null,
- [
- 'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
- 'users' => [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ],
- 'groups' => [],
- 'remotes' => [],
- 'emails' => [],
- 'circles' => [],
- 'lookup' => [],
- ], false,
- ],
- // Share type restricted to user - Multipage result
- [
- 'test', 'folder', [Share::SHARE_TYPE_USER], 1, 2, false, [
- ['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
- ], null, null,
- [
- 'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
- 'users' => [
- ['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
- ],
- 'groups' => [],
- 'remotes' => [],
- 'emails' => [],
- 'circles' => [],
- 'lookup' => [],
- ], true,
- ],
- ];
- }
-
- /**
- * @dataProvider dataSearchSharees
- *
- * @param string $searchTerm
- * @param string $itemType
- * @param array $shareTypes
- * @param int $page
- * @param int $perPage
- * @param bool $shareWithGroupOnly
- * @param array $mockedUserResult
- * @param array $mockedGroupsResult
- * @param array $mockedRemotesResult
- * @param array $expected
- * @param bool $nextLink
- */
- public function testSearchSharees($searchTerm, $itemType, array $shareTypes, $page, $perPage, $shareWithGroupOnly,
- $mockedUserResult, $mockedGroupsResult, $mockedRemotesResult, $expected, $nextLink) {
- /** @var \PHPUnit_Framework_MockObject_MockObject|\OCA\Files_Sharing\Controller\ShareesAPIController $sharees */
- $sharees = $this->getMockBuilder('\OCA\Files_Sharing\Controller\ShareesAPIController')
- ->setConstructorArgs([
- 'files_sharing',
- $this->getMockBuilder('OCP\IRequest')->disableOriginalConstructor()->getMock(),
- $this->groupManager,
- $this->userManager,
- $this->contactsManager,
- $this->getMockBuilder('OCP\IConfig')->disableOriginalConstructor()->getMock(),
- $this->session,
- $this->getMockBuilder('OCP\IURLGenerator')->disableOriginalConstructor()->getMock(),
- $this->getMockBuilder('OCP\ILogger')->disableOriginalConstructor()->getMock(),
- $this->shareManager,
- $this->clientService,
- $this->cloudIdManager
- ])
- ->setMethods(array('getShareesForShareIds', 'getUsers', 'getGroups', 'getRemote'))
- ->getMock();
- $sharees->expects(($mockedUserResult === null) ? $this->never() : $this->once())
- ->method('getUsers')
- ->with($searchTerm)
- ->willReturnCallback(function() use ($sharees, $mockedUserResult) {
- $result = $this->invokePrivate($sharees, 'result');
- $result['users'] = $mockedUserResult;
- $this->invokePrivate($sharees, 'result', [$result]);
- });
- $sharees->expects(($mockedGroupsResult === null) ? $this->never() : $this->once())
- ->method('getGroups')
- ->with($searchTerm)
- ->willReturnCallback(function() use ($sharees, $mockedGroupsResult) {
- $result = $this->invokePrivate($sharees, 'result');
- $result['groups'] = $mockedGroupsResult;
- $this->invokePrivate($sharees, 'result', [$result]);
- });
-
- $sharees->expects(($mockedRemotesResult === null) ? $this->never() : $this->once())
- ->method('getRemote')
- ->with($searchTerm)
- ->willReturn($mockedRemotesResult);
-
- $ocs = $this->invokePrivate($sharees, 'searchSharees', [$searchTerm, $itemType, $shareTypes, $page, $perPage, $shareWithGroupOnly]);
- $this->assertInstanceOf('\OCP\AppFramework\Http\DataResponse', $ocs);
- $this->assertEquals($expected, $ocs->getData());
-
- // Check if next link is set
- if ($nextLink) {
- $headers = $ocs->getHeaders();
- $this->assertArrayHasKey('Link', $headers);
- $this->assertStringStartsWith('<', $headers['Link']);
- $this->assertStringEndsWith('>; rel="next"', $headers['Link']);
- }
- }
-
/**
* @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
* @expectedExceptionMessage Missing itemType