Completed
Push — master ( 047880...b09c02 )
by Kamil
92:08 queued 74:48
created

HtmlDebugTemplateBlockRendererSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 40
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_block_renderer() 0 4 1
A it_renders_html_debug_comment_prepending_the_block_if_rendering_html_template() 0 15 1
A it_does_not_render_html_debug_comment_prepending_the_block_if_rendering_non_html_template() 0 11 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\Renderer\TemplateBlockRendererInterface;
20
21
final class HtmlDebugTemplateBlockRendererSpec extends ObjectBehavior
22
{
23
    function let(TemplateBlockRendererInterface $templateBlockRenderer): void
24
    {
25
        $this->beConstructedWith($templateBlockRenderer);
26
    }
27
28
    function it_is_a_template_block_renderer(): void
29
    {
30
        $this->shouldImplement(TemplateBlockRendererInterface::class);
31
    }
32
33
    function it_renders_html_debug_comment_prepending_the_block_if_rendering_html_template(
34
        TemplateBlockRendererInterface $templateBlockRenderer
35
    ): void {
36
        $templateBlockRenderer->render('event_name', Argument::cetera())->willReturn('Block content');
37
38
        $this->render(
39
            'event_name',
40
            new TemplateBlock('block_name', 'block.html.twig', [], 0, true),
41
            ['foo' => 'bar']
42
        )->shouldReturn(
43
            '<!-- BEGIN BLOCK | event name: "event_name", block name: "block_name", template: "block.html.twig", priority: 0 -->' . "\n" .
44
            'Block content' . "\n" .
45
            '<!-- END BLOCK | event name: "event_name", block name: "block_name" -->'
46
        );
47
    }
48
49
    function it_does_not_render_html_debug_comment_prepending_the_block_if_rendering_non_html_template(
50
        TemplateBlockRendererInterface $templateBlockRenderer
51
    ): void {
52
        $templateBlockRenderer->render('event_name', Argument::cetera())->willReturn('Block content');
53
54
        $this->render(
55
            'event_name',
56
            new TemplateBlock('block_name', 'block.txt.twig', [], 0, true),
57
            ['foo' => 'bar']
58
        )->shouldReturn('Block content');
59
    }
60
}
61