1 | <?php |
||
32 | final class ManagingProductVariantsContext implements Context |
||
33 | { |
||
34 | /** |
||
35 | * @var SharedStorageInterface |
||
36 | */ |
||
37 | private $sharedStorage; |
||
38 | |||
39 | /** |
||
40 | * @var DefaultProductVariantResolver |
||
41 | */ |
||
42 | private $defaultProductVariantResolver; |
||
43 | |||
44 | /** |
||
45 | * @var CreatePageInterface |
||
46 | */ |
||
47 | private $createPage; |
||
48 | |||
49 | /** |
||
50 | * @var IndexPageInterface |
||
51 | */ |
||
52 | private $indexPage; |
||
53 | |||
54 | /** |
||
55 | * @var UpdatePageInterface |
||
56 | */ |
||
57 | private $updatePage; |
||
58 | |||
59 | /** |
||
60 | * @var CurrentPageResolverInterface |
||
61 | */ |
||
62 | private $currentPageResolver; |
||
63 | |||
64 | /** |
||
65 | * @var NotificationCheckerInterface |
||
66 | */ |
||
67 | private $notificationChecker; |
||
68 | |||
69 | /** |
||
70 | * @param SharedStorageInterface $sharedStorage |
||
71 | * @param DefaultProductVariantResolver $defaultProductVariantResolver |
||
72 | * @param CreatePageInterface $createPage |
||
73 | * @param IndexPageInterface $indexPage |
||
74 | * @param UpdatePageInterface $updatePage |
||
75 | * @param CurrentPageResolverInterface $currentPageResolver |
||
76 | * @param NotificationCheckerInterface $notificationChecker |
||
77 | */ |
||
78 | public function __construct( |
||
95 | |||
96 | /** |
||
97 | * @Given /^I want to create a new variant of (this product)$/ |
||
98 | */ |
||
99 | public function iWantToCreateANewProduct(ProductInterface $product) |
||
103 | |||
104 | /** |
||
105 | * @When I specify its code as :code |
||
106 | * @When I do not specify its code |
||
107 | */ |
||
108 | public function iSpecifyItsCodeAs($code = null) |
||
112 | |||
113 | /** |
||
114 | * @When I name it :name |
||
115 | */ |
||
116 | public function iNameItIn($name) |
||
120 | |||
121 | /** |
||
122 | * @When I rename it to :name |
||
123 | */ |
||
124 | public function iRenameItTo($name) |
||
128 | |||
129 | /** |
||
130 | * @When I add it |
||
131 | * @When I try to add it |
||
132 | */ |
||
133 | public function iAddIt() |
||
137 | |||
138 | /** |
||
139 | * @When I disable its inventory tracking |
||
140 | */ |
||
141 | public function iDisableItsTracking() |
||
145 | |||
146 | /** |
||
147 | * @When I enable its inventory tracking |
||
148 | */ |
||
149 | public function iEnableItsTracking() |
||
153 | |||
154 | /** |
||
155 | * @When /^I set its(?:| default) price to ("(?:€|£|\$)[^"]+")$/ |
||
156 | */ |
||
157 | public function iSetItsPriceTo($price) |
||
161 | |||
162 | /** |
||
163 | * @When I choose :calculatorName calculator |
||
164 | */ |
||
165 | public function iChooseCalculator($calculatorName) |
||
169 | |||
170 | /** |
||
171 | * @When /^I set its price to "(?:€|£|\$)([^"]+)" for ("[^"]+" currency) and ("[^"]+" channel)$/ |
||
172 | */ |
||
173 | public function iSetItsPriceToForCurrencyAndChannel($price, CurrencyInterface $currency, ChannelInterface $channel) |
||
177 | |||
178 | /** |
||
179 | * @When I set its :optionName option to :optionValue |
||
180 | */ |
||
181 | public function iSetItsOptionAs($optionName, $optionValue) |
||
185 | |||
186 | /** |
||
187 | * @Then the :productVariantCode variant of the :product product should appear in the shop |
||
188 | */ |
||
189 | public function theProductVariantShouldAppearInTheShop($productVariantCode, ProductInterface $product) |
||
198 | |||
199 | /** |
||
200 | * @When /^I (?:|want to )view all variants of (this product)$/ |
||
201 | * @When /^I view(?:| all) variants of the (product "[^"]+")$/ |
||
202 | */ |
||
203 | public function iWantToViewAllVariantsOfThisProduct(ProductInterface $product) |
||
207 | |||
208 | /** |
||
209 | * @Then I should see :numberOfProductVariants variants in the list |
||
210 | * @Then I should see :numberOfProductVariants variant in the list |
||
211 | */ |
||
212 | public function iShouldSeeProductsInTheList($numberOfProductVariants) |
||
222 | |||
223 | /** |
||
224 | * @When /^I delete the ("[^"]+" variant of product "[^"]+")$/ |
||
225 | * @When /^I try to delete the ("[^"]+" variant of product "[^"]+")$/ |
||
226 | */ |
||
227 | public function iDeleteTheVariantOfProduct(ProductVariantInterface $productVariant) |
||
233 | |||
234 | /** |
||
235 | * @Then /^(this variant) should not exist in the product catalog$/ |
||
236 | */ |
||
237 | public function productVariantShouldNotExist(ProductVariantInterface $productVariant) |
||
246 | |||
247 | /** |
||
248 | * @Then I should be notified that this variant is in use and cannot be deleted |
||
249 | */ |
||
250 | public function iShouldBeNotifiedOfFailure() |
||
257 | |||
258 | /** |
||
259 | * @Then /^(this variant) should still exist in the product catalog$/ |
||
260 | */ |
||
261 | public function productShouldExistInTheProductCatalog(ProductVariantInterface $productVariant) |
||
265 | |||
266 | /** |
||
267 | * @When /^I want to modify the ("[^"]+" product variant)$/ |
||
268 | * @When /^I want to modify (this product variant)$/ |
||
269 | */ |
||
270 | public function iWantToModifyAProduct(ProductVariantInterface $productVariant) |
||
274 | |||
275 | /** |
||
276 | * @Then the code field should be disabled |
||
277 | */ |
||
278 | public function theCodeFieldShouldBeDisabled() |
||
285 | |||
286 | /** |
||
287 | * @Then I should be notified that price is required |
||
288 | */ |
||
289 | public function iShouldBeNotifiedThatPriceIsRequired() |
||
293 | |||
294 | /** |
||
295 | * @When I save my changes |
||
296 | * @When I try to save my changes |
||
297 | */ |
||
298 | public function iSaveMyChanges() |
||
302 | |||
303 | /** |
||
304 | * @When /^I change its price to "(?:€|£|\$)([^"]+)"$/ |
||
305 | */ |
||
306 | public function iChangeItsPriceTo($price) |
||
310 | |||
311 | /** |
||
312 | * @When I remove its name |
||
313 | */ |
||
314 | public function iRemoveItsNameFromTranslation() |
||
318 | |||
319 | /** |
||
320 | * @Then /^the variant "([^"]+)" should have (\d+) items on hand$/ |
||
321 | */ |
||
322 | public function thisVariantShouldHaveItemsOnHand($productVariantName, $quantity) |
||
329 | |||
330 | /** |
||
331 | * @Then /^the "([^"]+)" variant of ("[^"]+" product) should have (\d+) items on hand$/ |
||
332 | */ |
||
333 | public function theVariantOfProductShouldHaveItemsOnHand($productVariantName, ProductInterface $product, $quantity) |
||
342 | |||
343 | /** |
||
344 | * @Then /^inventory of (this variant) should not be tracked$/ |
||
345 | */ |
||
346 | public function thisProductVariantShouldNotBeTracked(ProductVariantInterface $productVariant) |
||
355 | |||
356 | /** |
||
357 | * @Then /^inventory of (this variant) should be tracked$/ |
||
358 | */ |
||
359 | public function thisProductVariantShouldBeTracked(ProductVariantInterface $productVariant) |
||
368 | |||
369 | /** |
||
370 | * @Then /^I should see that the ("([^"]+)" variant) is not tracked$/ |
||
371 | */ |
||
372 | public function iShouldSeeThatIsNotTracked(ProductVariantInterface $productVariant) |
||
379 | |||
380 | /** |
||
381 | * @Then /^I should see that the ("[^"]+" variant) has zero on hand quantity$/ |
||
382 | */ |
||
383 | public function iShouldSeeThatTheVariantHasZeroOnHandQuantity(ProductVariantInterface $productVariant) |
||
390 | |||
391 | /** |
||
392 | * @Then /^(\d+) units of (this product) should be on hold$/ |
||
393 | */ |
||
394 | public function unitsOfThisProductShouldBeOnHold($quantity, ProductInterface $product) |
||
401 | |||
402 | /** |
||
403 | * @Then /^(\d+) units of (this product) should be on hand$/ |
||
404 | */ |
||
405 | public function unitsOfThisProductShouldBeOnHand($quantity, ProductInterface $product) |
||
422 | |||
423 | /** |
||
424 | * @Then /^there should be no units of (this product) on hold$/ |
||
425 | */ |
||
426 | public function thereShouldBeNoUnitsOfThisProductOnHold(ProductInterface $product) |
||
433 | |||
434 | /** |
||
435 | * @Then the :variant variant should have :amount items on hold |
||
436 | * @Then /^(this variant) should have (\d+) items on hold$/ |
||
437 | */ |
||
438 | public function thisVariantShouldHaveItemsOnHold(ProductVariantInterface $variant, $amount) |
||
442 | |||
443 | /** |
||
444 | * @Then the :variant variant of :product product should have :amount items on hold |
||
445 | */ |
||
446 | public function theVariantOfProductShouldHaveItemsOnHold(ProductVariantInterface $variant, ProductInterface $product, $amount) |
||
452 | |||
453 | /** |
||
454 | * @Then /^(variant with code "[^"]+") for ("[^"]+" currency) and ("[^"]+" channel) should have "(?:€|£|\$)([^"]+)"$/ |
||
455 | */ |
||
456 | public function theProductForCurrencyAndChannelShouldHave( |
||
469 | |||
470 | /** |
||
471 | * @param string $element |
||
472 | * @param $message |
||
473 | */ |
||
474 | private function assertValidationMessage($element, $message) |
||
481 | |||
482 | /** |
||
483 | * @param int $expectedAmount |
||
484 | * @param ProductVariantInterface $variant |
||
485 | * |
||
486 | * @throws \InvalidArgumentException |
||
487 | */ |
||
488 | private function assertOnHoldQuantityOfVariant($expectedAmount, $variant) |
||
503 | } |
||
504 |
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.