Completed
Push — scalar-types/currency ( d4a290...08e1db )
by Kamil
25:05 queued 02:52
created

it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
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
declare(strict_types=1);
13
14
namespace spec\Sylius\Component\Channel\Context\RequestBased;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Channel\Context\RequestBased\RequestResolverInterface;
18
use Sylius\Component\Channel\Model\ChannelInterface;
19
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
20
use Symfony\Component\HttpFoundation\Request;
21
22
/**
23
 * @author Kamil Kokot <[email protected]>
24
 */
25
final class HostnameBasedRequestResolverSpec extends ObjectBehavior
26
{
27
    function let(ChannelRepositoryInterface $channelRepository): void
28
    {
29
        $this->beConstructedWith($channelRepository);
30
    }
31
32
    function it_implements_request_resolver_interface(): void
33
    {
34
        $this->shouldImplement(RequestResolverInterface::class);
35
    }
36
37
    function it_finds_the_channel_by_request_hostname(
38
        ChannelRepositoryInterface $channelRepository,
39
        Request $request,
40
        ChannelInterface $channel
41
    ): void {
42
        $request->getHost()->willReturn('example.org');
43
44
        $channelRepository->findOneByHostname('example.org')->willReturn($channel);
45
46
        $this->findChannel($request)->shouldReturn($channel);
47
    }
48
49
    function it_returns_null_if_channel_was_not_found(
50
        ChannelRepositoryInterface $channelRepository,
51
        Request $request
52
    ): void {
53
        $request->getHost()->willReturn('example.org');
54
55
        $channelRepository->findOneByHostname('example.org')->willReturn(null);
56
57
        $this->findChannel($request)->shouldReturn(null);
58
    }
59
}
60