Completed
Push — master ( eeff33...1702a2 )
by Kamil
41:57 queued 20:40
created

ChannelContextSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 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\Behat\Context\Transform;
13
14
use Behat\Behat\Context\Context;
15
use PhpSpec\ObjectBehavior;
16
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
17
use Sylius\Component\Core\Model\ChannelInterface;
18
19
/**
20
 * @author Łukasz Chruściel <[email protected]>
21
 */
22
class ChannelContextSpec extends ObjectBehavior
23
{
24
    function let(
25
        ChannelRepositoryInterface $channelRepository
26
    ) {
27
        $this->beConstructedWith(
28
            $channelRepository
29
        );
30
    }
31
32
    function it_is_initializable()
33
    {
34
        $this->shouldHaveType('Sylius\Behat\Context\Transform\ChannelContext');
35
    }
36
37
    function it_implements_context_interface()
38
    {
39
        $this->shouldImplement(Context::class);
40
    }
41
42
    function it_transforms_channel_name_to_channel_object(
43
        ChannelRepositoryInterface $channelRepository,
44
        ChannelInterface $channel
45
    ) {
46
        $channelRepository->findOneBy(['name' => 'Store'])->willReturn($channel);
47
48
        $this->getChannelByName('Store')->shouldReturn($channel);
49
    }
50
51
    function it_throws_an_exception_if_channel_is_not_found(
52
        ChannelRepositoryInterface $channelRepository
53
    ) {
54
        $channelRepository->findOneBy(['name' => 'Store'])->willReturn(null);
55
56
        $this->shouldThrow(new \InvalidArgumentException('Channel with name "Store" does not exist'))->during('getChannelByName', ['Store']);
57
    }
58
}
59