engelsystem/tests/Unit/Renderer/Twig/Extensions/MarkdownTest.php

50 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;
use Engelsystem\Renderer\Twig\Extensions\Markdown;
use Parsedown;
class MarkdownTest extends ExtensionTest
{
/**
* @covers \Engelsystem\Renderer\Twig\Extensions\Markdown::getFilters
*/
public function testGeFilters(): void
{
$extension = new Markdown(new Parsedown());
$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(): void
{
$extension = new Markdown(new Parsedown());
$this->assertEquals(
'<p>&lt;i&gt;Lorem&lt;/i&gt; <em>&quot;Ipsum&quot;</em></p>',
$extension->render('<i>Lorem</i> *"Ipsum"*'),
);
}
2020-10-21 01:08:03 +02:00
/**
* @covers \Engelsystem\Renderer\Twig\Extensions\Markdown::render
*/
public function testRenderHtml(): void
2020-10-21 01:08:03 +02:00
{
$renderer = new Parsedown();
2020-10-21 01:08:03 +02:00
$extension = new Markdown($renderer);
$this->assertEquals(
'<p><i>Lorem</i> <em>&quot;Ipsum&quot;</em></p>',
$extension->render('<i>Lorem</i> *"Ipsum"*', false),
);
2020-10-21 01:08:03 +02:00
}
}