Completed
Push — master ( cfaf77...b5ed7c )
by Kamil
47:11 queued 29:42
created

ChannelBasedPriceHelperSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 4
dl 0
loc 44
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 6 1
A it_is_initializable() 0 4 1
A it_is_helper() 0 4 1
A it_implements_channel_based_price_helper_interface() 0 4 1
A it_returns_variant_price_for_current_channel() 0 14 1
A it_has_name() 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\Templating\Helper;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Bundle\CoreBundle\Templating\Helper\ChannelBasedPriceHelper;
16
use Sylius\Bundle\CoreBundle\Templating\Helper\ChannelBasedPriceHelperInterface;
17
use Sylius\Component\Core\Calculator\ProductVariantPriceCalculatorInterface;
18
use Sylius\Component\Core\Model\ChannelInterface;
19
use Sylius\Component\Core\Model\OrderInterface;
20
use Sylius\Component\Core\Model\ProductVariantInterface;
21
use Sylius\Component\Order\Context\CartContextInterface;
22
use Symfony\Component\Templating\Helper\Helper;
23
24
/**
25
 * @author Mateusz Zalewski <[email protected]>
26
 */
27
final class ChannelBasedPriceHelperSpec extends ObjectBehavior
28
{
29
    function let(
30
        CartContextInterface $cartContext,
31
        ProductVariantPriceCalculatorInterface $productVariantPriceCalculator
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $productVariantPriceCalculator 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...
32
    ) {
33
        $this->beConstructedWith($cartContext, $productVariantPriceCalculator);
34
    }
35
36
    function it_is_initializable()
37
    {
38
        $this->shouldHaveType(ChannelBasedPriceHelper::class);
39
    }
40
41
    function it_is_helper()
42
    {
43
        $this->shouldHaveType(Helper::class);
44
    }
45
46
    function it_implements_channel_based_price_helper_interface()
47
    {
48
        $this->shouldImplement(ChannelBasedPriceHelperInterface::class);
49
    }
50
51
    function it_returns_variant_price_for_current_channel(
52
        CartContextInterface $cartContext,
53
        ChannelInterface $currentChannel,
54
        OrderInterface $currentCart,
55
        ProductVariantInterface $productVariant,
56
        ProductVariantPriceCalculatorInterface $productVariantPriceCalculator
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $productVariantPriceCalculator 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...
57
    ) {
58
        $cartContext->getCart()->willReturn($currentCart);
59
        $currentCart->getChannel()->willReturn($currentChannel);
60
61
        $productVariantPriceCalculator->calculate($productVariant, ['channel' => $currentChannel])->willReturn(1000);
62
63
        $this->getPriceForCurrentChannel($productVariant)->shouldReturn(1000);
64
    }
65
66
    function it_has_name()
67
    {
68
        $this->getName()->shouldReturn('sylius_channel_variant_price');
69
    }
70
}
71