1 | <?php |
||
28 | final class CheckoutCompleteContext implements Context |
||
29 | { |
||
30 | /** @var SharedStorageInterface */ |
||
31 | private $sharedStorage; |
||
32 | |||
33 | /** @var CompletePageInterface */ |
||
34 | private $completePage; |
||
35 | |||
36 | /** @var NotificationCheckerInterface */ |
||
37 | private $notificationChecker; |
||
38 | |||
39 | public function __construct( |
||
48 | |||
49 | /** |
||
50 | * @When I try to open checkout complete page |
||
51 | * @When I want to complete checkout |
||
52 | */ |
||
53 | public function iTryToOpenCheckoutCompletePage() |
||
57 | |||
58 | /** |
||
59 | * @When I decide to change the payment method |
||
60 | */ |
||
61 | public function iGoToThePaymentStep() |
||
65 | |||
66 | /** |
||
67 | * @When /^I provide additional note like "([^"]+)"$/ |
||
68 | */ |
||
69 | public function iProvideAdditionalNotesLike($notes) |
||
74 | |||
75 | /** |
||
76 | * @When I return to the checkout summary step |
||
77 | */ |
||
78 | public function iReturnToTheCheckoutSummaryStep() |
||
82 | |||
83 | /** |
||
84 | * @Given I have confirmed order |
||
85 | * @When I confirm my order |
||
86 | */ |
||
87 | public function iConfirmMyOrder() |
||
91 | |||
92 | /** |
||
93 | * @Then I should be on the checkout complete step |
||
94 | * @Then I should be on the checkout summary step |
||
95 | */ |
||
96 | public function iShouldBeOnTheCheckoutCompleteStep() |
||
100 | |||
101 | /** |
||
102 | * @Then my order's shipping address should be to :fullName |
||
103 | */ |
||
104 | public function iShouldSeeThisShippingAddressAsShippingAddress($fullName) |
||
110 | |||
111 | /** |
||
112 | * @Then my order's billing address should be to :fullName |
||
113 | */ |
||
114 | public function iShouldSeeThisBillingAddressAsBillingAddress($fullName) |
||
120 | |||
121 | /** |
||
122 | * @Then address to :fullName should be used for both shipping and billing of my order |
||
123 | */ |
||
124 | public function iShouldSeeThisShippingAddressAsShippingAndBillingAddress($fullName) |
||
129 | |||
130 | /** |
||
131 | * @Then I should have :quantity :productName products in the cart |
||
132 | */ |
||
133 | public function iShouldHaveProductsInTheCart($quantity, $productName) |
||
137 | |||
138 | /** |
||
139 | * @Then my order shipping should be :price |
||
140 | */ |
||
141 | public function myOrderShippingShouldBe(string $price): void |
||
145 | |||
146 | /** |
||
147 | * @Then I should not see shipping total |
||
148 | */ |
||
149 | public function iShouldNotSeeShippingTotal(): void |
||
150 | { |
||
151 | Assert::false($this->completePage->hasShippingTotal()); |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * @Then /^the ("[^"]+" product) should have unit price discounted by ("\$\d+")$/ |
||
156 | */ |
||
157 | public function theShouldHaveUnitPriceDiscountedFor(ProductInterface $product, $amount) |
||
158 | { |
||
159 | Assert::true($this->completePage->hasProductDiscountedUnitPriceBy($product, $amount)); |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * @Then /^my order total should be ("(?:\£|\$)\d+(?:\.\d+)?")$/ |
||
164 | */ |
||
165 | public function myOrderTotalShouldBe($total) |
||
166 | { |
||
167 | Assert::true($this->completePage->hasOrderTotal($total)); |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * @Then my order promotion total should be :promotionTotal |
||
172 | */ |
||
173 | public function myOrderPromotionTotalShouldBe($promotionTotal) |
||
174 | { |
||
175 | Assert::true($this->completePage->hasPromotionTotal($promotionTotal)); |
||
176 | } |
||
177 | |||
178 | /** |
||
179 | * @Then :promotionName should be applied to my order |
||
180 | */ |
||
181 | public function shouldBeAppliedToMyOrder($promotionName) |
||
182 | { |
||
183 | Assert::true($this->completePage->hasOrderPromotion($promotionName)); |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * @Then :promotionName should be applied to my order shipping |
||
188 | */ |
||
189 | public function shouldBeAppliedToMyOrderShipping($promotionName) |
||
190 | { |
||
191 | Assert::true($this->completePage->hasShippingPromotion($promotionName)); |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * @Given my tax total should be :taxTotal |
||
196 | */ |
||
197 | public function myTaxTotalShouldBe(string $taxTotal): void |
||
198 | { |
||
199 | Assert::same($this->completePage->getTaxTotal(), $taxTotal); |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * @Then my order's shipping method should be :shippingMethod |
||
204 | */ |
||
205 | public function myOrdersShippingMethodShouldBe(ShippingMethodInterface $shippingMethod) |
||
206 | { |
||
207 | Assert::true($this->completePage->hasShippingMethod($shippingMethod)); |
||
208 | } |
||
209 | |||
210 | /** |
||
211 | * @Then my order's payment method should be :paymentMethod |
||
212 | */ |
||
213 | public function myOrdersPaymentMethodShouldBe(PaymentMethodInterface $paymentMethod) |
||
214 | { |
||
215 | Assert::same($this->completePage->getPaymentMethodName(), $paymentMethod->getName()); |
||
216 | } |
||
217 | |||
218 | /** |
||
219 | * @Then the :product product should have unit price :price |
||
220 | */ |
||
221 | public function theProductShouldHaveUnitPrice(ProductInterface $product, $price) |
||
222 | { |
||
223 | Assert::true($this->completePage->hasProductUnitPrice($product, $price)); |
||
224 | } |
||
225 | |||
226 | /** |
||
227 | * @Then /^I should be notified that (this product) does not have sufficient stock$/ |
||
228 | */ |
||
229 | public function iShouldBeNotifiedThatThisProductDoesNotHaveSufficientStock(ProductInterface $product) |
||
230 | { |
||
231 | Assert::true($this->completePage->hasProductOutOfStockValidationMessage($product)); |
||
232 | } |
||
233 | |||
234 | /** |
||
235 | * @Then /^I should not be notified that (this product) does not have sufficient stock$/ |
||
236 | */ |
||
237 | public function iShouldNotBeNotifiedThatThisProductDoesNotHaveSufficientStock(ProductInterface $product) |
||
238 | { |
||
239 | Assert::false($this->completePage->hasProductOutOfStockValidationMessage($product)); |
||
240 | } |
||
241 | |||
242 | /** |
||
243 | * @Then my order's locale should be :locale |
||
244 | */ |
||
245 | public function myOrderLocaleShouldBe($locale) |
||
246 | { |
||
247 | Assert::true($this->completePage->hasLocale($locale)); |
||
248 | } |
||
249 | |||
250 | /** |
||
251 | * @Then I should see :provinceName in the shipping address |
||
252 | */ |
||
253 | public function iShouldSeeInTheShippingAddress($provinceName) |
||
254 | { |
||
255 | Assert::true($this->completePage->hasShippingProvinceName($provinceName)); |
||
256 | } |
||
257 | |||
258 | /** |
||
259 | * @Then I should see :provinceName in the billing address |
||
260 | */ |
||
261 | public function iShouldSeeInTheBillingAddress($provinceName) |
||
262 | { |
||
263 | Assert::true($this->completePage->hasBillingProvinceName($provinceName)); |
||
264 | } |
||
265 | |||
266 | /** |
||
267 | * @Then I should not see any information about payment method |
||
268 | */ |
||
269 | public function iShouldNotSeeAnyInformationAboutPaymentMethod() |
||
270 | { |
||
271 | Assert::false($this->completePage->hasPaymentMethod()); |
||
272 | } |
||
273 | |||
274 | /** |
||
275 | * @Then I should not be able to confirm order because products does not fit :shippingMethod requirements |
||
276 | */ |
||
277 | public function iShouldNotBeAbleToConfirmOrderBecauseDoesNotBelongsToShippingCategory(ShippingMethodInterface $shippingMethod) |
||
289 | |||
290 | /** |
||
291 | * @Then /^I should be informed that (this promotion) is no longer applied$/ |
||
292 | */ |
||
293 | public function iShouldBeInformedThatMyPromotionIsNoLongerApplied(PromotionInterface $promotion) |
||
300 | |||
301 | /** |
||
302 | * @Then /^I should be informed that (this payment method) has been disabled$/ |
||
303 | */ |
||
304 | public function iShouldBeInformedThatThisPaymentMethodHasBeenDisabled(PaymentMethodInterface $paymentMethod) |
||
314 | |||
315 | /** |
||
316 | * @Then /^I should be informed that (this product) has been disabled$/ |
||
317 | */ |
||
318 | public function iShouldBeInformedThatThisProductHasBeenDisabled(ProductInterface $product) |
||
328 | |||
329 | /** |
||
330 | * @Then I should be informed that order total has been changed |
||
331 | */ |
||
332 | public function iShouldBeInformedThatOrderTotalHasBeenChanged() |
||
339 | |||
340 | /** |
||
341 | * @Then /^(this promotion) should give "([^"]+)" discount on shipping$/ |
||
342 | */ |
||
343 | public function thisPromotionShouldGiveDiscountOnShipping(PromotionInterface $promotion, string $discount): void |
||
344 | { |
||
345 | Assert::true($this->completePage->hasShippingPromotionWithDiscount($promotion->getName(), $discount)); |
||
346 | } |
||
347 | } |
||
348 |