Completed
Push — master ( 60f5be...0d3c0c )
by Kamil
24:02
created

CurrencyContextSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 36
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_Sylius_currency_context_interface() 0 4 1
A it_gets_default_currency_code() 0 4 1
A it_gets_currency_code_from_session() 0 6 1
A it_sets_currency_code_to_session() 0 6 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\Component\Currency\Context;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Currency\Context\CurrencyContextInterface;
16
use Sylius\Component\Storage\StorageInterface;
17
18
class CurrencyContextSpec extends ObjectBehavior
19
{
20
    function let(StorageInterface $storage)
21
    {
22
        $this->beConstructedWith($storage, 'EUR');
23
    }
24
25
    function it_is_initializable()
26
    {
27
        $this->shouldHaveType('Sylius\Component\Currency\Context\CurrencyContext');
28
    }
29
30
    function it_implements_Sylius_currency_context_interface()
31
    {
32
        $this->shouldImplement(CurrencyContextInterface::class);
33
    }
34
35
    function it_gets_default_currency_code()
36
    {
37
        $this->getDefaultCurrencyCode()->shouldReturn('EUR');
38
    }
39
40
    function it_gets_currency_code_from_session($storage)
41
    {
42
        $storage->getData(CurrencyContextInterface::STORAGE_KEY, 'EUR')->willReturn('RSD');
43
44
        $this->getCurrencyCode()->shouldReturn('RSD');
45
    }
46
47
    function it_sets_currency_code_to_session($storage)
48
    {
49
        $storage->setData(CurrencyContextInterface::STORAGE_KEY, 'PLN')->shouldBeCalled();
50
51
        $this->setCurrencyCode('PLN');
52
    }
53
}
54