2017-10-31 13:40:13 +01:00
|
|
|
<?php
|
|
|
|
|
2017-10-31 14:23:23 +01:00
|
|
|
namespace Engelsystem\Test\Unit\Renderer;
|
2017-10-31 13:40:13 +01:00
|
|
|
|
|
|
|
use Engelsystem\Renderer\EngineInterface;
|
|
|
|
use Engelsystem\Renderer\HtmlEngine;
|
|
|
|
use Engelsystem\Renderer\Renderer;
|
|
|
|
use Engelsystem\Renderer\RendererServiceProvider;
|
|
|
|
use Engelsystem\Test\Unit\ServiceProviderTest;
|
2019-04-24 10:45:00 +02:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2017-10-31 13:40:13 +01:00
|
|
|
|
|
|
|
class RendererServiceProviderTest extends ServiceProviderTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Renderer\RendererServiceProvider::register()
|
|
|
|
* @covers \Engelsystem\Renderer\RendererServiceProvider::registerHtmlEngine()
|
2019-04-24 11:01:37 +02:00
|
|
|
* @covers \Engelsystem\Renderer\RendererServiceProvider::registerRenderer()
|
2017-10-31 13:40:13 +01:00
|
|
|
*/
|
|
|
|
public function testRegister()
|
|
|
|
{
|
2019-04-24 10:45:00 +02:00
|
|
|
/** @var Renderer|MockObject $renderer */
|
2017-10-31 13:40:13 +01:00
|
|
|
$renderer = $this->getMockBuilder(Renderer::class)
|
|
|
|
->getMock();
|
2019-04-24 10:45:00 +02:00
|
|
|
/** @var HtmlEngine|MockObject $htmlEngine */
|
2017-10-31 13:40:13 +01:00
|
|
|
$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
|
|
|
|
);
|
|
|
|
|
2018-08-29 13:58:50 +02:00
|
|
|
$app->expects($this->exactly(4))
|
2017-10-31 13:40:13 +01:00
|
|
|
->method('instance')
|
|
|
|
->withConsecutive(
|
2018-08-29 13:58:50 +02:00
|
|
|
[Renderer::class, $renderer],
|
2017-10-31 13:40:13 +01:00
|
|
|
['renderer', $renderer],
|
2018-08-29 13:58:50 +02:00
|
|
|
[HtmlEngine::class, $htmlEngine],
|
2017-10-31 13:40:13 +01:00
|
|
|
['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()
|
|
|
|
{
|
2019-04-24 10:45:00 +02:00
|
|
|
/** @var Renderer|MockObject $renderer */
|
2017-10-31 13:40:13 +01:00
|
|
|
$renderer = $this->getMockBuilder(Renderer::class)
|
|
|
|
->getMock();
|
2019-04-24 10:45:00 +02:00
|
|
|
/** @var EngineInterface|MockObject $engine1 */
|
2017-10-31 13:40:13 +01:00
|
|
|
$engine1 = $this->getMockForAbstractClass(EngineInterface::class);
|
2019-04-24 10:45:00 +02:00
|
|
|
/** @var EngineInterface|MockObject $engine2 */
|
2017-10-31 13:40:13 +01:00
|
|
|
$engine2 = $this->getMockForAbstractClass(EngineInterface::class);
|
|
|
|
|
|
|
|
$app = $this->getApp(['get', 'tagged']);
|
|
|
|
|
|
|
|
$this->setExpects($app, 'get', ['renderer'], $renderer);
|
2019-09-17 22:16:53 +02:00
|
|
|
$this->setExpects($app, 'tagged', ['renderer.engine'], [$engine1, $engine2]);
|
2017-10-31 13:40:13 +01:00
|
|
|
|
2019-09-17 22:16:53 +02:00
|
|
|
$renderer
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->method('addRenderer')
|
|
|
|
->withConsecutive([$engine1], [$engine2]);
|
2017-10-31 13:40:13 +01:00
|
|
|
|
|
|
|
$serviceProvider = new RendererServiceProvider($app);
|
|
|
|
$serviceProvider->boot();
|
|
|
|
}
|
|
|
|
}
|