summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-03-07 11:48:14 +0100
committerJoas Schilling <coding@schilljs.com>2018-03-09 10:16:12 +0100
commita31439e89d9f5a7f1f22c4da3761f60761fab186 (patch)
treec4112739da3b832aef9651a15aea26809e708e9d
parent932fcc9859a0d9061048388b310c4f1871fa12f1 (diff)
downloadnextcloud-server-a31439e89d9f5a7f1f22c4da3761f60761fab186.tar.gz
nextcloud-server-a31439e89d9f5a7f1f22c4da3761f60761fab186.zip
Add tests for finding own email and user results pagination
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--tests/lib/Collaboration/Collaborators/MailPluginTest.php95
1 files changed, 94 insertions, 1 deletions
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index 9c4836c2eb3..7ee9cf63e18 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -32,6 +32,7 @@ use OCP\Contacts\IManager;
use OCP\Federation\ICloudIdManager;
use OCP\IConfig;
use OCP\IGroupManager;
+use OCP\IUser;
use OCP\IUserSession;
use OCP\Share;
use Test\TestCase;
@@ -98,6 +99,12 @@ class MailPluginTest extends TestCase {
$this->instantiatePlugin();
+ $currentUser = $this->createMock(IUser::class);
+ $currentUser->method('getUID')
+ ->willReturn('current');
+ $this->userSession->method('getUser')
+ ->willReturn($currentUser);
+
$this->contactsManager->expects($this->any())
->method('search')
->with($searchTerm, ['EMAIL', 'FN'])
@@ -340,7 +347,93 @@ class MailPluginTest extends TestCase {
['users' => [], 'exact' => ['users' => [['label' => 'User (test@example.com)','value' => ['shareType' => 0, 'shareWith' => 'test'],]]]],
true,
false,
- ]
+ ],
+ // Current local user found by email => no result
+ [
+ 'test@example.com',
+ [
+ [
+ 'FN' => 'User',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['current@localhost'],
+ 'isLocalSystemBook' => true,
+ ]
+ ],
+ true,
+ ['exact' => []],
+ false,
+ false,
+ ],
+ // Pagination and "more results" for user matches byyyyyyy emails
+ [
+ 'test@example',
+ [
+ [
+ 'FN' => 'User1',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['test1@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ [
+ 'FN' => 'User2',
+ 'EMAIL' => ['test@example.de'],
+ 'CLOUD' => ['test2@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ [
+ 'FN' => 'User3',
+ 'EMAIL' => ['test@example.org'],
+ 'CLOUD' => ['test3@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ [
+ 'FN' => 'User4',
+ 'EMAIL' => ['test@example.net'],
+ 'CLOUD' => ['test4@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ ],
+ true,
+ ['users' => [
+ ['label' => 'User1 (test@example.com)','value' => ['shareType' => 0, 'shareWith' => 'test1']],
+ ['label' => 'User2 (test@example.de)','value' => ['shareType' => 0, 'shareWith' => 'test2']],
+ ], 'emails' => [], 'exact' => ['users' => [], 'emails' => []]],
+ false,
+ true,
+ ],
+ // Pagination and "more results" for normal emails
+ [
+ 'test@example',
+ [
+ [
+ 'FN' => 'User1',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['test1@localhost'],
+ ],
+ [
+ 'FN' => 'User2',
+ 'EMAIL' => ['test@example.de'],
+ 'CLOUD' => ['test2@localhost'],
+ ],
+ [
+ 'FN' => 'User3',
+ 'EMAIL' => ['test@example.org'],
+ 'CLOUD' => ['test3@localhost'],
+ ],
+ [
+ 'FN' => 'User4',
+ 'EMAIL' => ['test@example.net'],
+ 'CLOUD' => ['test4@localhost'],
+ ],
+ ],
+ true,
+ ['emails' => [
+ ['label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.com']],
+ ['label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.de']],
+ ], 'exact' => ['emails' => []]],
+ false,
+ true,
+ ],
];
}