summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.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/ExtensionTest.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/ExtensionTest.php')
-rw-r--r--tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php b/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php
index 10f2e69a..e1c5a378 100644
--- a/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php
+++ b/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php
@@ -8,6 +8,27 @@ use Twig_Function as TwigFunction;
abstract class ExtensionTest extends TestCase
{
/**
+ * Assert that a twig filter was registered
+ *
+ * @param string $name
+ * @param callable $callback
+ * @param TwigFunction[] $functions
+ */
+ protected function assertFilterExists($name, $callback, $functions)
+ {
+ foreach ($functions as $function) {
+ if ($function->getName() != $name) {
+ continue;
+ }
+
+ $this->assertEquals($callback, $function->getCallable());
+ return;
+ }
+
+ $this->fail(sprintf('Filter %s not found', $name));
+ }
+
+ /**
* Assert that a twig function was registered
*
* @param string $name
@@ -45,4 +66,19 @@ abstract class ExtensionTest extends TestCase
$this->fail(sprintf('Global %s not found', $name));
}
+
+ /**
+ * Assert that a token parser was set
+ *
+ * @param $tokenParser
+ * @param $tokenParsers
+ */
+ protected function assertTokenParserExists($tokenParser, $tokenParsers)
+ {
+ $this->assertArraySubset(
+ [$tokenParser],
+ $tokenParsers,
+ sprintf('Token parser %s not found', get_class($tokenParser))
+ );
+ }
}