Completed
Push — remove-content-bundle ( fd7705...1b4274 )
by Kamil
18:36
created

ChannelAndCurrencyPricingConfigurationTransformerSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_is_data_transformer() 0 4 1
A it_transforms_array_into_proper_calculator_configuration_array() 0 15 1
A it_transform_back_from_proper_calculator_configuration_to_flat_array() 0 13 1
A it_returns_empty_array_if_given_value_is_null() 0 4 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\Bundle\CoreBundle\Form\DataTransformer;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Bundle\CoreBundle\Form\DataTransformer\ChannelAndCurrencyPricingConfigurationTransformer;
16
use Symfony\Component\Form\DataTransformerInterface;
17
18
/**
19
 * @author Arkadiusz Krakowiak <[email protected]>
20
 */
21
final class ChannelAndCurrencyPricingConfigurationTransformerSpec extends ObjectBehavior
22
{
23
    function let()
24
    {
25
        $this->beConstructedWith('_');
26
    }
27
28
    function it_is_initializable()
29
    {
30
        $this->shouldHaveType(ChannelAndCurrencyPricingConfigurationTransformer::class);
31
    }
32
33
    function it_is_data_transformer()
34
    {
35
        $this->shouldImplement(DataTransformerInterface::class);
36
    }
37
38
    function it_transforms_array_into_proper_calculator_configuration_array()
39
    {
40
        $flatCalculatorConfiguration = ['Web_USD' => 1000, 'Web_EUR' => 2000, 'Mobile_USD' => 20000, 'Mobile_EUR' => 1400];
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $flatCalculatorConfiguration exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
41
42
        $this->reverseTransform($flatCalculatorConfiguration)->shouldReturn([
43
            'Web' => [
44
                'USD' => 1000,
45
                'EUR' => 2000,
46
            ],
47
            'Mobile' => [
48
                'USD' => 20000,
49
                'EUR' => 1400
50
            ],
51
        ]);
52
    }
53
54
    function it_transform_back_from_proper_calculator_configuration_to_flat_array()
55
    {
56
        $this->transform([
57
            'Web' => [
58
                'USD' => 1000,
59
                'EUR' => 2000,
60
            ],
61
            'Mobile' => [
62
                'USD' => 20000,
63
                'EUR' => 1400
64
            ],
65
        ])->shouldReturn(['Web_USD' => 1000, 'Web_EUR' => 2000, 'Mobile_USD' => 20000, 'Mobile_EUR' => 1400]);
66
    }
67
68
    function it_returns_empty_array_if_given_value_is_null()
69
    {
70
        $this->transform(null)->shouldReturn([]);
71
    }
72
}
73