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

it_implements_shipping_method_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\ShippingCategoryInterface;
18
use Sylius\Component\Shipping\Model\ShippingMethodInterface;
19
20
/**
21
 * @author Paweł Jędrzejewski <[email protected]>
22
 * @author Gonzalo Vilaseca <[email protected]>
23
 */
24
final class ShippingMethodSpec extends ObjectBehavior
25
{
26
    public function let()
27
    {
28
        $this->setCurrentLocale('en_US');
29
        $this->setFallbackLocale('en_US');
30
    }
31
32
    function it_implements_shipping_method_interface(): void
33
    {
34
        $this->shouldImplement(ShippingMethodInterface::class);
35
    }
36
37
    function it_implements_Sylius_toogleable_interface(): void
0 ignored issues
show
Coding Style introduced by
function it_implements_S..._toogleable_interface() does not seem to conform to the naming convention (^(?:(?:[a-z]|__)[a-zA-Z0-9]*|[a-z][a-z0-9_]*)$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
38
    {
39
        $this->shouldImplement('Sylius\Component\Resource\Model\ToggleableInterface');
40
    }
41
42
    function it_has_no_id_by_default(): void
43
    {
44
        $this->getId()->shouldReturn(null);
45
    }
46
47
    function its_code_is_mutable(): void
48
    {
49
        $this->setCode('SC2');
50
        $this->getCode()->shouldReturn('SC2');
51
    }
52
53
    function it_is_enabled_by_default(): void
54
    {
55
        $this->shouldBeEnabled();
56
    }
57
58
    function it_allows_disabling_itself(): void
59
    {
60
        $this->setEnabled(false);
61
        $this->shouldNotBeEnabled();
62
    }
63
64
    function it_does_not_belong_to_category_by_default(): void
65
    {
66
        $this->getCategory()->shouldReturn(null);
67
    }
68
69
    function it_allows_assigning_itself_to_category(ShippingCategoryInterface $category): void
70
    {
71
        $this->setCategory($category);
72
        $this->getCategory()->shouldReturn($category);
73
    }
74
75
    function it_allows_detaching_itself_from_category(ShippingCategoryInterface $category): void
76
    {
77
        $this->setCategory($category);
78
        $this->getCategory()->shouldReturn($category);
79
80
        $this->setCategory(null);
81
        $this->getCategory()->shouldReturn(null);
82
    }
83
84
    function it_has_match_any_category_requirement_by_default(): void
85
    {
86
        $this->getCategoryRequirement()->shouldReturn(ShippingMethodInterface::CATEGORY_REQUIREMENT_MATCH_ANY);
87
    }
88
89
    function its_category_matching_requirement_is_mutable(): void
90
    {
91
        $this->setCategoryRequirement(ShippingMethodInterface::CATEGORY_REQUIREMENT_MATCH_NONE);
92
        $this->getCategoryRequirement()->shouldReturn(ShippingMethodInterface::CATEGORY_REQUIREMENT_MATCH_NONE);
93
    }
94
95
    function it_is_unnamed_by_default(): void
96
    {
97
        $this->getName()->shouldReturn(null);
98
    }
99
100
    function its_name_is_mutable(): void
101
    {
102
        $this->setName('Shippable goods');
103
        $this->getName()->shouldReturn('Shippable goods');
104
    }
105
106
    function its_description_is_mutable(): void
107
    {
108
        $this->setDescription('Very good shipping, cheap price, good delivery time.');
109
        $this->getDescription()->shouldReturn('Very good shipping, cheap price, good delivery time.');
110
    }
111
112
    function it_returns_name_when_converted_to_string(): void
113
    {
114
        $this->setName('Shippable goods');
115
        $this->__toString()->shouldReturn('Shippable goods');
116
    }
117
118
    function it_has_no_calculator_defined_by_default(): void
119
    {
120
        $this->getCalculator()->shouldReturn(null);
121
    }
122
123
    function its_calculator_is_mutable(): void
124
    {
125
        $this->setCalculator('default');
126
        $this->getCalculator()->shouldReturn('default');
127
    }
128
129
    function it_initializes_array_for_configuration_by_default(): void
130
    {
131
        $this->getConfiguration()->shouldReturn([]);
132
    }
133
134
    function its_configuration_is_mutable(): void
135
    {
136
        $this->setConfiguration(['charge' => 5]);
137
        $this->getConfiguration()->shouldReturn(['charge' => 5]);
138
    }
139
140
    function it_initializes_creation_date_by_default(): void
141
    {
142
        $this->getCreatedAt()->shouldHaveType('DateTime');
143
    }
144
145
    function its_creation_date_is_mutable(): void
146
    {
147
        $date = new \DateTime();
148
149
        $this->setCreatedAt($date);
150
        $this->getCreatedAt()->shouldReturn($date);
151
    }
152
153
    function it_has_no_last_update_date_by_default(): void
154
    {
155
        $this->getUpdatedAt()->shouldReturn(null);
156
    }
157
158
    function its_last_update_date_is_mutable(): void
159
    {
160
        $date = new \DateTime();
161
162
        $this->setUpdatedAt($date);
163
        $this->getUpdatedAt()->shouldReturn($date);
164
    }
165
166
    function it_has_no_archiving_date_by_default(): void
167
    {
168
        $this->getArchivedAt()->shouldReturn(null);
169
    }
170
171
    function its_archiving_date_is_mutable(): void
172
    {
173
        $date = new \DateTime();
174
175
        $this->setArchivedAt($date);
176
        $this->getArchivedAt()->shouldReturn($date);
177
    }
178
}
179