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

HostnameBasedRequestResolverSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 35
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_implements_request_resolver_interface() 0 4 1
A it_finds_the_channel_by_request_hostname() 0 11 1
A it_returns_null_if_channel_was_not_found() 0 10 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
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