|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is part of the league/commonmark package. |
| 7 | + * |
| 8 | + * (c) Colin O'Dell <[email protected]> |
| 9 | + * |
| 10 | + * For the full copyright and license information, please view the LICENSE |
| 11 | + * file that was distributed with this source code. |
| 12 | + */ |
| 13 | + |
| 14 | +namespace League\CommonMark\Tests\Functional; |
| 15 | + |
| 16 | +use League\CommonMark\CommonMarkConverter; |
| 17 | +use PHPUnit\Framework\TestCase; |
| 18 | + |
| 19 | +final class MaxDelimitersPerLineTest extends TestCase |
| 20 | +{ |
| 21 | + /** |
| 22 | + * @dataProvider provideTestCases |
| 23 | + */ |
| 24 | + public function testIt(string $input, int $maxDelimsPerLine, string $expectedOutput): void |
| 25 | + { |
| 26 | + $converter = new CommonMarkConverter(['max_delimiters_per_line' => $maxDelimsPerLine]); |
| 27 | + |
| 28 | + $this->assertEquals($expectedOutput, \trim($converter->convert($input)->getContent())); |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * @return iterable<array<mixed>> |
| 33 | + */ |
| 34 | + public function provideTestCases(): iterable |
| 35 | + { |
| 36 | + yield ['*a* **b *c* b**', 6, '<p><em>a</em> <strong>b <em>c</em> b</strong></p>']; |
| 37 | + |
| 38 | + yield ['*a* **b *c **d** c* b**', 0, '<p>*a* **b *c **d** c* b**</p>']; |
| 39 | + yield ['*a* **b *c **d** c* b**', 1, '<p>*a* **b *c **d** c* b**</p>']; |
| 40 | + yield ['*a* **b *c **d** c* b**', 2, '<p><em>a</em> **b *c **d** c* b**</p>']; |
| 41 | + yield ['*a* **b *c **d** c* b**', 3, '<p><em>a</em> **b *c **d** c* b**</p>']; |
| 42 | + yield ['*a* **b *c **d** c* b**', 4, '<p><em>a</em> **b *c **d** c* b**</p>']; |
| 43 | + yield ['*a* **b *c **d** c* b**', 5, '<p><em>a</em> **b *c **d** c* b**</p>']; |
| 44 | + yield ['*a* **b *c **d** c* b**', 6, '<p><em>a</em> **b *c <strong>d</strong> c* b**</p>']; |
| 45 | + yield ['*a* **b *c **d** c* b**', 7, '<p><em>a</em> **b <em>c <strong>d</strong> c</em> b**</p>']; |
| 46 | + yield ['*a* **b *c **d** c* b**', 8, '<p><em>a</em> <strong>b <em>c <strong>d</strong> c</em> b</strong></p>']; |
| 47 | + yield ['*a* **b *c **d** c* b**', 9, '<p><em>a</em> <strong>b <em>c <strong>d</strong> c</em> b</strong></p>']; |
| 48 | + yield ['*a* **b *c **d** c* b**', 100, '<p><em>a</em> <strong>b <em>c <strong>d</strong> c</em> b</strong></p>']; |
| 49 | + } |
| 50 | +} |
0 commit comments