1 | <?php |
||
24 | final class AttributeValueSpec extends ObjectBehavior |
||
25 | { |
||
26 | function it_is_initializable() |
||
30 | |||
31 | function it_implements_Sylius_subject_attribute_interface() |
||
35 | |||
36 | function it_has_no_id_by_default() |
||
40 | |||
41 | function it_does_not_belong_to_a_subject_by_default() |
||
45 | |||
46 | function it_allows_assigning_itself_to_a_subject(AttributeSubjectInterface $subject) |
||
51 | |||
52 | function it_allows_detaching_itself_from_a_subject(AttributeSubjectInterface $subject) |
||
60 | |||
61 | function it_has_no_attribute_defined_by_default() |
||
65 | |||
66 | function its_attribute_is_definable(AttributeInterface $attribute) |
||
71 | |||
72 | function it_has_no_default_locale_code() |
||
76 | |||
77 | function its_locale_code_is_mutable() |
||
82 | |||
83 | function it_has_no_value_by_default() |
||
87 | |||
88 | function its_value_is_mutable_based_on_attribute_storage_type(AttributeInterface $attribute) |
||
89 | { |
||
90 | $storageTypeToExampleData = [ |
||
91 | 'boolean' => false, |
||
92 | 'text' => 'Lorem ipsum', |
||
93 | 'integer' => 42, |
||
94 | 'float' => 6.66, |
||
95 | 'datetime' => new \DateTime(), |
||
96 | 'date' => new \DateTime(), |
||
97 | 'json' => ['foo' => 'bar'], |
||
98 | ]; |
||
99 | |||
100 | foreach ($storageTypeToExampleData as $storageType => $exampleData) { |
||
101 | $attribute->getStorageType()->willReturn($storageType); |
||
102 | $this->setAttribute($attribute); |
||
103 | |||
104 | $this->setValue($exampleData); |
||
105 | $this->getValue()->shouldReturn($exampleData); |
||
106 | } |
||
107 | } |
||
108 | |||
109 | function its_value_can_be_set_to_null(AttributeInterface $attribute) |
||
110 | { |
||
111 | $storageTypes = [ |
||
112 | 'boolean', |
||
113 | 'text', |
||
114 | 'integer', |
||
115 | 'float', |
||
116 | 'datetime', |
||
117 | 'date', |
||
118 | 'json', |
||
119 | ]; |
||
120 | |||
121 | foreach ($storageTypes as $storageType) { |
||
122 | $attribute->getStorageType()->willReturn($storageType); |
||
123 | $this->setAttribute($attribute); |
||
124 | |||
125 | $this->setValue(null); |
||
126 | $this->getValue()->shouldReturn(null); |
||
127 | } |
||
128 | } |
||
129 | |||
130 | function it_throws_exception_when_trying_to_get_code_without_attribute_defined() |
||
137 | |||
138 | function it_returns_its_attribute_code(AttributeInterface $attribute) |
||
145 | |||
146 | function it_throws_exception_when_trying_to_get_name_without_attribute_defined() |
||
153 | |||
154 | function it_returns_its_attribute_name(AttributeInterface $attribute) |
||
161 | |||
162 | function it_throws_exception_when_trying_to_get_type_without_attribute_defined() |
||
169 | |||
170 | function it_returns_its_attribute_type(AttributeInterface $attribute) |
||
177 | } |
||
178 |
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.