summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/Twig/Extensions/TranslationTest.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-08-29 15:29:48 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-29 23:46:32 +0200
commit8257864829ffdfb410f05e0dd0a9c781f48b741a (patch)
treea0334208645bdb04625545e6775a602939c0a859 /tests/Unit/Renderer/Twig/Extensions/TranslationTest.php
parenta2c47304d8230f1937c2a4f019aba89fa74203bc (diff)
Added translation support for twig templates
See https://twig-extensions.readthedocs.io/en/latest/i18n.html for documentation
Diffstat (limited to 'tests/Unit/Renderer/Twig/Extensions/TranslationTest.php')
-rw-r--r--tests/Unit/Renderer/Twig/Extensions/TranslationTest.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/Unit/Renderer/Twig/Extensions/TranslationTest.php b/tests/Unit/Renderer/Twig/Extensions/TranslationTest.php
new file mode 100644
index 00000000..f1548604
--- /dev/null
+++ b/tests/Unit/Renderer/Twig/Extensions/TranslationTest.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;
+
+use Engelsystem\Helpers\Translator;
+use Engelsystem\Renderer\Twig\Extensions\Translation;
+use PHPUnit\Framework\MockObject\MockObject;
+use Twig_Extensions_TokenParser_Trans as TranslationTokenParser;
+
+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);
+ /** @var TranslationTokenParser|MockObject $parser */
+ $parser = $this->createMock(TranslationTokenParser::class);
+
+ $extension = new Translation($translator, $parser);
+ $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);
+ /** @var TranslationTokenParser|MockObject $parser */
+ $parser = $this->createMock(TranslationTokenParser::class);
+
+ $extension = new Translation($translator, $parser);
+ $functions = $extension->getFunctions();
+
+ $this->assertExtensionExists('__', [$translator, 'translate'], $functions);
+ }
+
+ /**
+ * @covers \Engelsystem\Renderer\Twig\Extensions\Translation::getTokenParsers
+ */
+ public function testGetTokenParsers()
+ {
+ /** @var Translator|MockObject $translator */
+ $translator = $this->createMock(Translator::class);
+ /** @var TranslationTokenParser|MockObject $parser */
+ $parser = $this->createMock(TranslationTokenParser::class);
+
+ $extension = new Translation($translator, $parser);
+ $tokenParsers = $extension->getTokenParsers();
+
+ $this->assertTokenParserExists($parser, $tokenParsers);
+ }
+}