diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-01-17 13:48:43 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-01-18 12:08:08 +0100 |
commit | 92bc33dd1e2eedd408add076a4f0a37257542951 (patch) | |
tree | dc2849b992c364eb7f6554482b5ef98ea2e91428 /tests/lib | |
parent | 266c64069fb300d79f253a1bdd2e249e78330d50 (diff) | |
download | nextcloud-server-92bc33dd1e2eedd408add076a4f0a37257542951.tar.gz nextcloud-server-92bc33dd1e2eedd408add076a4f0a37257542951.zip |
Backport of format self-mentions, but don't offer them #7914
comments should compile mentions also if done by author
it is used by clients for formatting reasons, there is no reason not format
the author if her handle is included in the comment body.
It is unrelated to sending out notifications.
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
do not offer the handle of the current user for auto completion
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
add types to php doc
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/Collaboration/Collaborators/UserPluginTest.php | 47 | ||||
-rw-r--r-- | tests/lib/Comments/CommentTest.php | 9 |
2 files changed, 54 insertions, 2 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)); + } } diff --git a/tests/lib/Comments/CommentTest.php b/tests/lib/Comments/CommentTest.php index 10ec4bae7d5..6f67356ccae 100644 --- a/tests/lib/Comments/CommentTest.php +++ b/tests/lib/Comments/CommentTest.php @@ -8,6 +8,9 @@ use Test\TestCase; class CommentTest extends TestCase { + /** + * @throws \OCP\Comments\IllegalIDChangeException + */ public function testSettersValidInput() { $comment = new Comment(); @@ -58,6 +61,9 @@ class CommentTest extends TestCase { $comment->setId('c17'); } + /** + * @throws \OCP\Comments\IllegalIDChangeException + */ public function testResetId() { $comment = new Comment(); $comment->setId('c23'); @@ -133,7 +139,7 @@ class CommentTest extends TestCase { '@alice @bob look look, a duplication @alice test @bob!', ['alice', 'bob'] ], [ - '@alice is the author, but notify @bob!', ['bob'], 'alice' + '@alice is the author, notify @bob, nevertheless mention her!', ['alice', 'bob'], 'alice' ], [ '@foobar and @barfoo you should know, @foo@bar.com is valid' . @@ -159,7 +165,6 @@ class CommentTest extends TestCase { $uid = array_shift($expectedUids); $this->assertSame('user', $mention['type']); $this->assertSame($uid, $mention['id']); - $this->assertNotSame($author, $mention['id']); } $this->assertEmpty($mentions); $this->assertEmpty($expectedUids); |