summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/Twig/Extensions/MarkdownTest.php
blob: fd98c7cd53a5f9b45603f08579c604610ec11ed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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>&quot;Ipsum&quot;</em></p>';
        $renderer->expects($this->once())
            ->method('text')
            ->with('Lorem *&quot;Ipsum&quot;*')
            ->willReturn($return);

        $extension = new Markdown($renderer);
        $this->assertEquals($return, $extension->render('Lorem *"Ipsum"*'));
    }
}