Completed
Push — master ( 2f9340...094334 )
by Kamil
17:24
created

ChannelContextSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 5
c 4
b 1
f 0
lcom 0
cbo 2
dl 0
loc 59
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 13 1
A it_is_initializable() 0 4 1
A it_implements_context_interface() 0 4 1
A it_sets_default_channel_in_the_shared_storage() 0 12 1
A it_configures_shipping_destination_countries() 0 19 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\Setup;
13
14
use Behat\Behat\Context\Context;
15
use PhpSpec\ObjectBehavior;
16
use Sylius\Component\Addressing\Model\CountryInterface;
17
use Sylius\Component\Addressing\Model\ZoneInterface;
18
use Sylius\Component\Core\Model\ChannelInterface;
19
use Sylius\Component\Core\Test\Services\DefaultStoreDataInterface;
20
use Sylius\Component\Core\Test\Services\SharedStorageInterface;
21
use Sylius\Component\Resource\Factory\FactoryInterface;
22
use Sylius\Component\Resource\Repository\RepositoryInterface;
23
24
/**
25
 * @author Arkadiusz Krakowiak <[email protected]>
26
 */
27
class ChannelContextSpec extends ObjectBehavior
28
{
29
    function let(
30
        SharedStorageInterface $sharedStorage,
31
        DefaultStoreDataInterface $defaultFranceChannelFactory,
32
        FactoryInterface $countryFactory,
33
        RepositoryInterface $countryRepository
34
    ) {
35
        $this->beConstructedWith(
36
            $sharedStorage,
37
            $defaultFranceChannelFactory,
38
            $countryFactory,
39
            $countryRepository
40
        );
41
    }
42
43
    function it_is_initializable()
44
    {
45
        $this->shouldHaveType('Sylius\Behat\Context\Setup\ChannelContext');
46
    }
47
48
    function it_implements_context_interface()
49
    {
50
        $this->shouldImplement(Context::class);
51
    }
52
53
    function it_sets_default_channel_in_the_shared_storage(
54
        $defaultFranceChannelFactory,
55
        $sharedStorage,
56
        ChannelInterface $channel,
57
        ZoneInterface $zone
58
    ) {
59
        $defaultData = ['channel' => $channel, 'zone' => $zone];
60
        $defaultFranceChannelFactory->create()->willReturn($defaultData);
61
        $sharedStorage->setClipboard($defaultData)->shouldBeCalled();
62
63
        $this->thatStoreIsOperatingOnASingleChannel();
64
    }
65
66
    function it_configures_shipping_destination_countries(
67
        $countryFactory,
68
        $countryRepository,
69
        CountryInterface $australia,
70
        CountryInterface $china,
71
        CountryInterface $france
72
    ) {
73
        $countryFactory->createNew()->willReturn($australia, $china, $france);
74
75
        $australia->setCode('AU')->shouldBeCalled();
76
        $china->setCode('CN')->shouldBeCalled();
77
        $france->setCode('FR')->shouldBeCalled();
78
79
        $countryRepository->add($australia)->shouldBeCalled();
80
        $countryRepository->add($china)->shouldBeCalled();
81
        $countryRepository->add($france)->shouldBeCalled();
82
83
        $this->storeShipsTo('Australia', 'China', 'France');
84
    }
85
}
86