MarkdownExtraTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. class MarkdownExtraTest extends \PHPUnit\Framework\TestCase
  3. {
  4. public function testSetupOfPredefinedAttributes()
  5. {
  6. $obj = new \Michelf\MarkdownExtra();
  7. // Allows custom expansions of arreviations to their full version with the abbr tag
  8. $obj->predef_abbr = array(
  9. 'foo' => 'foobar-test',
  10. );
  11. $result = $obj->transform('**Hello world, foo**');
  12. $this->assertSame(
  13. '<p><strong>Hello world, <abbr title="foobar-test">foo</abbr></strong></p>',
  14. trim($result)
  15. );
  16. }
  17. public function testSetupOfMultiplePredefinedAttributes()
  18. {
  19. $obj = new \Michelf\MarkdownExtra();
  20. // Allows custom expansions of arreviations to their full version with the abbr tag
  21. $obj->predef_abbr = array(
  22. 'foo' => 'foobar-test',
  23. 'ISP' => 'Internet Service Provider',
  24. );
  25. $result = $obj->transform('**I get internet from an ISP. foo.**');
  26. $this->assertSame(
  27. '<p><strong>I get internet from an <abbr title="Internet Service Provider">ISP' .
  28. '</abbr>. <abbr title="foobar-test">foo</abbr>.</strong></p>',
  29. trim($result)
  30. );
  31. }
  32. public function testTransformWithNoMarkup()
  33. {
  34. $obj = new \Michelf\MarkdownExtra();
  35. $obj->no_markup = true;
  36. $result = $obj->transform('This is a <strong class="custom">no markup</strong> test.');
  37. $this->assertSame(
  38. '<p>This is a &lt;strong class="custom">no markup&lt;/strong> test.</p>',
  39. trim($result)
  40. );
  41. }
  42. }