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