Completed
Push — master ( 994ba8...dbff07 )
by Kamil
19:19
created

PerUnitRateCalculatorSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 32
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_should_implement_Sylius_shipping_calculator_interface() 0 4 1
A it_returns_per_unit_type() 0 4 1
A it_should_calculate_the_total_with_the_per_unit_amount_configured_on_the_method() 0 7 1
A its_calculated_value_should_be_an_integer() 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\Shipping\Calculator;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Shipping\Calculator\CalculatorInterface;
16
use Sylius\Component\Shipping\Model\ShippingSubjectInterface;
17
18
/**
19
 * @author Paweł Jędrzejewski <[email protected]>
20
 */
21
class PerUnitRateCalculatorSpec extends ObjectBehavior
22
{
23
    function it_is_initializable()
24
    {
25
        $this->shouldHaveType('Sylius\Component\Shipping\Calculator\PerUnitRateCalculator');
26
    }
27
28
    function it_should_implement_Sylius_shipping_calculator_interface()
29
    {
30
        $this->shouldImplement(CalculatorInterface::class);
31
    }
32
33
    function it_returns_per_unit_type()
34
    {
35
        $this->getType()->shouldReturn('per_unit_rate');
36
    }
37
38
    function it_should_calculate_the_total_with_the_per_unit_amount_configured_on_the_method(
39
        ShippingSubjectInterface $subject
40
    ) {
41
        $subject->getShippingUnitCount()->willReturn(11);
42
43
        $this->calculate($subject, ['amount' => 200])->shouldReturn(2200);
44
    }
45
46
    function its_calculated_value_should_be_an_integer(ShippingSubjectInterface $subject)
47
    {
48
        $subject->getShippingUnitCount()->willReturn(6);
49
50
        $this->calculate($subject, ['amount' => 200])->shouldBeInteger();
51
    }
52
}
53