summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/TwigServiceProviderTest.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-08-26 02:54:52 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-29 23:46:11 +0200
commitbb3d16d273bb3e4552e4869dd22cb2c2d81f5387 (patch)
tree7de41548a5bd3a56aead1d9d528aa93e058e973a /tests/Unit/Renderer/TwigServiceProviderTest.php
parenta1bc763a16ee8be109de5c9053fbc5eded53824e (diff)
Added Twig template renderer, closes #338
Diffstat (limited to 'tests/Unit/Renderer/TwigServiceProviderTest.php')
-rw-r--r--tests/Unit/Renderer/TwigServiceProviderTest.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/Unit/Renderer/TwigServiceProviderTest.php b/tests/Unit/Renderer/TwigServiceProviderTest.php
new file mode 100644
index 00000000..ede6fae4
--- /dev/null
+++ b/tests/Unit/Renderer/TwigServiceProviderTest.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Renderer;
+
+use Engelsystem\Renderer\TwigEngine;
+use Engelsystem\Renderer\TwigLoader;
+use Engelsystem\Renderer\TwigServiceProvider;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit\Framework\MockObject\MockObject;
+use Twig_Environment as Twig;
+use Twig_LoaderInterface as TwigLoaderInterface;
+
+class TwigServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Renderer\TwigServiceProvider::register
+ * @covers \Engelsystem\Renderer\TwigServiceProvider::registerTwigEngine
+ */
+ public function testRegister()
+ {
+ /** @var TwigEngine|MockObject $htmlEngine */
+ $twigEngine = $this->createMock(TwigEngine::class);
+ /** @var TwigLoader|MockObject $twigLoader */
+ $twigLoader = $this->createMock(TwigLoader::class);
+ /** @var Twig|MockObject $twig */
+ $twig = $this->createMock(Twig::class);
+
+ $app = $this->getApp(['make', 'instance', 'tag', 'get']);
+
+ $viewsPath = __DIR__ . '/Stub';
+
+ $app->expects($this->exactly(3))
+ ->method('make')
+ ->withConsecutive(
+ [TwigLoader::class, ['paths' => $viewsPath]],
+ [Twig::class],
+ [TwigEngine::class]
+ )->willReturnOnConsecutiveCalls(
+ $twigLoader,
+ $twig,
+ $twigEngine
+ );
+
+ $app->expects($this->exactly(4))
+ ->method('instance')
+ ->withConsecutive(
+ [TwigLoader::class, $twigLoader],
+ [TwigLoaderInterface::class, $twigLoader],
+ [Twig::class, $twig],
+ ['renderer.twigEngine', $twigEngine]
+ );
+
+ $app->expects($this->once())
+ ->method('get')
+ ->with('path.views')
+ ->willReturn($viewsPath);
+
+ $this->setExpects($app, 'tag', ['renderer.twigEngine', ['renderer.engine']]);
+
+ $serviceProvider = new TwigServiceProvider($app);
+ $serviceProvider->register();
+ }
+}