@@ -202,17 +202,55 @@ public static function mentionsProvider(): array {
202202 ['type ' => 'email ' , 'id ' => 'aa23d315de327cfc330f0401ea061005b2b0cdd45ec8346f12664dd1f34cb886 ' ],
203203 ],
204204 ],
205+ [
206+ 'Mention @alice but not `@bob` inside inline code ' ,
207+ [['type ' => 'user ' , 'id ' => 'alice ' ]],
208+ ],
209+ [
210+ 'Mention @alice but not `Hello @bob there` inside inline code ' ,
211+ [['type ' => 'user ' , 'id ' => 'alice ' ]],
212+ ],
213+ [
214+ "Mention ` user @alice \nAs it's just 2 ` accents " ,
215+ [['type ' => 'user ' , 'id ' => 'alice ' ]],
216+ ],
217+ [
218+ 'Mention @alice and @bob but not `Hello @bob there` inside inline code ' ,
219+ [['type ' => 'user ' , 'id ' => 'alice ' ], ['type ' => 'user ' , 'id ' => 'bob ' ]],
220+ ],
221+ [
222+ "Mention @alice but not in fenced code block \n``` \n@bob @charlie \n``` \nend " ,
223+ [['type ' => 'user ' , 'id ' => 'alice ' ]],
224+ ],
225+ [
226+ "Mention @alice but not in tilde code block \n~~~ \n@bob \n~~~ \nend " ,
227+ [['type ' => 'user ' , 'id ' => 'alice ' ]],
228+ ],
229+ [
230+ 'No mentions at all in `@alice` and `@bob` ' ,
231+ [],
232+ ],
233+ [
234+ "@alice \n``` \n@bob \n``` \n@charlie " ,
235+ [['type ' => 'user ' , 'id ' => 'charlie ' ], ['type ' => 'user ' , 'id ' => 'alice ' ]],
236+ ],
237+ [
238+ "@alice \n``` \n@bob \n``` \n@charlie " ,
239+ [['type ' => 'user ' , 'id ' => 'charlie ' ], ['type ' => 'user ' , 'id ' => 'alice ' ], ['type ' => 'user ' , 'id ' => 'bob ' ]],
240+ null ,
241+ false ,
242+ ],
205243 ];
206244 }
207245
208246 #[DataProvider(methodName: 'mentionsProvider ' )]
209- public function testMentions (string $ message , array $ expectedMentions , ?string $ author = null ): void {
247+ public function testMentions (string $ message , array $ expectedMentions , ?string $ author = null , bool $ markdown = true ): void {
210248 $ comment = new Comment ();
211249 $ comment ->setMessage ($ message );
212250 if (!is_null ($ author )) {
213251 $ comment ->setActor ('user ' , $ author );
214252 }
215- $ mentions = $ comment ->getMentions ();
253+ $ mentions = $ comment ->getMentions ($ markdown );
216254 $ this ->assertSame ($ expectedMentions , $ mentions );
217255 }
218256}
0 commit comments