2018-12-21 23:11:44 +01:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-12-21 23:11:44 +01:00
|
|
|
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
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testGeFilters(): void
|
2018-12-21 23:11:44 +01:00
|
|
|
{
|
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
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testRender(): void
|
2018-12-21 23:11:44 +01:00
|
|
|
{
|
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
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testRenderHtml(): void
|
2020-10-21 01:08:03 +02:00
|
|
|
{
|
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
|
|
|
}
|