Completed
Push — symfony3-wololo-packages ( fecf70...6bf04d )
by Kamil
28:46 queued 11:35
created

FlatRateCalculatorSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 31
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_implements_shipping_calculator_interface() 0 4 1
A it_returns_flat_rate_type() 0 6 1
A it_calculates_the_flat_rate_amount_configured_on_the_method() 0 11 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\Core\Shipping\Calculator;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Core\Model\ChannelInterface;
16
use Sylius\Component\Core\Model\OrderInterface;
17
use Sylius\Component\Core\Model\ShipmentInterface;
18
use Sylius\Component\Core\Shipping\Calculator\FlatRateCalculator;
19
use Sylius\Component\Shipping\Calculator\CalculatorInterface;
20
21
/**
22
 * @author Grzegorz Sadowski <[email protected]>
23
 */
24
final class FlatRateCalculatorSpec extends ObjectBehavior
25
{
26
    function it_is_initializable()
27
    {
28
        $this->shouldHaveType(FlatRateCalculator::class);
29
    }
30
31
    function it_implements_shipping_calculator_interface()
32
    {
33
        $this->shouldImplement(CalculatorInterface::class);
34
    }
35
36
    function it_returns_flat_rate_type(CalculatorInterface $calculator)
37
    {
38
        $calculator->getType()->willReturn('flat_rate');
39
40
        $this->getType()->shouldReturn('flat_rate');
41
    }
42
43
    function it_calculates_the_flat_rate_amount_configured_on_the_method(
44
        ShipmentInterface $shipment,
45
        OrderInterface $order,
46
        ChannelInterface $channel
47
    ) {
48
        $shipment->getOrder()->willReturn($order);
49
        $order->getChannel()->willReturn($channel);
50
        $channel->getCode()->willReturn('WEB');
51
52
        $this->calculate($shipment, ['WEB' => ['amount' => 1500]])->shouldReturn(1500);
53
    }
54
}
55