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\Model; |
13
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
15
|
|
|
use Sylius\Component\Shipping\Model\ShipmentInterface; |
16
|
|
|
use Sylius\Component\Shipping\Model\ShipmentUnitInterface; |
17
|
|
|
use Sylius\Component\Shipping\Model\ShippableInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class ShipmentUnitSpec extends ObjectBehavior |
23
|
|
|
{ |
24
|
|
|
function it_is_initializable() |
25
|
|
|
{ |
26
|
|
|
$this->shouldHaveType('Sylius\Component\Shipping\Model\ShipmentUnit'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
function it_implements_Sylius_shipment_unit_interface() |
30
|
|
|
{ |
31
|
|
|
$this->shouldImplement(ShipmentUnitInterface::class); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
function it_has_no_id_by_default() |
35
|
|
|
{ |
36
|
|
|
$this->getId()->shouldReturn(null); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
function it_does_not_belong_to_shipment_by_default() |
40
|
|
|
{ |
41
|
|
|
$this->getShipment()->shouldReturn(null); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
function it_allows_assigning_itself_to_shipment(ShipmentInterface $shipment) |
45
|
|
|
{ |
46
|
|
|
$this->setShipment($shipment); |
47
|
|
|
$this->getShipment()->shouldReturn($shipment); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
function it_allows_detaching_itself_from_shipment(ShipmentInterface $shipment) |
51
|
|
|
{ |
52
|
|
|
$this->setShipment($shipment); |
53
|
|
|
$this->getShipment()->shouldReturn($shipment); |
54
|
|
|
|
55
|
|
|
$this->setShipment(null); |
56
|
|
|
$this->getShipment()->shouldReturn(null); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
function it_has_no_shippable_defined_by_default() |
60
|
|
|
{ |
61
|
|
|
$this->getShippable()->shouldReturn(null); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
function it_allows_defining_shippable(ShippableInterface $shippable) |
65
|
|
|
{ |
66
|
|
|
$this->setShippable($shippable); |
67
|
|
|
$this->getShippable()->shouldReturn($shippable); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
function it_has_ready_state_by_default() |
71
|
|
|
{ |
72
|
|
|
$this->getShippingState()->shouldReturn(ShipmentInterface::STATE_READY); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
function its_state_is_mutable() |
76
|
|
|
{ |
77
|
|
|
$this->setShippingState(ShipmentInterface::STATE_SHIPPED); |
78
|
|
|
$this->getShippingState()->shouldReturn(ShipmentInterface::STATE_SHIPPED); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
function it_initializes_creation_date_by_default() |
82
|
|
|
{ |
83
|
|
|
$this->getCreatedAt()->shouldHaveType(\DateTime::class); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
function its_creation_date_is_mutable() |
87
|
|
|
{ |
88
|
|
|
$date = new \DateTime(); |
89
|
|
|
|
90
|
|
|
$this->setCreatedAt($date); |
91
|
|
|
$this->getCreatedAt()->shouldReturn($date); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
function it_has_no_last_update_date_by_default() |
95
|
|
|
{ |
96
|
|
|
$this->getUpdatedAt()->shouldReturn(null); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
function its_last_update_date_is_mutable() |
100
|
|
|
{ |
101
|
|
|
$date = new \DateTime(); |
102
|
|
|
|
103
|
|
|
$this->setUpdatedAt($date); |
104
|
|
|
$this->getUpdatedAt()->shouldReturn($date); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|