[
'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)) {
}
$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);