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

PerUnitRateCalculatorSpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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