diff options
author | Joas Schilling <coding@schilljs.com> | 2019-07-11 10:24:27 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-07-11 10:24:27 +0200 |
commit | 092d34d9df352ff381d92e62d80d0ea20fd395ee (patch) | |
tree | 0602840f1b70459fda15a9e92ef093d8175aae8c /tests/lib | |
parent | 77918356d642e166a2b60cd120f291c72888930b (diff) | |
download | nextcloud-server-092d34d9df352ff381d92e62d80d0ea20fd395ee.tar.gz nextcloud-server-092d34d9df352ff381d92e62d80d0ea20fd395ee.zip |
Add a unit test for guests as well
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/Comments/CommentTest.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/lib/Comments/CommentTest.php b/tests/lib/Comments/CommentTest.php index 5fb19396d84..27d75193bc7 100644 --- a/tests/lib/Comments/CommentTest.php +++ b/tests/lib/Comments/CommentTest.php @@ -155,13 +155,21 @@ class CommentTest extends TestCase { [ 'Also @"user with spaces" are now supported', ['user with spaces'] ], + [ + 'Also @"guest/0123456789abcdef" are now supported', [], null, ['guest/0123456789abcdef'] + ], ]; } /** * @dataProvider mentionsProvider + * + * @param string $message + * @param array $expectedUids + * @param string|null $author + * @param array $expectedGuests */ - public function testMentions($message, $expectedUids, $author = null) { + public function testMentions(string $message, array $expectedUids, ?string $author = null, array $expectedGuests = []): void { $comment = new Comment(); $comment->setMessage($message); if(!is_null($author)) { @@ -169,9 +177,15 @@ class CommentTest extends TestCase { } $mentions = $comment->getMentions(); while($mention = array_shift($mentions)) { - $uid = array_shift($expectedUids); - $this->assertSame('user', $mention['type']); - $this->assertSame($uid, $mention['id']); + if ($mention['type'] === 'user') { + $id = array_shift($expectedUids); + } else if ($mention['type'] === 'guest') { + $id = array_shift($expectedGuests); + } else { + $this->fail('Unexpected mention type'); + continue; + } + $this->assertSame($id, $mention['id']); } $this->assertEmpty($mentions); $this->assertEmpty($expectedUids); |