Completed
Push — master ( 155c16...880d18 )
by Kamil
26:05
created

ChannelBasedThemeContextSpec   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 7
lcom 0
cbo 3
dl 0
loc 54
rs 10
c 3
b 1
f 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_theme_context_interface() 0 4 1
A it_returns_a_theme() 0 10 1
A it_returns_null_if_channel_has_no_theme() 0 9 1
A it_returns_null_if_there_is_no_channel() 0 7 1
A it_returns_null_if_any_exception_is_thrown_during_getting_the_channel() 0 7 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
namespace spec\Sylius\Component\Core\Theme;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\ThemeBundle\Context\ThemeContextInterface;
17
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
18
use Sylius\Bundle\ThemeBundle\Repository\ThemeRepositoryInterface;
19
use Sylius\Component\Channel\Context\ChannelContextInterface;
20
use Sylius\Component\Channel\Context\ChannelNotFoundException;
21
use Sylius\Component\Core\Model\ChannelInterface;
22
use Sylius\Component\Core\Theme\ChannelBasedThemeContext;
23
24
/**
25
 * @mixin ChannelBasedThemeContext
26
 *
27
 * @author Kamil Kokot <[email protected]>
28
 */
29
class ChannelBasedThemeContextSpec extends ObjectBehavior
30
{
31
    function let(ChannelContextInterface $channelContext)
32
    {
33
        $this->beConstructedWith($channelContext);
34
    }
35
36
    function it_is_initializable()
37
    {
38
        $this->shouldHaveType('Sylius\Component\Core\Theme\ChannelBasedThemeContext');
39
    }
40
41
    function it_implements_theme_context_interface()
42
    {
43
        $this->shouldImplement(ThemeContextInterface::class);
44
    }
45
46
    function it_returns_a_theme(
47
        ChannelContextInterface $channelContext,
48
        ChannelInterface $channel,
49
        ThemeInterface $theme
50
    ) {
51
        $channelContext->getChannel()->willReturn($channel);
52
        $channel->getTheme()->willReturn($theme);
53
54
        $this->getTheme()->shouldReturn($theme);
55
    }
56
57
    function it_returns_null_if_channel_has_no_theme(
58
        ChannelContextInterface $channelContext,
59
        ChannelInterface $channel
60
    ) {
61
        $channelContext->getChannel()->willReturn($channel);
62
        $channel->getTheme()->willReturn(null);
63
64
        $this->getTheme()->shouldReturn(null);
65
    }
66
67
    function it_returns_null_if_there_is_no_channel(
68
        ChannelContextInterface $channelContext
69
    ) {
70
        $channelContext->getChannel()->willThrow(ChannelNotFoundException::class);
71
72
        $this->getTheme()->shouldReturn(null);
73
    }
74
75
    function it_returns_null_if_any_exception_is_thrown_during_getting_the_channel(
76
        ChannelContextInterface $channelContext
77
    ) {
78
        $channelContext->getChannel()->willThrow(\Exception::class);
79
80
        $this->getTheme()->shouldReturn(null);
81
    }
82
}
83