1 | <?php |
||
31 | final class ProductAttributeContext implements Context |
||
32 | { |
||
33 | /** |
||
34 | * @var SharedStorageInterface |
||
35 | */ |
||
36 | private $sharedStorage; |
||
37 | |||
38 | /** |
||
39 | * @var RepositoryInterface |
||
40 | */ |
||
41 | private $productAttributeRepository; |
||
42 | |||
43 | /** |
||
44 | * @var AttributeFactoryInterface |
||
45 | */ |
||
46 | private $productAttributeFactory; |
||
47 | |||
48 | /** |
||
49 | * @var FactoryInterface |
||
50 | */ |
||
51 | private $productAttributeValueFactory; |
||
52 | |||
53 | /** |
||
54 | * @var ObjectManager |
||
55 | */ |
||
56 | private $objectManager; |
||
57 | |||
58 | /** |
||
59 | * @var \Faker\Generator |
||
60 | */ |
||
61 | private $faker; |
||
62 | |||
63 | /** |
||
64 | * @param SharedStorageInterface $sharedStorage |
||
65 | * @param RepositoryInterface $productAttributeRepository |
||
66 | * @param AttributeFactoryInterface $productAttributeFactory |
||
67 | * @param FactoryInterface $productAttributeValueFactory |
||
68 | * @param ObjectManager $objectManager |
||
69 | */ |
||
70 | public function __construct( |
||
85 | |||
86 | /** |
||
87 | * @Given the store has a :type product attribute :name with code :code |
||
88 | */ |
||
89 | public function theStoreHasAProductAttributeWithCode($type, $name, $code) |
||
95 | |||
96 | /** |
||
97 | * @Given the store has( also) a :type product attribute :name at position :position |
||
98 | */ |
||
99 | public function theStoreHasAProductAttributeWithPosition($type, $name, $position) |
||
106 | |||
107 | /** |
||
108 | * @Given /^the store has(?:| also)(?:| a| an) (text|textarea|integer|percent) product attribute "([^"]+)"$/ |
||
109 | */ |
||
110 | public function theStoreHasAProductAttribute(string $type, string $name): void |
||
116 | |||
117 | /** |
||
118 | * @Given /^(this product attribute) has(?:| also) a value "([^"]+)" in ("[^"]+" locale)$/ |
||
119 | */ |
||
120 | public function thisProductAttributeHasAValueInLocale( |
||
137 | |||
138 | /** |
||
139 | * @Given /^(this product attribute) has(?:| also) a value "([^"]+)" in ("[^"]+" locale) and "([^"]+)" in ("[^"]+" locale)$/ |
||
140 | */ |
||
141 | public function thisProductAttributeHasAValueInLocaleAndInLocale( |
||
161 | |||
162 | /** |
||
163 | * @Given the store has a select product attribute :name |
||
164 | */ |
||
165 | public function theStoreHasASelectProductAttribute(string $name): void |
||
169 | |||
170 | /** |
||
171 | * @Given the store has a select product attribute :name with value :value |
||
172 | * @Given the store has a select product attribute :name with values :firstValue and :secondValue |
||
173 | */ |
||
174 | public function theStoreHasASelectProductAttributeWithValue(string $name, string ...$values): void |
||
191 | |||
192 | /** |
||
193 | * @Given /^(this product attribute) has set min value as (\d+) and max value as (\d+)$/ |
||
194 | */ |
||
195 | public function thisAttributeHasSetMinValueAsAndMaxValueAs(ProductAttributeInterface $attribute, $min, $max) |
||
201 | |||
202 | /** |
||
203 | * @Given /^(this product) has(?:| also)(?:| a) select attribute "([^"]+)" with value "([^"]+)"$/ |
||
204 | * @Given /^(this product) has(?:| also)(?:| a) select attribute "([^"]+)" with values "([^"]+)" and "([^"]+)"$/ |
||
205 | */ |
||
206 | public function thisProductHasSelectAttributeWithValues( |
||
213 | |||
214 | /** |
||
215 | * @Given /^(this product) has(?:| also)(?:| a) select attribute "([^"]+)" with value "([^"]+)" in ("[^"]+" locale)$/ |
||
216 | */ |
||
217 | public function thisProductHasSelectAttributeWithValueInLocale( |
||
225 | |||
226 | /** |
||
227 | * @Given /^(this product) has (text|textarea) attribute "([^"]+)" with value "([^"]+)"$/ |
||
228 | * @Given /^(this product) has (text|textarea) attribute "([^"]+)" with value "([^"]+)" in ("[^"]+" locale)$/ |
||
229 | */ |
||
230 | public function thisProductHasAttributeWithValue( |
||
243 | |||
244 | /** |
||
245 | * @Given /^(this product) has percent attribute "([^"]+)" with value ([^"]+)%$/ |
||
246 | */ |
||
247 | public function thisProductHasPercentAttributeWithValue(ProductInterface $product, $productAttributeName, $value) |
||
255 | |||
256 | /** |
||
257 | * @Given /^(this product) has ([^"]+) attribute "([^"]+)" set to "([^"]+)"$/ |
||
258 | */ |
||
259 | public function thisProductHasCheckboxAttributeWithValue( |
||
272 | |||
273 | /** |
||
274 | * @Given /^(this product) has percent attribute "([^"]+)" at position (\d+)$/ |
||
275 | */ |
||
276 | public function thisProductHasPercentAttributeWithValueAtPosition( |
||
289 | |||
290 | /** |
||
291 | * @Given /^(this product) has ([^"]+) attribute "([^"]+)" with date "([^"]+)"$/ |
||
292 | */ |
||
293 | public function thisProductHasDateTimeAttributeWithDate( |
||
306 | |||
307 | /** |
||
308 | * @param string $type |
||
309 | * @param string $name |
||
310 | * @param string|null $code |
||
311 | * |
||
312 | * @return ProductAttributeInterface |
||
313 | */ |
||
314 | private function createProductAttribute($type, $name, $code = null) |
||
325 | |||
326 | /** |
||
327 | * @param string $type |
||
328 | * @param string $name |
||
329 | * @param string|null $code |
||
330 | * |
||
331 | * @return ProductAttributeInterface |
||
332 | */ |
||
333 | private function provideProductAttribute($type, $name, $code = null) |
||
348 | |||
349 | /** |
||
350 | * @param mixed $value |
||
351 | * @param ProductAttributeInterface $attribute |
||
352 | * @param string $localeCode |
||
353 | * |
||
354 | * @return ProductAttributeValueInterface |
||
355 | */ |
||
356 | private function createProductAttributeValue( |
||
371 | |||
372 | /** |
||
373 | * @param ProductAttributeInterface $productAttribute |
||
374 | */ |
||
375 | private function saveProductAttribute(ProductAttributeInterface $productAttribute) |
||
380 | |||
381 | /** |
||
382 | * @param ProductInterface $product |
||
383 | * @param string $productAttributeName |
||
384 | * @param array $values |
||
385 | * @param string $localeCode |
||
386 | */ |
||
387 | private function createSelectProductAttributeValue( |
||
411 | } |
||
412 |