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