Completed
Push — master ( 9cae3f...77cc4b )
by Kamil
74:02 queued 42:22
created

ShopperContextSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 0
cbo 5
dl 0
loc 48
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 8 1
A it_implements_a_shopper_context_interface() 0 4 1
A it_gets_a_current_channel_from_a_context() 0 8 1
A it_gets_a_current_currency_code_from_a_context() 0 6 1
A it_gets_a_current_locale_code_from_a_context() 0 6 1
A it_gets_a_current_customer_from_a_context() 0 8 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\Core\Context;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Channel\Context\ChannelContextInterface;
18
use Sylius\Component\Core\Context\ShopperContextInterface;
19
use Sylius\Component\Core\Model\ChannelInterface;
20
use Sylius\Component\Core\Model\CustomerInterface;
21
use Sylius\Component\Currency\Context\CurrencyContextInterface;
22
use Sylius\Component\Customer\Context\CustomerContextInterface;
23
use Sylius\Component\Locale\Context\LocaleContextInterface;
24
25
/**
26
 * @author Paweł Jędrzejewski <[email protected]>
27
 */
28
final class ShopperContextSpec extends ObjectBehavior
29
{
30
    function let(
31
        ChannelContextInterface $channelContext,
32
        CurrencyContextInterface $currencyContext,
33
        LocaleContextInterface $localeContext,
34
        CustomerContextInterface $customerContext
35
    ): void {
36
        $this->beConstructedWith($channelContext, $currencyContext, $localeContext, $customerContext);
37
    }
38
39
    function it_implements_a_shopper_context_interface(): void
40
    {
41
        $this->shouldImplement(ShopperContextInterface::class);
42
    }
43
44
    function it_gets_a_current_channel_from_a_context(
45
        ChannelContextInterface $channelContext,
46
        ChannelInterface $channel
47
    ): void {
48
        $channelContext->getChannel()->willReturn($channel);
49
50
        $this->getChannel()->shouldReturn($channel);
51
    }
52
53
    function it_gets_a_current_currency_code_from_a_context(CurrencyContextInterface $currencyContext): void
54
    {
55
        $currencyContext->getCurrencyCode()->willReturn('USD');
56
57
        $this->getCurrencyCode()->shouldReturn('USD');
58
    }
59
60
    function it_gets_a_current_locale_code_from_a_context(LocaleContextInterface $localeContext): void
61
    {
62
        $localeContext->getLocaleCode()->willReturn('en_US');
63
64
        $this->getLocaleCode()->shouldReturn('en_US');
65
    }
66
67
    function it_gets_a_current_customer_from_a_context(
68
        CustomerContextInterface $customerContext,
69
        CustomerInterface $customer
70
    ): void {
71
        $customerContext->getCustomer()->willReturn($customer);
72
73
        $this->getCustomer()->shouldReturn($customer);
74
    }
75
}
76