Completed
Push — scalar-types/ui ( 162de3 )
by Kamil
22:15
created

it_implements_shipment_unit_interface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
declare(strict_types=1);
13
14
namespace spec\Sylius\Component\Shipping\Model;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Shipping\Model\ShipmentInterface;
18
use Sylius\Component\Shipping\Model\ShipmentUnitInterface;
19
use Sylius\Component\Shipping\Model\ShippableInterface;
20
21
/**
22
 * @author Paweł Jędrzejewski <[email protected]>
23
 */
24
final class ShipmentUnitSpec extends ObjectBehavior
25
{
26
    function it_implements_shipment_unit_interface(): void
27
    {
28
        $this->shouldImplement(ShipmentUnitInterface::class);
29
    }
30
31
    function it_has_no_id_by_default(): void
32
    {
33
        $this->getId()->shouldReturn(null);
34
    }
35
36
    function it_does_not_belong_to_shipment_by_default(): void
37
    {
38
        $this->getShipment()->shouldReturn(null);
39
    }
40
41
    function it_allows_assigning_itself_to_shipment(ShipmentInterface $shipment): void
42
    {
43
        $this->setShipment($shipment);
44
        $this->getShipment()->shouldReturn($shipment);
45
    }
46
47
    function it_allows_detaching_itself_from_shipment(ShipmentInterface $shipment): void
48
    {
49
        $this->setShipment($shipment);
50
        $this->getShipment()->shouldReturn($shipment);
51
52
        $this->setShipment(null);
53
        $this->getShipment()->shouldReturn(null);
54
    }
55
56
    function it_has_no_shippable_defined_by_default(): void
57
    {
58
        $this->getShippable()->shouldReturn(null);
59
    }
60
61
    function it_allows_defining_shippable(ShippableInterface $shippable): void
62
    {
63
        $this->setShippable($shippable);
64
        $this->getShippable()->shouldReturn($shippable);
65
    }
66
67
    function it_initializes_creation_date_by_default(): void
68
    {
69
        $this->getCreatedAt()->shouldHaveType(\DateTimeInterface::class);
70
    }
71
72
    function its_creation_date_is_mutable(): void
73
    {
74
        $date = new \DateTime();
75
76
        $this->setCreatedAt($date);
77
        $this->getCreatedAt()->shouldReturn($date);
78
    }
79
80
    function it_has_no_last_update_date_by_default(): void
81
    {
82
        $this->getUpdatedAt()->shouldReturn(null);
83
    }
84
85
    function its_last_update_date_is_mutable(): void
86
    {
87
        $date = new \DateTime();
88
89
        $this->setUpdatedAt($date);
90
        $this->getUpdatedAt()->shouldReturn($date);
91
    }
92
}
93