Completed
Push — template-events-system ( 9bf74a...bcfbd4 )
by Kamil
04:53
created

TemplateBlockRendererSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 52
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_a_template_block_renderer() 0 4 1
A it_renders_a_template_block() 0 10 1
A it_renders_html_debug_comment_prepending_the_comment_if_in_debug_mode_rendering_html_template() 0 15 1
A it_renders_html_debug_comment_prepending_the_comment_if_not_in_debug_mode_rendering_html_template() 0 12 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 Sylius\Bundle\UiBundle\Registry\TemplateBlock;
18
use Sylius\Bundle\UiBundle\Renderer\TemplateBlockRendererInterface;
19
use Twig\Environment;
20
21
final class TemplateBlockRendererSpec extends ObjectBehavior
22
{
23
    function let(Environment $twig): void
24
    {
25
        $this->beConstructedWith($twig, true);
26
    }
27
28
    function it_is_a_template_block_renderer(): void
29
    {
30
        $this->shouldImplement(TemplateBlockRendererInterface::class);
31
    }
32
33
    function it_renders_a_template_block(Environment $twig): void
34
    {
35
        $twig->render('block.txt.twig', ['foo' => 'bar'])->willReturn('Block content');
36
37
        $this->render(
38
            'event_name',
39
            new TemplateBlock('block_name', 'block.txt.twig', 0, true),
40
            ['foo' => 'bar']
41
        )->shouldReturn('Block content');
42
    }
43
44
    function it_renders_html_debug_comment_prepending_the_comment_if_in_debug_mode_rendering_html_template(Environment $twig): void
45
    {
46
        $this->beConstructedWith($twig, true);
47
48
        $twig->render('block.html.twig', ['foo' => 'bar'])->willReturn('Block content');
49
50
        $this->render(
51
            'event_name',
52
            new TemplateBlock('block_name', 'block.html.twig', 0, true),
53
            ['foo' => 'bar']
54
        )->shouldReturn(
55
            '<!-- event name: "event_name", block name: "block_name", template: "block.html.twig", priority: 0 -->' . "\n" .
56
            'Block content'
57
        );
58
    }
59
60
    function it_renders_html_debug_comment_prepending_the_comment_if_not_in_debug_mode_rendering_html_template(Environment $twig): void
61
    {
62
        $this->beConstructedWith($twig, false);
63
64
        $twig->render('block.html.twig', ['foo' => 'bar'])->willReturn('Block content');
65
66
        $this->render(
67
            'event_name',
68
            new TemplateBlock('block_name', 'block.html.twig', 0, true),
69
            ['foo' => 'bar']
70
        )->shouldReturn('Block content');
71
    }
72
}
73