You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.9 KiB
PHP
64 lines
1.9 KiB
PHP
<?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"*'));
|
|
}
|
|
|
|
/**
|
|
* @covers \Engelsystem\Renderer\Twig\Extensions\Markdown::render
|
|
*/
|
|
public function testRenderHtml()
|
|
{
|
|
/** @var Parsedown|MockObject $renderer */
|
|
$renderer = $this->createMock(Parsedown::class);
|
|
|
|
$input = '<i>**test**</i>';
|
|
$return = '<p><strong><i>**test**</i></strong></p>';
|
|
$renderer->expects($this->once())
|
|
->method('text')
|
|
->with($input)
|
|
->willReturn($return);
|
|
|
|
$extension = new Markdown($renderer);
|
|
$this->assertEquals($return, $extension->render($input, false));
|
|
}
|
|
}
|