|
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
|
|
|
|