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
|
|
|
|