HomeTest.php 540 B

12345678910111213141516171819
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. class HomeTest extends TestCase
  4. {
  5. public function testRegexMention()
  6. {
  7. $text = 'Salut @nathan';
  8. $mentions = array();
  9. preg_match_all("~@([a-zA-Z0-9_]*)~", $text, $mentions);
  10. self::assertEquals($mentions[0][0], "@nathan");
  11. }
  12. public function testRegexHashtag()
  13. {
  14. $text = 'Salut #nathan';
  15. $mentions = array();
  16. preg_match_all("~#([a-zA-Z0-9_]*)~", $text, $mentions);
  17. self::assertEquals($mentions[0][0], "#nathan");
  18. }
  19. }