Completed
Push — master ( 4207f0...333332 )
by Kamil
23:19 queued 01:42
created

it_implements_theme_context_interface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
dl 0
loc 4
rs 10
c 3
b 0
f 1
cc 1
eloc 2
nc 1
nop 0
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
namespace spec\Sylius\Bundle\ThemeBundle\Context;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\ThemeBundle\Context\ThemeContext;
17
use Sylius\Bundle\ThemeBundle\Context\ThemeContextInterface;
18
use Sylius\Bundle\ThemeBundle\HierarchyProvider\ThemeHierarchyProviderInterface;
19
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
20
21
/**
22
 * @mixin ThemeContext
23
 *
24
 * @author Kamil Kokot <[email protected]>
25
 */
26
class ThemeContextSpec extends ObjectBehavior
27
{
28
    function let(ThemeHierarchyProviderInterface $themeHierarchyProvider)
29
    {
30
        $this->beConstructedWith($themeHierarchyProvider);
31
    }
32
33
    function it_is_initializable()
34
    {
35
        $this->shouldHaveType('Sylius\Bundle\ThemeBundle\Context\ThemeContext');
36
    }
37
38
    function it_implements_theme_context_interface()
39
    {
40
        $this->shouldImplement(ThemeContextInterface::class);
41
    }
42
43
    function it_has_theme(ThemeInterface $theme)
44
    {
45
        $this->getTheme()->shouldReturn(null);
46
47
        $this->setTheme($theme);
48
        $this->getTheme()->shouldReturn($theme);
49
    }
50
51
    function it_proxies_getting_theme_hierarchy_if_there_is_current_theme(
52
        ThemeHierarchyProviderInterface $themeHierarchyProvider,
53
        ThemeInterface $theme
54
    ) {
55
        $this->setTheme($theme);
56
        $themeHierarchyProvider->getThemeHierarchy($theme)->willReturn([$theme]);
57
58
        $this->getThemeHierarchy()->shouldReturn([$theme]);
59
    }
60
61
    function it_returns_an_empty_array_as_theme_hierarchy_if_there_is_no_current_theme(
62
        ThemeHierarchyProviderInterface $themeHierarchyProvider
63
    ) {
64
        $themeHierarchyProvider->getThemeHierarchy(Argument::any())->shouldNotBeCalled();
65
66
        $this->getThemeHierarchy()->shouldReturn([]);
67
    }
68
}
69