1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace spec\Sylius\Bundle\UiBundle\Renderer; |
15
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
17
|
|
|
use Prophecy\Argument; |
18
|
|
|
use Sylius\Bundle\UiBundle\Registry\TemplateBlock; |
19
|
|
|
use Sylius\Bundle\UiBundle\Registry\TemplateBlockRegistryInterface; |
20
|
|
|
use Sylius\Bundle\UiBundle\Renderer\TemplateBlockRendererInterface; |
21
|
|
|
use Sylius\Bundle\UiBundle\Renderer\TemplateEventRendererInterface; |
22
|
|
|
|
23
|
|
|
final class TemplateEventRendererSpec extends ObjectBehavior |
24
|
|
|
{ |
25
|
|
|
function let(TemplateBlockRegistryInterface $templateBlockRegistry, TemplateBlockRendererInterface $templateBlockRenderer): void |
26
|
|
|
{ |
27
|
|
|
$this->beConstructedWith($templateBlockRegistry, $templateBlockRenderer); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function it_is_a_template_event_renderer(): void |
31
|
|
|
{ |
32
|
|
|
$this->shouldImplement(TemplateEventRendererInterface::class); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function it_renders_template_events( |
36
|
|
|
TemplateBlockRegistryInterface $templateBlockRegistry, |
37
|
|
|
TemplateBlockRendererInterface $templateBlockRenderer |
38
|
|
|
): void { |
39
|
|
|
$firstTemplateBlock = new TemplateBlock('first_block', 'firstBlock.txt.twig', [], 0, true); |
40
|
|
|
$secondTemplateBlock = new TemplateBlock('second_block', 'secondBlock.txt.twig', [], 0, true); |
41
|
|
|
|
42
|
|
|
$templateBlockRegistry->findEnabledForEvent('best_event_ever')->willReturn([$firstTemplateBlock, $secondTemplateBlock]); |
43
|
|
|
|
44
|
|
|
$templateBlockRenderer->render('best_event_ever', $firstTemplateBlock, ['foo' => 'bar'])->willReturn('First block'); |
45
|
|
|
$templateBlockRenderer->render('best_event_ever', $secondTemplateBlock, ['foo' => 'bar'])->willReturn('Second block'); |
46
|
|
|
|
47
|
|
|
$this->render('best_event_ever', ['foo' => 'bar'])->shouldReturn("First block\nSecond block"); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
function it_returns_an_empty_string_if_no_blocks_are_found_for_an_event( |
51
|
|
|
TemplateBlockRegistryInterface $templateBlockRegistry, |
52
|
|
|
TemplateBlockRendererInterface $templateBlockRenderer |
53
|
|
|
): void { |
54
|
|
|
$templateBlockRegistry->findEnabledForEvent('best_event_ever')->willReturn([]); |
55
|
|
|
|
56
|
|
|
$templateBlockRenderer->render(Argument::cetera())->shouldNotBeCalled(); |
57
|
|
|
|
58
|
|
|
$this->render('best_event_ever')->shouldReturn(''); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|