1 | <?php |
||
35 | final class ProductContext implements Context |
||
36 | { |
||
37 | /** |
||
38 | * @var SharedStorageInterface |
||
39 | */ |
||
40 | private $sharedStorage; |
||
41 | |||
42 | /** |
||
43 | * @var ProductRepositoryInterface |
||
44 | */ |
||
45 | private $productRepository; |
||
46 | |||
47 | /** |
||
48 | * @var FactoryInterface |
||
49 | */ |
||
50 | private $productFactory; |
||
51 | |||
52 | /** |
||
53 | * @var AttributeFactoryInterface |
||
54 | */ |
||
55 | private $productAttributeFactory; |
||
56 | |||
57 | /** |
||
58 | * @var FactoryInterface |
||
59 | */ |
||
60 | private $productVariantFactory; |
||
61 | |||
62 | /** |
||
63 | * @var FactoryInterface |
||
64 | */ |
||
65 | private $attributeValueFactory; |
||
66 | |||
67 | /** |
||
68 | * @var FactoryInterface |
||
69 | */ |
||
70 | private $productOptionFactory; |
||
71 | |||
72 | /** |
||
73 | * @var FactoryInterface |
||
74 | */ |
||
75 | private $productOptionValueFactory; |
||
76 | |||
77 | /** |
||
78 | * @var ObjectManager |
||
79 | */ |
||
80 | private $objectManager; |
||
81 | |||
82 | /** |
||
83 | * @param SharedStorageInterface $sharedStorage |
||
84 | * @param ProductRepositoryInterface $productRepository |
||
85 | * @param FactoryInterface $productFactory |
||
86 | * @param AttributeFactoryInterface $productAttributeFactory |
||
87 | * @param FactoryInterface $productVariantFactory |
||
88 | * @param FactoryInterface $attributeValueFactory |
||
89 | * @param FactoryInterface $productOptionFactory |
||
90 | * @param FactoryInterface $productOptionValueFactory |
||
91 | * @param ObjectManager $objectManager |
||
92 | */ |
||
93 | public function __construct( |
||
114 | |||
115 | /** |
||
116 | * @Given /^the store has a product "([^"]+)"$/ |
||
117 | * @Given /^the store has a product "([^"]+)" priced at ("[^"]+")$/ |
||
118 | */ |
||
119 | public function storeHasAProductPricedAt($productName, $price = 0) |
||
135 | |||
136 | /** |
||
137 | * @Given /^the (product "[^"]+") has "([^"]+)" variant priced at ("[^"]+")$/ |
||
138 | * @Given /^(this product) has "([^"]+)" variant priced at ("[^"]+")$/ |
||
139 | */ |
||
140 | public function theProductHasVariantPricedAt(ProductInterface $product, $productVariantName, $price) |
||
154 | |||
155 | /** |
||
156 | * @Given /^there is product "([^"]+)" available in ((?:this|that|"[^"]+") channel)$/ |
||
157 | */ |
||
158 | public function thereIsProductAvailableInGivenChannel($productName, ChannelInterface $channel) |
||
170 | |||
171 | /** |
||
172 | * @Given /^([^"]+) belongs to ("[^"]+" tax category)$/ |
||
173 | */ |
||
174 | public function productBelongsToTaxCategory(ProductInterface $product, TaxCategoryInterface $taxCategory) |
||
179 | |||
180 | /** |
||
181 | * @Given /^(it) comes in the following variations:$/ |
||
182 | */ |
||
183 | public function itComesInTheFollowingVariations(ProductInterface $product, TableNode $table) |
||
197 | |||
198 | /** |
||
199 | * @Given /^("[^"]+" variant of product "[^"]+") belongs to ("[^"]+" tax category)$/ |
||
200 | */ |
||
201 | public function productVariantBelongsToTaxCategory( |
||
208 | |||
209 | /** |
||
210 | * @Given /^(this product) has ([^"]+) attribute "([^"]+)" with value "([^"]+)"$/ |
||
211 | */ |
||
212 | public function thisProductHasAttributeWithValue(ProductInterface $product, $productAttributeType, $productAttributeName, $value) |
||
220 | |||
221 | /** |
||
222 | * @Given /^(this product) has percent attribute "([^"]+)" with value ([^"]+)%$/ |
||
223 | */ |
||
224 | public function thisProductHasPercentAttributeWithValue(ProductInterface $product, $productAttributeName, $value) |
||
232 | |||
233 | /** |
||
234 | * @Given /^(this product) has ([^"]+) attribute "([^"]+)" set to "([^"]+)"$/ |
||
235 | */ |
||
236 | public function thisProductHasCheckboxAttributeWithValue(ProductInterface $product, $productAttributeType, $productAttributeName, $value) |
||
245 | |||
246 | /** |
||
247 | * @Given /^(this product) has ([^"]+) attribute "([^"]+)" with date "([^"]+)"$/ |
||
248 | */ |
||
249 | public function thisProductHasDateTimeAttributeWithDate(ProductInterface $product, $productAttributeType, $productAttributeName, $date) |
||
258 | |||
259 | /** |
||
260 | * @Given /^(this product) has option "([^"]+)" with values "([^"]+)" and "([^"]+)"$/ |
||
261 | */ |
||
262 | public function thisProductHasOptionWithValues(ProductInterface $product, $optionName, $firstValue, $secondValue) |
||
299 | |||
300 | /** |
||
301 | * @Given /^(this product) is available in "([^"]+)" size priced at ("[^"]+")$/ |
||
302 | */ |
||
303 | public function thisProductIsAvailableInSize(ProductInterface $product, $optionValueName, $price) |
||
316 | |||
317 | /** |
||
318 | * @param string $type |
||
319 | * @param string $name |
||
320 | * @param string $code |
||
321 | * |
||
322 | * @return AttributeInterface |
||
323 | */ |
||
324 | private function createProductAttribute($type, $name, $code = 'PA112') |
||
334 | |||
335 | /** |
||
336 | * @param string $value |
||
337 | * |
||
338 | * @return AttributeValueInterface |
||
339 | */ |
||
340 | private function createProductAttributeValue($value, AttributeInterface $attribute) |
||
351 | |||
352 | /** |
||
353 | * @param string $price |
||
354 | * |
||
355 | * @return int |
||
356 | */ |
||
357 | private function getPriceFromString($price) |
||
361 | } |
||
362 |