MaximumNestingLevelTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the league/commonmark package.
  5. *
  6. * (c) Colin O'Dell <colinodell@gmail.com>
  7. *
  8. * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
  9. * - (c) John MacFarlane
  10. *
  11. * For the full copyright and license information, please view the LICENSE
  12. * file that was distributed with this source code.
  13. */
  14. namespace League\CommonMark\Tests\Functional;
  15. use League\CommonMark\CommonMarkConverter;
  16. use PHPUnit\Framework\TestCase;
  17. final class MaximumNestingLevelTest extends TestCase
  18. {
  19. public function testThatWeCanHitTheLimit(): void
  20. {
  21. $converter = new CommonMarkConverter(['max_nesting_level' => 2]);
  22. $markdown = '> > Foo';
  23. $expected = '<blockquote>
  24. <blockquote>
  25. <p>Foo</p>
  26. </blockquote>
  27. </blockquote>
  28. ';
  29. $this->assertEquals($expected, $converter->convert($markdown));
  30. }
  31. public function testThatWeCannotExceedTheLimit(): void
  32. {
  33. $converter = new CommonMarkConverter(['max_nesting_level' => 2]);
  34. $markdown = '> > > > > > Foo';
  35. $expected = '<blockquote>
  36. <blockquote>
  37. <p>&gt; &gt; &gt; &gt; Foo</p>
  38. </blockquote>
  39. </blockquote>
  40. ';
  41. $this->assertEquals($expected, $converter->convert($markdown));
  42. }
  43. }