Completed
Push — master ( 860366...55daec )
by Kamil
19:37
created

DefaultChannelFactorySpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
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\Component\Core\Test\Services;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Channel\Factory\ChannelFactoryInterface;
16
use Sylius\Component\Core\Model\ChannelInterface;
17
use Sylius\Component\Core\Test\Services\DefaultChannelFactoryInterface;
18
use Sylius\Component\Resource\Repository\RepositoryInterface;
19
20
/**
21
 * @author Mateusz Zalewski <[email protected]>
22
 */
23
class DefaultChannelFactorySpec extends ObjectBehavior
24
{
25
    function let(ChannelFactoryInterface $channelFactory, RepositoryInterface $channelRepository)
26
    {
27
        $this->beConstructedWith($channelFactory, $channelRepository);
28
    }
29
30
    function it_is_initializable()
31
    {
32
        $this->shouldHaveType('Sylius\Component\Core\Test\Services\DefaultChannelFactory');
33
    }
34
35
    function it_implements_default_channel_factory_interface()
36
    {
37
        $this->shouldImplement(DefaultChannelFactoryInterface::class);
38
    }
39
40
    function it_creates_default_channel_and_persist_it(
41
        $channelFactory,
42
        $channelRepository,
43
        ChannelInterface $channel
44
    ) {
45
        $channelFactory->createNamed('Default')->willReturn($channel);
46
47
        $channel->setCode('DEFAULT')->shouldBeCalled();
48
        $channelRepository->add($channel)->shouldBeCalled();
49
50
        $this->create()->shouldReturn(['channel' => $channel]);
51
    }
52
}
53