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