|
| 1 | +<?php |
| 2 | +namespace Moxio\CommonMark\Extension\DefinitionList\Test; |
| 3 | + |
| 4 | +use League\CommonMark\Environment; |
| 5 | +use League\CommonMark\HtmlRenderer; |
| 6 | +use Moxio\CommonMark\Extension\DefinitionList\DefinitionList; |
| 7 | +use Moxio\CommonMark\Extension\DefinitionList\DefinitionListExtension; |
| 8 | +use Moxio\CommonMark\Extension\DefinitionList\DefinitionListItemDefinition; |
| 9 | +use Moxio\CommonMark\Extension\DefinitionList\DefinitionListItemTerm; |
| 10 | +use PHPUnit\Framework\TestCase; |
| 11 | + |
| 12 | +class AttributeRenderingTest extends TestCase |
| 13 | +{ |
| 14 | + private HtmlRenderer $renderer; |
| 15 | + |
| 16 | + protected function setUp(): void |
| 17 | + { |
| 18 | + $environment = Environment::createCommonMarkEnvironment(); |
| 19 | + $environment->addExtension(new DefinitionListExtension()); |
| 20 | + $this->renderer = new HtmlRenderer($environment); |
| 21 | + } |
| 22 | + |
| 23 | + public function testCorrectlyRendersAttributesOfDefinitionList(): void |
| 24 | + { |
| 25 | + $block = new DefinitionList(); |
| 26 | + $block->data['attributes'] = ['id' => 'foo']; |
| 27 | + $actualOutput = $this->renderer->renderBlock($block); |
| 28 | + |
| 29 | + $this->assertXmlStringEqualsXmlString("<html><dl id=\"foo\"></dl></html>", "<html>$actualOutput</html>"); |
| 30 | + } |
| 31 | + |
| 32 | + public function testCorrectlyRendersAttributesOfDefinitionListItemDefinition(): void |
| 33 | + { |
| 34 | + $block = new DefinitionListItemDefinition(); |
| 35 | + $block->data['attributes'] = ['id' => 'foo']; |
| 36 | + $actualOutput = $this->renderer->renderBlock($block); |
| 37 | + |
| 38 | + $this->assertXmlStringEqualsXmlString("<html><dd id=\"foo\"></dd></html>", "<html>$actualOutput</html>"); |
| 39 | + } |
| 40 | + |
| 41 | + public function testCorrectlyRendersAttributesOfDefinitionListItemTerm(): void |
| 42 | + { |
| 43 | + $block = new DefinitionListItemTerm([]); |
| 44 | + $block->data['attributes'] = ['id' => 'foo']; |
| 45 | + $actualOutput = $this->renderer->renderBlock($block); |
| 46 | + |
| 47 | + $this->assertXmlStringEqualsXmlString("<html><dt id=\"foo\"></dt></html>", "<html>$actualOutput</html>"); |
| 48 | + } |
| 49 | +} |
0 commit comments