diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-12-21 23:11:44 +0100 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2018-12-22 12:01:23 +0100 |
commit | 393db492948a16f246790b88a38a1235cb167659 (patch) | |
tree | 2c9c837333c04dd06964ea1f0a13679b1b246c31 /tests/Unit | |
parent | b3f059ad04fc0f54282aea98c5c2af8d7e46867a (diff) |
Renderer: Added twig extension for markdown rendering
Diffstat (limited to 'tests/Unit')
-rw-r--r-- | tests/Unit/Renderer/Twig/Extensions/MarkdownTest.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/Unit/Renderer/Twig/Extensions/MarkdownTest.php b/tests/Unit/Renderer/Twig/Extensions/MarkdownTest.php new file mode 100644 index 00000000..fd98c7cd --- /dev/null +++ b/tests/Unit/Renderer/Twig/Extensions/MarkdownTest.php @@ -0,0 +1,44 @@ +<?php + +namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions; + +use Engelsystem\Renderer\Twig\Extensions\Markdown; +use Parsedown; +use PHPUnit\Framework\MockObject\MockObject; + +class MarkdownTest extends ExtensionTest +{ + /** + * @covers \Engelsystem\Renderer\Twig\Extensions\Markdown::getFilters + */ + public function testGeFilters() + { + /** @var Parsedown|MockObject $renderer */ + $renderer = $this->createMock(Parsedown::class); + + $extension = new Markdown($renderer); + $filters = $extension->getFilters(); + + $this->assertExtensionExists('markdown', [$extension, 'render'], $filters); + $this->assertExtensionExists('md', [$extension, 'render'], $filters); + } + + /** + * @covers \Engelsystem\Renderer\Twig\Extensions\Markdown::__construct + * @covers \Engelsystem\Renderer\Twig\Extensions\Markdown::render + */ + public function testRender() + { + /** @var Parsedown|MockObject $renderer */ + $renderer = $this->createMock(Parsedown::class); + + $return = '<p>Lorem <em>"Ipsum"</em></p>'; + $renderer->expects($this->once()) + ->method('text') + ->with('Lorem *"Ipsum"*') + ->willReturn($return); + + $extension = new Markdown($renderer); + $this->assertEquals($return, $extension->render('Lorem *"Ipsum"*')); + } +} |