summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-08-26 12:23:47 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-29 23:46:31 +0200
commitdf6360044b5c2396b2bee0dfa9e8d744bfa424d5 (patch)
tree177b81f1feca7b1b77b4cd20d006bc1820baba12 /tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php
parentbb3d16d273bb3e4552e4869dd22cb2c2d81f5387 (diff)
Added Twig template functions
Diffstat (limited to 'tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php')
-rw-r--r--tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php b/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php
new file mode 100644
index 00000000..10f2e69a
--- /dev/null
+++ b/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;
+
+use PHPUnit\Framework\TestCase;
+use Twig_Function as TwigFunction;
+
+abstract class ExtensionTest extends TestCase
+{
+ /**
+ * Assert that a twig function was registered
+ *
+ * @param string $name
+ * @param callable $callback
+ * @param TwigFunction[] $functions
+ */
+ protected function assertExtensionExists($name, $callback, $functions)
+ {
+ foreach ($functions as $function) {
+ if ($function->getName() != $name) {
+ continue;
+ }
+
+ $this->assertEquals($callback, $function->getCallable());
+ return;
+ }
+
+ $this->fail(sprintf('Function %s not found', $name));
+ }
+
+ /**
+ * Assert that a global exists
+ *
+ * @param string $name
+ * @param mixed $value
+ * @param mixed[] $globals
+ */
+ protected function assertGlobalsExists($name, $value, $globals)
+ {
+ if (isset($globals[$name])) {
+ $this->assertArraySubset([$name => $value], $globals);
+
+ return;
+ }
+
+ $this->fail(sprintf('Global %s not found', $name));
+ }
+}