|
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\Processor; |
|
13
|
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
|
15
|
|
|
use SM\Factory\FactoryInterface; |
|
16
|
|
|
use Sylius\Component\Resource\StateMachine\StateMachineInterface; |
|
17
|
|
|
use Sylius\Component\Shipping\Model\ShipmentInterface; |
|
18
|
|
|
use Sylius\Component\Shipping\Model\ShipmentUnitInterface; |
|
19
|
|
|
use Sylius\Component\Shipping\Processor\ShipmentProcessorInterface; |
|
20
|
|
|
use Sylius\Component\Shipping\ShipmentTransitions; |
|
21
|
|
|
use Sylius\Component\Shipping\ShipmentUnitTransitions; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @author Saša Stamenković <[email protected]> |
|
25
|
|
|
*/ |
|
26
|
|
|
class ShipmentProcessorSpec extends ObjectBehavior |
|
27
|
|
|
{ |
|
28
|
|
|
function let(FactoryInterface $factory) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->beConstructedWith($factory); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
function it_is_initializable() |
|
34
|
|
|
{ |
|
35
|
|
|
$this->shouldHaveType('Sylius\Component\Shipping\Processor\ShipmentProcessor'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
function it_implements_Sylius_shipment_processor_interface() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->shouldImplement(ShipmentProcessorInterface::class); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
function it_updates_shipment_states( |
|
44
|
|
|
$factory, |
|
45
|
|
|
ShipmentInterface $shipment, |
|
46
|
|
|
StateMachineInterface $sm |
|
47
|
|
|
) { |
|
48
|
|
|
$factory->get($shipment, ShipmentTransitions::GRAPH)->willReturn($sm); |
|
49
|
|
|
|
|
50
|
|
|
$sm->apply('transition', true)->shouldBeCalled(); |
|
51
|
|
|
|
|
52
|
|
|
$this->updateShipmentStates([$shipment], 'transition'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
function it_updates_unit_states( |
|
56
|
|
|
$factory, |
|
57
|
|
|
ShipmentUnitInterface $unit, |
|
58
|
|
|
StateMachineInterface $sm |
|
59
|
|
|
) { |
|
60
|
|
|
$factory->get($unit, ShipmentUnitTransitions::GRAPH)->shouldBeCalled()->willReturn($sm); |
|
61
|
|
|
|
|
62
|
|
|
$sm->apply('transition', true)->shouldBeCalled(); |
|
63
|
|
|
|
|
64
|
|
|
$this->updateUnitStates([$unit], 'transition'); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|