2018-12-21 23:11:44 +01:00
|
|
|
<?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
|
|
|
|
{
|
2021-12-29 17:14:11 +01:00
|
|
|
$extension = new Markdown(new Parsedown());
|
2018-12-21 23:11:44 +01:00
|
|
|
$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
|
|
|
|
{
|
2021-12-29 17:14:11 +01:00
|
|
|
$extension = new Markdown(new Parsedown());
|
2018-12-21 23:11:44 +01:00
|
|
|
|
2021-12-29 17:14:11 +01:00
|
|
|
$this->assertEquals(
|
|
|
|
'<p><i>Lorem</i> <em>"Ipsum"</em></p>',
|
|
|
|
$extension->render('<i>Lorem</i> *"Ipsum"*'),
|
|
|
|
);
|
2018-12-21 23:11:44 +01:00
|
|
|
}
|
2020-10-21 01:08:03 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Renderer\Twig\Extensions\Markdown::render
|
|
|
|
*/
|
|
|
|
public function testRenderHtml(): void
|
|
|
|
{
|
2021-12-29 17:14:11 +01:00
|
|
|
$renderer = new Parsedown();
|
2020-10-21 01:08:03 +02:00
|
|
|
$extension = new Markdown($renderer);
|
2021-12-29 17:14:11 +01:00
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
'<p><i>Lorem</i> <em>"Ipsum"</em></p>',
|
|
|
|
$extension->render('<i>Lorem</i> *"Ipsum"*', false),
|
|
|
|
);
|
2020-10-21 01:08:03 +02:00
|
|
|
}
|
2018-12-21 23:11:44 +01:00
|
|
|
}
|