You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EmoticonsEngine.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. class EmoticonsEngine extends PHPUnit_Framework_TestCase
  3. {
  4. function setUp()
  5. {
  6. include_once __DIR__ . '/../emoticons_engine.php';
  7. }
  8. /**
  9. * text2icons() method tests
  10. */
  11. function test_text2icons()
  12. {
  13. $map = array(
  14. ':D' => array('smiley-laughing.gif', ':D' ),
  15. ':-D' => array('smiley-laughing.gif', ':-D' ),
  16. ':(' => array('smiley-frown.gif', ':(' ),
  17. ':-(' => array('smiley-frown.gif', ':-(' ),
  18. '8)' => array('smiley-cool.gif', '8)' ),
  19. '8-)' => array('smiley-cool.gif', '8-)' ),
  20. ':O' => array('smiley-surprised.gif', ':O' ),
  21. ':-O' => array('smiley-surprised.gif', ':-O' ),
  22. ':P' => array('smiley-tongue-out.gif', ':P' ),
  23. ':-P' => array('smiley-tongue-out.gif', ':-P' ),
  24. ':@' => array('smiley-yell.gif', ':@' ),
  25. ':-@' => array('smiley-yell.gif', ':-@' ),
  26. 'O:)' => array('smiley-innocent.gif', 'O:)' ),
  27. 'O:-)' => array('smiley-innocent.gif', 'O:-)' ),
  28. ':)' => array('smiley-smile.gif', ':)' ),
  29. ':-)' => array('smiley-smile.gif', ':-)' ),
  30. ':$' => array('smiley-embarassed.gif', ':$' ),
  31. ':-$' => array('smiley-embarassed.gif', ':-$' ),
  32. ':*' => array('smiley-kiss.gif', ':*' ),
  33. ':-*' => array('smiley-kiss.gif', ':-*' ),
  34. ':S' => array('smiley-undecided.gif', ':S' ),
  35. ':-S' => array('smiley-undecided.gif', ':-S' ),
  36. );
  37. foreach ($map as $body => $expected) {
  38. $result = emoticons_engine::text2icons($body);
  39. $this->assertRegExp('/' . preg_quote($expected[0], '/') . '/', $result);
  40. $this->assertRegExp('/title="' . preg_quote($expected[1], '/') . '"/', $result);
  41. }
  42. }
  43. }