1 | <?php |
||
32 | final class CartContext implements Context |
||
33 | { |
||
34 | /** |
||
35 | * @var SharedStorageInterface |
||
36 | */ |
||
37 | private $sharedStorage; |
||
38 | |||
39 | /** |
||
40 | * @var SummaryPageInterface |
||
41 | */ |
||
42 | private $summaryPage; |
||
43 | |||
44 | /** |
||
45 | * @var ShowPageInterface |
||
46 | */ |
||
47 | private $productShowPage; |
||
48 | |||
49 | /** |
||
50 | * @var NotificationCheckerInterface |
||
51 | */ |
||
52 | private $notificationChecker; |
||
53 | |||
54 | /** |
||
55 | * @var SharedSecurityServiceInterface |
||
56 | */ |
||
57 | private $sharedSecurityService; |
||
58 | |||
59 | /** |
||
60 | * @param SharedStorageInterface $sharedStorage |
||
61 | * @param SummaryPageInterface $summaryPage |
||
62 | * @param ShowPageInterface $productShowPage |
||
63 | * @param NotificationCheckerInterface $notificationChecker |
||
64 | * @param SharedSecurityServiceInterface $sharedSecurityService |
||
65 | */ |
||
66 | public function __construct( |
||
79 | |||
80 | /** |
||
81 | * @When I see the summary of my cart |
||
82 | */ |
||
83 | public function iOpenCartSummaryPage() |
||
87 | |||
88 | /** |
||
89 | * @When I save my changes |
||
90 | */ |
||
91 | public function iSaveMyChanges() |
||
95 | |||
96 | /** |
||
97 | * @Then my cart should be empty |
||
98 | * @Then cart should be empty with no value |
||
99 | */ |
||
100 | public function iShouldBeNotifiedThatMyCartIsEmpty() |
||
109 | |||
110 | /** |
||
111 | * @Given /^I (?:remove|removed) product "([^"]+)" from the cart$/ |
||
112 | */ |
||
113 | public function iRemoveProductFromTheCart($productName) |
||
118 | |||
119 | /** |
||
120 | * @Given I change :productName quantity to :quantity |
||
121 | */ |
||
122 | public function iChangeQuantityTo($productName, $quantity) |
||
127 | |||
128 | /** |
||
129 | * @Then grand total value should be :total |
||
130 | * @Then my cart total should be :total |
||
131 | */ |
||
132 | public function myCartTotalShouldBe($total) |
||
141 | |||
142 | /** |
||
143 | * @Then tax total value should be :taxTotal |
||
144 | * @Then my cart taxes should be :taxTotal |
||
145 | */ |
||
146 | public function myCartTaxesShouldBe($taxTotal) |
||
156 | |||
157 | /** |
||
158 | * @Then shipping total value should be :shippingTotal |
||
159 | * @Then my cart shipping total should be :shippingTotal |
||
160 | * @Then my cart shipping should be for free |
||
161 | */ |
||
162 | public function myCartShippingFeeShouldBe($shippingTotal = '$0.00') |
||
172 | |||
173 | /** |
||
174 | * @Then my cart promotions should be :promotionsTotal |
||
175 | * @Then my discount should be :promotionsTotal |
||
176 | */ |
||
177 | public function myDiscountShouldBe($promotionsTotal) |
||
187 | |||
188 | /** |
||
189 | * @Given /^there should be no shipping fee$/ |
||
190 | */ |
||
191 | public function thereShouldBeNoShippingFee() |
||
203 | |||
204 | /** |
||
205 | * @Given /^there should be no discount$/ |
||
206 | */ |
||
207 | public function thereShouldBeNoDiscount() |
||
219 | |||
220 | /** |
||
221 | * @Then /^(its|theirs) price should be decreased by ("[^"]+")$/ |
||
222 | * @Then /^(product "[^"]+") price should be decreased by ("[^"]+")$/ |
||
223 | */ |
||
224 | public function itsPriceShouldBeDecreasedBy(ProductInterface $product, $amount) |
||
238 | |||
239 | /** |
||
240 | * @Then /^(product "[^"]+") price should not be decreased$/ |
||
241 | * @Then /^(its|theirs) price should not be decreased$/ |
||
242 | */ |
||
243 | public function productPriceShouldNotBeDecreased(ProductInterface $product) |
||
252 | |||
253 | /** |
||
254 | * @Given /^I add (this product) to the cart$/ |
||
255 | * @Given I added product :product to the cart |
||
256 | * @Given /^I (?:have|had) (product "[^"]+") in the cart$/ |
||
257 | * @When I add product :product to the cart |
||
258 | */ |
||
259 | public function iAddProductToTheCart(ProductInterface $product) |
||
266 | |||
267 | /** |
||
268 | * @Given /^(this user) has ("[^"]+" product) in the cart$/ |
||
269 | */ |
||
270 | public function thisUserHasProductInTheCart(ShopUserInterface $user, ProductInterface $product) |
||
276 | |||
277 | /** |
||
278 | * @Given /^I added (products "([^"]+)" and "([^"]+)") to the cart$/ |
||
279 | * @When /^I add (products "([^"]+)" and "([^"]+)") to the cart$/ |
||
280 | * @Given /^I added (products "([^"]+)", "([^"]+)" and "([^"]+)") to the cart$/ |
||
281 | * @When /^I add (products "([^"]+)", "([^"]+)" and "([^"]+)") to the cart$/ |
||
282 | */ |
||
283 | public function iAddMultipleProductsToTheCart(array $products) |
||
289 | |||
290 | /** |
||
291 | * @Given I added :variant variant of product :product to the cart |
||
292 | * @When I add :variant variant of product :product to the cart |
||
293 | * @When I have :variant variant of product :product in the cart |
||
294 | * @When /^I add "([^"]+)" variant of (this product) to the cart$/ |
||
295 | */ |
||
296 | public function iAddProductToTheCartSelectingVariant($variant, ProductInterface $product) |
||
303 | |||
304 | /** |
||
305 | * @When /^I add (\d+) of (them) to (?:the|my) cart$/ |
||
306 | */ |
||
307 | public function iAddQuantityOfProductsToTheCart($quantity, ProductInterface $product) |
||
312 | |||
313 | /** |
||
314 | * @Given /^I have(?:| added) (\d+) (products "([^"]+)") (?:to|in) the cart$/ |
||
315 | * @When /^I add(?:|ed) (\d+) (products "([^"]+)") to the cart$/ |
||
316 | */ |
||
317 | public function iAddProductsToTheCart($quantity, ProductInterface $product) |
||
324 | |||
325 | /** |
||
326 | * @Then I should be on my cart summary page |
||
327 | */ |
||
328 | public function shouldBeOnMyCartSummaryPage() |
||
335 | |||
336 | /** |
||
337 | * @Then I should be notified that the product has been successfully added |
||
338 | */ |
||
339 | public function iShouldBeNotifiedThatItHasBeenSuccessfullyAdded() |
||
343 | |||
344 | /** |
||
345 | * @Then there should be one item in my cart |
||
346 | */ |
||
347 | public function thereShouldBeOneItemInMyCart() |
||
354 | |||
355 | /** |
||
356 | * @Then this item should have name :itemName |
||
357 | */ |
||
358 | public function thisProductShouldHaveName($itemName) |
||
365 | |||
366 | /** |
||
367 | * @Then this item should have variant :variantName |
||
368 | */ |
||
369 | public function thisItemShouldHaveVariant($variantName) |
||
376 | |||
377 | /** |
||
378 | * @When I add :product with :productOption :productOptionValue to the cart |
||
379 | */ |
||
380 | public function iAddThisProductWithToTheCart(ProductInterface $product, OptionInterface $productOption, $productOptionValue) |
||
386 | |||
387 | /** |
||
388 | * @Given /^(this product) should have ([^"]+) "([^"]+)"$/ |
||
389 | */ |
||
390 | public function thisItemShouldHaveOptionValue(ProductInterface $product, $optionName, $optionValue) |
||
397 | |||
398 | /** |
||
399 | * @When I clear my cart |
||
400 | */ |
||
401 | public function iClearMyCart() |
||
405 | |||
406 | /** |
||
407 | * @Then /^I should see "([^"]+)" with quantity (\d+) in my cart$/ |
||
408 | */ |
||
409 | public function iShouldSeeWithQuantityInMyCart($productName, $quantity) |
||
417 | |||
418 | /** |
||
419 | * @Given I use coupon with code :couponCode |
||
420 | */ |
||
421 | public function iUseCouponWithCode($couponCode) |
||
425 | |||
426 | /** |
||
427 | * @Then I should be notified that promotion coupon has been added to the cart |
||
428 | */ |
||
429 | public function iShouldBeNotifiedThatPromotionCouponHasBeenAddedToTheCart() |
||
436 | |||
437 | /** |
||
438 | * @Then I should be notified that promotion coupon is not valid |
||
439 | */ |
||
440 | public function iShouldBeNotifiedThatPromotionCouponIsNotValid() |
||
447 | |||
448 | /** |
||
449 | * @Then total price of :productName item should be :productPrice |
||
450 | */ |
||
451 | public function thisItemPriceShouldBe($productName, $productPrice) |
||
452 | { |
||
453 | $this->summaryPage->open(); |
||
454 | |||
455 | Assert::same( |
||
456 | $this->summaryPage->getItemTotal($productName), |
||
457 | $productPrice |
||
458 | ); |
||
459 | } |
||
460 | |||
461 | /** |
||
462 | * @Then /^I should be notified that (this product) cannot be updated$/ |
||
463 | */ |
||
464 | public function iShouldBeNotifiedThatThisProductDoesNotHaveSufficientStock(ProductInterface $product) |
||
471 | |||
472 | /** |
||
473 | * @Then /^I should not be notified that (this product) cannot be updated$/ |
||
474 | */ |
||
475 | public function iShouldNotBeNotifiedThatThisProductCannotBeUpdated(ProductInterface $product) |
||
482 | } |
||
483 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.