summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/Twig/Extensions/TranslationTest.php
blob: 3b4b05c6f7c69a013a2e9c3decc520094d21ae2b (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
<?php

namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;

use Engelsystem\Helpers\Translation\Translator;
use Engelsystem\Renderer\Twig\Extensions\Translation;
use PHPUnit\Framework\MockObject\MockObject;

class TranslationTest extends ExtensionTest
{
    /**
     * @covers \Engelsystem\Renderer\Twig\Extensions\Translation::__construct
     * @covers \Engelsystem\Renderer\Twig\Extensions\Translation::getFilters
     */
    public function testGeFilters()
    {
        /** @var Translator|MockObject $translator */
        $translator = $this->createMock(Translator::class);

        $extension = new Translation($translator);
        $filters = $extension->getFilters();

        $this->assertExtensionExists('trans', [$translator, 'translate'], $filters);
    }

    /**
     * @covers \Engelsystem\Renderer\Twig\Extensions\Translation::getFunctions
     */
    public function testGetFunctions()
    {
        /** @var Translator|MockObject $translator */
        $translator = $this->createMock(Translator::class);

        $extension = new Translation($translator);
        $functions = $extension->getFunctions();

        $this->assertExtensionExists('__', [$translator, 'translate'], $functions);
        $this->assertExtensionExists('_e', [$translator, 'translatePlural'], $functions);
    }
}