summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2018-01-17 13:49:18 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2018-01-17 13:49:18 +0100
commit6fdd6861118f55a9e740552b82382f55e9415eea (patch)
tree240878b5cc10662a963e1abcb47feaef6678dd32 /tests
parent3784fa2074ba411860e2986b7b324f4c93ca899e (diff)
downloadnextcloud-server-6fdd6861118f55a9e740552b82382f55e9415eea.tar.gz
nextcloud-server-6fdd6861118f55a9e740552b82382f55e9415eea.zip
do not offer the handle of the current user for auto completion
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Collaboration/Collaborators/UserPluginTest.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
index 7d6d9c645a0..cfb97de8676 100644
--- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
@@ -442,4 +442,51 @@ class UserPluginTest extends TestCase {
$this->assertEquals($expected, $result['users']);
$this->assertSame($reachedEnd, $moreResults);
}
+
+ public function takeOutCurrentUserProvider() {
+ $inputUsers = [
+ 'alice' => 'Alice',
+ 'bob' => 'Bob',
+ 'carol' => 'Carol'
+ ];
+ return [
+ [
+ $inputUsers,
+ ['alice', 'carol'],
+ 'bob'
+ ],
+ [
+ $inputUsers,
+ ['alice', 'bob', 'carol'],
+ 'dave'
+ ],
+ [
+ $inputUsers,
+ ['alice', 'bob', 'carol'],
+ null
+ ]
+ ];
+ }
+
+ /**
+ * @dataProvider takeOutCurrentUserProvider
+ * @param array $users
+ * @param array $expectedUIDs
+ * @param $currentUserId
+ */
+ public function testTakeOutCurrentUser(array $users, array $expectedUIDs, $currentUserId) {
+ $this->instantiatePlugin();
+
+ $this->session->expects($this->once())
+ ->method('getUser')
+ ->willReturnCallback(function() use ($currentUserId) {
+ if($currentUserId !== null) {
+ return $this->getUserMock($currentUserId, $currentUserId);
+ }
+ return null;
+ });
+
+ $this->plugin->takeOutCurrentUser($users);
+ $this->assertSame($expectedUIDs, array_keys($users));
+ }
}