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
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testGeFilters(): void
|
2018-08-29 15:29:48 +02:00
|
|
|
{
|
|
|
|
/** @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
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testGetFunctions(): void
|
2018-08-29 15:29:48 +02:00
|
|
|
{
|
|
|
|
/** @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
|
|
|
}
|
|
|
|
}
|