summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/RendererTest.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-11-28 15:43:51 +0100
committerGitHub <noreply@github.com>2017-11-28 15:43:51 +0100
commit599f2fd264bfc7b1b6826fe206442806e317340f (patch)
tree50cf84d7d07d11bd65b45c2c17f37632f6cd8eff /tests/Unit/Renderer/RendererTest.php
parenta5fc5bd0979e8de1fce8a8addd351a6e7bd6aeb8 (diff)
parenteda7f7788ea8012bd8be46405c56a666c11f3fa5 (diff)
Merge pull request #365 from engelsystem/feature-igel-rewrite
Feature igel rewrite
Diffstat (limited to 'tests/Unit/Renderer/RendererTest.php')
-rw-r--r--tests/Unit/Renderer/RendererTest.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/Unit/Renderer/RendererTest.php b/tests/Unit/Renderer/RendererTest.php
new file mode 100644
index 00000000..969ced7f
--- /dev/null
+++ b/tests/Unit/Renderer/RendererTest.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Renderer;
+
+use Engelsystem\Renderer\EngineInterface;
+use Engelsystem\Renderer\Renderer;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Psr\Log\LoggerInterface;
+
+class RendererTest extends TestCase
+{
+ public function testGet()
+ {
+ $renderer = new Renderer();
+
+ /** @var MockObject|EngineInterface $nullRenderer */
+ $nullRenderer = $this->getMockForAbstractClass(EngineInterface::class);
+
+ $nullRenderer->expects($this->atLeastOnce())
+ ->method('canRender')
+ ->willReturn(false);
+ $renderer->addRenderer($nullRenderer);
+
+ /** @var MockObject|EngineInterface $mockRenderer */
+ $mockRenderer = $this->getMockForAbstractClass(EngineInterface::class);
+
+ $mockRenderer->expects($this->atLeastOnce())
+ ->method('canRender')
+ ->with('foo.template')
+ ->willReturn(true);
+
+ $mockRenderer->expects($this->atLeastOnce())
+ ->method('get')
+ ->with('foo.template', ['lorem' => 'ipsum'])
+ ->willReturn('Rendered content');
+
+ $renderer->addRenderer($mockRenderer);
+ $data = $renderer->render('foo.template', ['lorem' => 'ipsum']);
+
+ $this->assertEquals('Rendered content', $data);
+ }
+
+ public function testError()
+ {
+ $renderer = new Renderer();
+
+ /** @var MockObject|LoggerInterface $loggerMock */
+ $loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
+ $loggerMock
+ ->expects($this->once())
+ ->method('error');
+
+ $renderer->setLogger($loggerMock);
+
+ $data = $renderer->render('testing.template');
+ $this->assertEquals('', $data);
+ }
+}