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

TemplateBlockRegistrySpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 32
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_registry() 0 4 1
A it_returns_all_template_blocks() 0 8 1
A it_returns_enabled_template_blocks_for_a_given_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\Registry;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Bundle\UiBundle\Registry\TemplateBlock;
18
use Sylius\Bundle\UiBundle\Registry\TemplateBlockRegistryInterface;
19
20
final class TemplateBlockRegistrySpec extends ObjectBehavior
21
{
22
    function let(): void
23
    {
24
        $this->beConstructedWith([]);
25
    }
26
27
    function it_is_a_template_block_registry(): void
28
    {
29
        $this->shouldImplement(TemplateBlockRegistryInterface::class);
30
    }
31
32
    function it_returns_all_template_blocks(): void
33
    {
34
        $templateBlock = new TemplateBlock('block_name', 'block.html.twig', [], 10, true);
35
36
        $this->beConstructedWith(['event' => [$templateBlock]]);
37
38
        $this->all()->shouldReturn(['event' => [$templateBlock]]);
39
    }
40
41
    function it_returns_enabled_template_blocks_for_a_given_event(): void
42
    {
43
        $firstTemplateBlock = new TemplateBlock('first_block', 'first.html.twig', [], 0, true);
44
        $secondTemplateBlock = new TemplateBlock('second_block', 'second.html.twig', [], 10, false);
45
        $thirdTemplateBlock = new TemplateBlock('third_block', 'third.html.twig', [], 50, true);
46
47
        $this->beConstructedWith(['event' => [$firstTemplateBlock, $secondTemplateBlock], 'another_event' => [$thirdTemplateBlock]]);
48
49
        $this->findEnabledForEvent('event')->shouldReturn([$firstTemplateBlock]);
50
    }
51
}
52