Completed
Push — master ( 52cd2c...047880 )
by Kamil
47:26 queued 26:32
created

TemplateEventRendererSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 38
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_a_template_event_renderer() 0 4 1
A it_renders_template_events() 0 14 1
A it_returns_an_empty_string_if_no_blocks_are_found_for_an_event() 0 10 1
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