1 | <?php |
||
28 | final class ManagingPromotionsContext implements Context |
||
29 | { |
||
30 | /** |
||
31 | * @var SharedStorageInterface |
||
32 | */ |
||
33 | private $sharedStorage; |
||
34 | |||
35 | /** |
||
36 | * @var IndexPageInterface |
||
37 | */ |
||
38 | private $indexPage; |
||
39 | |||
40 | /** |
||
41 | * @var CreatePageInterface |
||
42 | */ |
||
43 | private $createPage; |
||
44 | |||
45 | /** |
||
46 | * @var UpdatePageInterface |
||
47 | */ |
||
48 | private $updatePage; |
||
49 | |||
50 | /** |
||
51 | * @var CurrentPageResolverInterface |
||
52 | */ |
||
53 | private $currentPageResolver; |
||
54 | |||
55 | /** |
||
56 | * @var NotificationCheckerInterface |
||
57 | */ |
||
58 | private $notificationChecker; |
||
59 | |||
60 | /** |
||
61 | * @param SharedStorageInterface $sharedStorage |
||
62 | * @param IndexPageInterface $indexPage |
||
63 | * @param CreatePageInterface $createPage |
||
64 | * @param UpdatePageInterface $updatePage |
||
65 | * @param CurrentPageResolverInterface $currentPageResolver |
||
66 | * @param NotificationCheckerInterface $notificationChecker |
||
67 | */ |
||
68 | public function __construct( |
||
69 | SharedStorageInterface $sharedStorage, |
||
70 | IndexPageInterface $indexPage, |
||
71 | CreatePageInterface $createPage, |
||
72 | UpdatePageInterface $updatePage, |
||
73 | CurrentPageResolverInterface $currentPageResolver, |
||
74 | NotificationCheckerInterface $notificationChecker |
||
75 | ) { |
||
76 | $this->sharedStorage = $sharedStorage; |
||
77 | $this->indexPage = $indexPage; |
||
78 | $this->createPage = $createPage; |
||
79 | $this->updatePage = $updatePage; |
||
80 | $this->currentPageResolver = $currentPageResolver; |
||
81 | $this->notificationChecker = $notificationChecker; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @Given I want to create a new promotion |
||
86 | */ |
||
87 | public function iWantToCreateANewPromotion() |
||
91 | |||
92 | /** |
||
93 | * @Given I want to browse promotions |
||
94 | */ |
||
95 | public function iWantToBrowsePromotions() |
||
99 | |||
100 | /** |
||
101 | * @When I specify its code as :code |
||
102 | * @When I do not specify its code |
||
103 | */ |
||
104 | public function iSpecifyItsCodeAs($code = null) |
||
108 | |||
109 | /** |
||
110 | * @When I name it :name |
||
111 | * @When I do not name it |
||
112 | * @When I remove its name |
||
113 | */ |
||
114 | public function iNameIt($name = null) |
||
118 | |||
119 | /** |
||
120 | * @Then the :promotionName promotion should appear in the registry |
||
121 | * @Then the :promotionName promotion should exist in the registry |
||
122 | * @Then this promotion should still be named :promotionName |
||
123 | * @Then promotion :promotionName should still exist in the registry |
||
124 | */ |
||
125 | public function thePromotionShouldAppearInTheRegistry($promotionName) |
||
134 | |||
135 | /** |
||
136 | * @When I add it |
||
137 | * @When I try to add it |
||
138 | */ |
||
139 | public function iAddIt() |
||
143 | |||
144 | /** |
||
145 | * @Given I add the "Contains taxon" rule configured with :count :taxonName |
||
146 | */ |
||
147 | public function iAddTheContainsTaxonRuleConfiguredWith($count, $taxonName) |
||
153 | |||
154 | /** |
||
155 | * @Given I add the "Taxon" rule configured with :firstTaxon |
||
156 | * @Given I add the "Taxon" rule configured with :firstTaxon and :secondTaxon |
||
157 | */ |
||
158 | public function iAddTheTaxonRuleConfiguredWith($firstTaxon, $secondTaxon = null) |
||
167 | |||
168 | /** |
||
169 | * @Given I add the "Total of items from taxon" rule configured with :count :taxonName |
||
170 | */ |
||
171 | public function iAddTheRuleConfiguredWith($count, $taxonName) |
||
177 | |||
178 | /** |
||
179 | * @Given I add the "Order fixed discount" action configured with €:amount |
||
180 | */ |
||
181 | public function stepDefinition($amount) |
||
186 | |||
187 | /** |
||
188 | * @Then /^there should be (\d+) promotion(?:|s)$/ |
||
189 | */ |
||
190 | public function thereShouldBePromotion($number) |
||
198 | |||
199 | /** |
||
200 | * @Then /^(this promotion) should be coupon based$/ |
||
201 | */ |
||
202 | public function thisPromotionShouldBeCouponBased(PromotionInterface $promotion) |
||
209 | |||
210 | /** |
||
211 | * @Then /^I should be able to manage coupons for (this promotion)$/ |
||
212 | */ |
||
213 | public function iShouldBeAbleToManageCouponsForThisPromotion(PromotionInterface $promotion) |
||
220 | |||
221 | /** |
||
222 | * @Then I should be notified that :element is required |
||
223 | */ |
||
224 | public function iShouldBeNotifiedThatIsRequired($element) |
||
228 | |||
229 | /** |
||
230 | * @Then I should be notified that promotion with this code already exists |
||
231 | */ |
||
232 | public function iShouldBeNotifiedThatPromotionWithThisCodeAlreadyExists() |
||
239 | |||
240 | /** |
||
241 | * @Then promotion with :element :name should not be added |
||
242 | */ |
||
243 | public function promotionWithElementValueShouldNotBeAdded($element, $name) |
||
252 | |||
253 | /** |
||
254 | * @Then there should still be only one promotion with :element :value |
||
255 | */ |
||
256 | public function thereShouldStillBeOnlyOnePromotionWith($element, $value) |
||
265 | |||
266 | /** |
||
267 | * @When I set its usage limit to :usageLimit |
||
268 | */ |
||
269 | public function iSetItsUsageLimitTo($usageLimit) |
||
275 | |||
276 | /** |
||
277 | * @Then the :promotion promotion should be available to be used only :usageLimit times |
||
278 | */ |
||
279 | public function thePromotionShouldBeAvailableToUseOnlyTimes(PromotionInterface $promotion, $usageLimit) |
||
288 | |||
289 | /** |
||
290 | * @When I make it exclusive |
||
291 | */ |
||
292 | public function iMakeItExclusive() |
||
298 | |||
299 | /** |
||
300 | * @Then the :promotion promotion should be exclusive |
||
301 | */ |
||
302 | public function thePromotionShouldBeExclusive(PromotionInterface $promotion) |
||
306 | |||
307 | /** |
||
308 | * @When I make it coupon based |
||
309 | */ |
||
310 | public function iMakeItCouponBased() |
||
316 | |||
317 | /** |
||
318 | * @Then the :promotion promotion should be coupon based |
||
319 | */ |
||
320 | public function thePromotionShouldBeCouponBased(PromotionInterface $promotion) |
||
324 | |||
325 | /** |
||
326 | * @When I make it applicable for the :channelName channel |
||
327 | */ |
||
328 | public function iMakeItApplicableForTheChannel($channelName) |
||
334 | |||
335 | /** |
||
336 | * @Then the :promotion promotion should be applicable for the :channelName channel |
||
337 | */ |
||
338 | public function thePromotionShouldBeApplicatableForTheChannel(PromotionInterface $promotion, $channelName) |
||
347 | |||
348 | /** |
||
349 | * @Given I want to modify a :promotion promotion |
||
350 | * @Given /^I want to modify (this promotion)$/ |
||
351 | */ |
||
352 | public function iWantToModifyAPromotion(PromotionInterface $promotion) |
||
356 | |||
357 | /** |
||
358 | * @Then the code field should be disabled |
||
359 | */ |
||
360 | public function theCodeFieldShouldBeDisabled() |
||
367 | |||
368 | /** |
||
369 | * @When I save my changes |
||
370 | * @When I try to save my changes |
||
371 | */ |
||
372 | public function iSaveMyChanges() |
||
376 | |||
377 | /** |
||
378 | * @When /^I delete a ("([^"]+)" promotion)$/ |
||
379 | * @When /^I try to delete a ("([^"]+)" promotion)$/ |
||
380 | */ |
||
381 | public function iDeletePromotion(PromotionInterface $promotion) |
||
388 | |||
389 | /** |
||
390 | * @Then /^(this promotion) should no longer exist in the promotion registry$/ |
||
391 | */ |
||
392 | public function promotionShouldNotExistInTheRegistry(PromotionInterface $promotion) |
||
401 | |||
402 | /** |
||
403 | * @Then I should be notified that it is in use and cannot be deleted |
||
404 | */ |
||
405 | public function iShouldBeNotifiedOfFailure() |
||
412 | |||
413 | /** |
||
414 | * @When I make it available from :startsDate to :endsDate |
||
415 | */ |
||
416 | public function iMakeItAvailableFromTo(\DateTime $startsDate, \DateTime $endsDate) |
||
423 | |||
424 | /** |
||
425 | * @Then the :promotion promotion should be available from :startsDate to :endsDate |
||
426 | */ |
||
427 | public function thePromotionShouldBeAvailableFromTo(PromotionInterface $promotion, \DateTime $startsDate, \DateTime $endsDate) |
||
441 | |||
442 | /** |
||
443 | * @Then I should be notified that promotion cannot end before it start |
||
444 | */ |
||
445 | public function iShouldBeNotifiedThatPromotionCannotEndBeforeItsEvenStart() |
||
454 | |||
455 | /** |
||
456 | * @param string $element |
||
457 | * @param string $expectedMessage |
||
458 | */ |
||
459 | private function assertFieldValidationMessage($element, $expectedMessage) |
||
468 | |||
469 | /** |
||
470 | * @param PromotionInterface $promotion |
||
471 | * @param string $field |
||
472 | */ |
||
473 | private function assertIfFieldIsTrue(PromotionInterface $promotion, $field) |
||
482 | } |
||
483 |