summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-10-31 13:40:13 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-10-31 13:40:13 +0100
commit60fd72cd1a1e4e53b9af87e00a8c27687c6b5385 (patch)
treebcf250d05a49a848644af44f09fb897467e3ecb0 /tests/Unit/Renderer
parentfb05a38a963784716c105e7f214615ad13d2f272 (diff)
Added service providers
Diffstat (limited to 'tests/Unit/Renderer')
-rw-r--r--tests/Unit/Renderer/RendererServiceProviderTest.php81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/Unit/Renderer/RendererServiceProviderTest.php b/tests/Unit/Renderer/RendererServiceProviderTest.php
new file mode 100644
index 00000000..f9044d8b
--- /dev/null
+++ b/tests/Unit/Renderer/RendererServiceProviderTest.php
@@ -0,0 +1,81 @@
+<?php
+
+namespace Engelsystem\Test\Logger;
+
+use Engelsystem\Renderer\EngineInterface;
+use Engelsystem\Renderer\HtmlEngine;
+use Engelsystem\Renderer\Renderer;
+use Engelsystem\Renderer\RendererServiceProvider;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject;
+
+class RendererServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Renderer\RendererServiceProvider::register()
+ * @covers \Engelsystem\Renderer\RendererServiceProvider::registerRenderer()
+ * @covers \Engelsystem\Renderer\RendererServiceProvider::registerHtmlEngine()
+ */
+ public function testRegister()
+ {
+ /** @var PHPUnit_Framework_MockObject_MockObject|Renderer $renderer */
+ $renderer = $this->getMockBuilder(Renderer::class)
+ ->getMock();
+ /** @var PHPUnit_Framework_MockObject_MockObject|HtmlEngine $htmlEngine */
+ $htmlEngine = $this->getMockBuilder(HtmlEngine::class)
+ ->getMock();
+
+ $app = $this->getApp(['make', 'instance', 'tag']);
+
+ $app->expects($this->exactly(2))
+ ->method('make')
+ ->withConsecutive(
+ [Renderer::class],
+ [HtmlEngine::class]
+ )->willReturnOnConsecutiveCalls(
+ $renderer,
+ $htmlEngine
+ );
+
+ $app->expects($this->exactly(2))
+ ->method('instance')
+ ->withConsecutive(
+ ['renderer', $renderer],
+ ['renderer.htmlEngine', $htmlEngine]
+ );
+
+ $this->setExpects($app, 'tag', ['renderer.htmlEngine', ['renderer.engine']]);
+
+ $serviceProvider = new RendererServiceProvider($app);
+ $serviceProvider->register();
+ }
+
+ /**
+ * @covers \Engelsystem\Renderer\RendererServiceProvider::boot()
+ */
+ public function testBoot()
+ {
+ /** @var PHPUnit_Framework_MockObject_MockObject|Renderer $renderer */
+ $renderer = $this->getMockBuilder(Renderer::class)
+ ->getMock();
+ /** @var PHPUnit_Framework_MockObject_MockObject|EngineInterface $engine1 */
+ $engine1 = $this->getMockForAbstractClass(EngineInterface::class);
+ /** @var PHPUnit_Framework_MockObject_MockObject|EngineInterface $engine2 */
+ $engine2 = $this->getMockForAbstractClass(EngineInterface::class);
+
+ $app = $this->getApp(['get', 'tagged']);
+
+ $engines = [$engine1, $engine2];
+
+ $this->setExpects($app, 'get', ['renderer'], $renderer);
+ $this->setExpects($app, 'tagged', ['renderer.engine'], $engines);
+
+ $invocation = $renderer
+ ->expects($this->exactly(count($engines)))
+ ->method('addRenderer');
+ call_user_func_array([$invocation, 'withConsecutive'], $engines);
+
+ $serviceProvider = new RendererServiceProvider($app);
+ $serviceProvider->boot();
+ }
+}