Completed
Push — master ( 1671b1...4e9462 )
by Kamil
23:39
created

OrderRecalculatorSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 7 1
A it_is_initializable() 0 4 1
A it_implements_order_recalculator_interface() 0 4 1
A it_recalculates_order_promotions_taxes_and_shipping_charges() 0 12 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\OrderProcessing;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Core\Model\OrderInterface;
16
use Sylius\Component\Core\OrderProcessing\OrderRecalculator;
17
use Sylius\Component\Core\OrderProcessing\OrderRecalculatorInterface;
18
use Sylius\Component\Core\OrderProcessing\ShippingChargesProcessorInterface;
19
use Sylius\Component\Core\Taxation\OrderTaxesApplicatorInterface;
20
use Sylius\Component\Promotion\Processor\PromotionProcessorInterface;
21
22
/**
23
 * @mixin OrderRecalculator
24
 *
25
 * @author Jan Góralski <[email protected]>
26
 */
27
class OrderRecalculatorSpec extends ObjectBehavior
28
{
29
    function let(
30
        PromotionProcessorInterface $promotionProcessor,
31
        OrderTaxesApplicatorInterface $taxesApplicator,
32
        ShippingChargesProcessorInterface $shippingChargesProcessor
33
    ) {
34
        $this->beConstructedWith($promotionProcessor, $taxesApplicator, $shippingChargesProcessor);
35
    }
36
37
    function it_is_initializable()
38
    {
39
        $this->shouldHaveType('Sylius\Component\Core\OrderProcessing\OrderRecalculator');
40
    }
41
42
    function it_implements_order_recalculator_interface()
43
    {
44
        $this->shouldImplement(OrderRecalculatorInterface::class);
45
    }
46
47
    function it_recalculates_order_promotions_taxes_and_shipping_charges(
48
        PromotionProcessorInterface $promotionProcessor,
49
        OrderTaxesApplicatorInterface $taxesApplicator,
50
        ShippingChargesProcessorInterface $shippingChargesProcessor,
51
        OrderInterface $order
52
    ) {
53
        $promotionProcessor->process($order)->shouldBeCalled();
54
        $taxesApplicator->apply($order)->shouldBeCalled();
55
        $shippingChargesProcessor->applyShippingCharges($order)->shouldBeCalled();
56
57
        $this->recalculate($order);
58
    }
59
}
60