-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from bplace/attr-support
Retrieve attributes from the block before rendering
- Loading branch information
Showing
4 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
namespace Moxio\CommonMark\Extension\DefinitionList\Test; | ||
|
||
use League\CommonMark\Environment; | ||
use League\CommonMark\HtmlRenderer; | ||
use Moxio\CommonMark\Extension\DefinitionList\DefinitionList; | ||
use Moxio\CommonMark\Extension\DefinitionList\DefinitionListExtension; | ||
use Moxio\CommonMark\Extension\DefinitionList\DefinitionListItemDefinition; | ||
use Moxio\CommonMark\Extension\DefinitionList\DefinitionListItemTerm; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AttributeRenderingTest extends TestCase | ||
{ | ||
private HtmlRenderer $renderer; | ||
|
||
protected function setUp(): void | ||
{ | ||
$environment = Environment::createCommonMarkEnvironment(); | ||
$environment->addExtension(new DefinitionListExtension()); | ||
$this->renderer = new HtmlRenderer($environment); | ||
} | ||
|
||
public function testCorrectlyRendersAttributesOfDefinitionList(): void | ||
{ | ||
$block = new DefinitionList(); | ||
$block->data['attributes'] = ['id' => 'foo']; | ||
$actualOutput = $this->renderer->renderBlock($block); | ||
|
||
$this->assertXmlStringEqualsXmlString("<html><dl id=\"foo\"></dl></html>", "<html>$actualOutput</html>"); | ||
} | ||
|
||
public function testCorrectlyRendersAttributesOfDefinitionListItemDefinition(): void | ||
{ | ||
$block = new DefinitionListItemDefinition(); | ||
$block->data['attributes'] = ['id' => 'foo']; | ||
$actualOutput = $this->renderer->renderBlock($block); | ||
|
||
$this->assertXmlStringEqualsXmlString("<html><dd id=\"foo\"></dd></html>", "<html>$actualOutput</html>"); | ||
} | ||
|
||
public function testCorrectlyRendersAttributesOfDefinitionListItemTerm(): void | ||
{ | ||
$block = new DefinitionListItemTerm([]); | ||
$block->data['attributes'] = ['id' => 'foo']; | ||
$actualOutput = $this->renderer->renderBlock($block); | ||
|
||
$this->assertXmlStringEqualsXmlString("<html><dt id=\"foo\"></dt></html>", "<html>$actualOutput</html>"); | ||
} | ||
} |