2018-08-29 15:29:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;
|
|
|
|
|
2019-07-08 01:31:59 +02:00
|
|
|
use Engelsystem\Helpers\Translation\Translator;
|
2018-08-29 15:29:48 +02:00
|
|
|
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(): void
|
|
|
|
{
|
|
|
|
/** @var Translator|MockObject $translator */
|
|
|
|
$translator = $this->createMock(Translator::class);
|
|
|
|
|
2019-11-29 16:51:36 +01:00
|
|
|
$extension = new Translation($translator);
|
2018-08-29 15:29:48 +02:00
|
|
|
$filters = $extension->getFilters();
|
|
|
|
|
|
|
|
$this->assertExtensionExists('trans', [$translator, 'translate'], $filters);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Renderer\Twig\Extensions\Translation::getFunctions
|
|
|
|
*/
|
|
|
|
public function testGetFunctions(): void
|
|
|
|
{
|
|
|
|
/** @var Translator|MockObject $translator */
|
|
|
|
$translator = $this->createMock(Translator::class);
|
|
|
|
|
2019-11-29 16:51:36 +01:00
|
|
|
$extension = new Translation($translator);
|
2018-08-29 15:29:48 +02:00
|
|
|
$functions = $extension->getFunctions();
|
|
|
|
|
|
|
|
$this->assertExtensionExists('__', [$translator, 'translate'], $functions);
|
2018-10-18 23:34:18 +02:00
|
|
|
$this->assertExtensionExists('_e', [$translator, 'translatePlural'], $functions);
|
2018-08-29 15:29:48 +02:00
|
|
|
}
|
|
|
|
}
|