summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-09-12 17:42:57 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-09-26 23:10:23 +0200
commitdd9e191d373217b2a07e4ac5b2cc294c0a6227a1 (patch)
tree651d723a1fa008866284b08eb5997a2fe8d3d79b /apps/files_sharing
parentf446ec83dd9275d592407a65d06496577371f7b5 (diff)
downloadnextcloud-server-dd9e191d373217b2a07e4ac5b2cc294c0a6227a1.tar.gz
nextcloud-server-dd9e191d373217b2a07e4ac5b2cc294c0a6227a1.zip
split off getUsers unit tests
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php318
1 files changed, 0 insertions, 318 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
index e027d0751cb..aa5ad4eec65 100644
--- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
@@ -162,324 +162,6 @@ class ShareesAPIControllerTest extends TestCase {
return $group;
}
- public function dataGetUsers() {
- return [
- ['test', false, true, [], [], [], [], true, false],
- ['test', false, false, [], [], [], [], true, false],
- ['test', true, true, [], [], [], [], true, false],
- ['test', true, false, [], [], [], [], true, false],
- [
- 'test', false, true, [], [],
- [
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
- ], [], true, $this->getUserMock('test', 'Test')
- ],
- [
- 'test', false, false, [], [],
- [
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
- ], [], true, $this->getUserMock('test', 'Test')
- ],
- [
- 'test', true, true, [], [],
- [], [], true, $this->getUserMock('test', 'Test')
- ],
- [
- 'test', true, false, [], [],
- [], [], true, $this->getUserMock('test', 'Test')
- ],
- [
- 'test', true, true, ['test-group'], [['test-group', 'test', 2, 0, []]],
- [
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_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']],
- ], [], true, $this->getUserMock('test', 'Test')
- ],
- [
- 'test',
- false,
- true,
- [],
- [
- $this->getUserMock('test1', 'Test One'),
- ],
- [],
- [
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ],
- true,
- false,
- ],
- [
- 'test',
- false,
- false,
- [],
- [
- $this->getUserMock('test1', 'Test One'),
- ],
- [],
- [],
- true,
- false,
- ],
- [
- 'test',
- false,
- true,
- [],
- [
- $this->getUserMock('test1', 'Test One'),
- $this->getUserMock('test2', 'Test Two'),
- ],
- [],
- [
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
- ],
- false,
- false,
- ],
- [
- 'test',
- false,
- false,
- [],
- [
- $this->getUserMock('test1', 'Test One'),
- $this->getUserMock('test2', 'Test Two'),
- ],
- [],
- [],
- true,
- false,
- ],
- [
- 'test',
- false,
- true,
- [],
- [
- $this->getUserMock('test0', 'Test'),
- $this->getUserMock('test1', 'Test One'),
- $this->getUserMock('test2', 'Test Two'),
- ],
- [
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_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']],
- ],
- false,
- false,
- ],
- [
- 'test',
- false,
- false,
- [],
- [
- $this->getUserMock('test0', 'Test'),
- $this->getUserMock('test1', 'Test One'),
- $this->getUserMock('test2', 'Test Two'),
- ],
- [
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test0']],
- ],
- [],
- true,
- false,
- ],
- [
- 'test',
- true,
- true,
- ['abc', 'xyz'],
- [
- ['abc', 'test', 2, 0, ['test1' => 'Test One']],
- ['xyz', 'test', 2, 0, []],
- ],
- [],
- [
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ],
- true,
- false,
- ],
- [
- 'test',
- true,
- false,
- ['abc', 'xyz'],
- [
- ['abc', 'test', 2, 0, ['test1' => 'Test One']],
- ['xyz', 'test', 2, 0, []],
- ],
- [],
- [],
- true,
- false,
- ],
- [
- 'test',
- true,
- true,
- ['abc', 'xyz'],
- [
- ['abc', 'test', 2, 0, [
- 'test1' => 'Test One',
- 'test2' => 'Test Two',
- ]],
- ['xyz', 'test', 2, 0, [
- 'test1' => 'Test One',
- 'test2' => 'Test Two',
- ]],
- ],
- [],
- [
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
- ],
- false,
- false,
- ],
- [
- 'test',
- true,
- false,
- ['abc', 'xyz'],
- [
- ['abc', 'test', 2, 0, [
- 'test1' => 'Test One',
- 'test2' => 'Test Two',
- ]],
- ['xyz', 'test', 2, 0, [
- 'test1' => 'Test One',
- 'test2' => 'Test Two',
- ]],
- ],
- [],
- [],
- true,
- false,
- ],
- [
- 'test',
- true,
- true,
- ['abc', 'xyz'],
- [
- ['abc', 'test', 2, 0, [
- 'test' => 'Test One',
- ]],
- ['xyz', 'test', 2, 0, [
- 'test2' => 'Test Two',
- ]],
- ],
- [
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
- ],
- [
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
- ],
- false,
- false,
- ],
- [
- 'test',
- true,
- false,
- ['abc', 'xyz'],
- [
- ['abc', 'test', 2, 0, [
- 'test' => 'Test One',
- ]],
- ['xyz', 'test', 2, 0, [
- 'test2' => 'Test Two',
- ]],
- ],
- [
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
- ],
- [],
- true,
- false,
- ],
- ];
- }
-
- /**
- * @dataProvider dataGetUsers
- *
- * @param string $searchTerm
- * @param bool $shareWithGroupOnly
- * @param bool $shareeEnumeration
- * @param array $groupResponse
- * @param array $userResponse
- * @param array $exactExpected
- * @param array $expected
- * @param bool $reachedEnd
- * @param mixed $singleUser
- */
- public function testGetUsers($searchTerm, $shareWithGroupOnly, $shareeEnumeration, $groupResponse, $userResponse, $exactExpected, $expected, $reachedEnd, $singleUser) {
- $this->invokePrivate($this->sharees, 'limit', [2]);
- $this->invokePrivate($this->sharees, 'offset', [0]);
- $this->invokePrivate($this->sharees, 'shareWithGroupOnly', [$shareWithGroupOnly]);
- $this->invokePrivate($this->sharees, 'shareeEnumeration', [$shareeEnumeration]);
-
- $user = $this->getUserMock('admin', 'Administrator');
- $this->session->expects($this->any())
- ->method('getUser')
- ->willReturn($user);
-
- if (!$shareWithGroupOnly) {
- $this->userManager->expects($this->once())
- ->method('searchDisplayName')
- ->with($searchTerm, $this->invokePrivate($this->sharees, 'limit'), $this->invokePrivate($this->sharees, 'offset'))
- ->willReturn($userResponse);
- } else {
- if ($singleUser !== false) {
- $this->groupManager->expects($this->exactly(2))
- ->method('getUserGroupIds')
- ->withConsecutive(
- $user,
- $singleUser
- )
- ->willReturn($groupResponse);
- } else {
- $this->groupManager->expects($this->once())
- ->method('getUserGroupIds')
- ->with($user)
- ->willReturn($groupResponse);
- }
-
- $this->groupManager->expects($this->exactly(sizeof($groupResponse)))
- ->method('displayNamesInGroup')
- ->with($this->anything(), $searchTerm, $this->invokePrivate($this->sharees, 'limit'), $this->invokePrivate($this->sharees, 'offset'))
- ->willReturnMap($userResponse);
- }
-
- if ($singleUser !== false) {
- $this->userManager->expects($this->once())
- ->method('get')
- ->with($searchTerm)
- ->willReturn($singleUser);
- }
-
- $this->invokePrivate($this->sharees, 'getUsers', [$searchTerm]);
- $result = $this->invokePrivate($this->sharees, 'result');
-
- $this->assertEquals($exactExpected, $result['exact']['users']);
- $this->assertEquals($expected, $result['users']);
- $this->assertCount((int) $reachedEnd, $this->invokePrivate($this->sharees, 'reachedEndFor'));
- }
-
public function dataGetGroups() {
return [
['test', false, true, [], [], [], [], true, false],