From 8257864829ffdfb410f05e0dd0a9c781f48b741a Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 29 Aug 2018 15:29:48 +0200 Subject: Added translation support for twig templates See https://twig-extensions.readthedocs.io/en/latest/i18n.html for documentation --- .../Renderer/Twig/Extensions/ExtensionTest.php | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php') 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 @@ -7,6 +7,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 * @@ -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)) + ); + } } -- cgit v1.2.3-70-g09d2