1 | <?php |
||
35 | final class CheckoutContext implements Context |
||
36 | { |
||
37 | /** |
||
38 | * @var SharedStorageInterface |
||
39 | */ |
||
40 | private $sharedStorage; |
||
41 | |||
42 | /** |
||
43 | * @var SecurityStepInterface |
||
44 | */ |
||
45 | private $checkoutSecurityStep; |
||
46 | |||
47 | /** |
||
48 | * @var AddressingStepInterface |
||
49 | */ |
||
50 | private $checkoutAddressingStep; |
||
51 | |||
52 | /** |
||
53 | * @var AddressingPageInterface |
||
54 | */ |
||
55 | private $addressingPage; |
||
56 | |||
57 | /** |
||
58 | * @var ShippingStepInterface |
||
59 | */ |
||
60 | private $checkoutShippingStep; |
||
61 | |||
62 | /** |
||
63 | * @var PaymentStepInterface |
||
64 | */ |
||
65 | private $checkoutPaymentStep; |
||
66 | |||
67 | /** |
||
68 | * @var FinalizeStepInterface |
||
69 | */ |
||
70 | private $checkoutFinalizeStep; |
||
71 | |||
72 | /** |
||
73 | * @var ThankYouPageInterface |
||
74 | */ |
||
75 | private $checkoutThankYouPage; |
||
76 | |||
77 | /** |
||
78 | * @var OrderPaymentsPageInterface |
||
79 | */ |
||
80 | private $orderPaymentsPage; |
||
81 | |||
82 | /** |
||
83 | * @var ShippingPageInterface |
||
84 | */ |
||
85 | private $shippingPage; |
||
86 | |||
87 | /** |
||
88 | * @var OrderRepositoryInterface |
||
89 | */ |
||
90 | private $orderRepository; |
||
91 | |||
92 | /** |
||
93 | * @param SharedStorageInterface $sharedStorage |
||
94 | * @param SecurityStepInterface $checkoutSecurityStep |
||
95 | * @param AddressingStepInterface $checkoutAddressingStep |
||
96 | * @param AddressingPageInterface $addressingPage |
||
97 | * @param ShippingStepInterface $checkoutShippingStep |
||
98 | * @param ShippingPageInterface $shippingPage |
||
99 | * @param PaymentStepInterface $checkoutPaymentStep |
||
100 | * @param FinalizeStepInterface $checkoutFinalizeStep |
||
101 | * @param ThankYouPageInterface $checkoutThankYouPage |
||
102 | * @param OrderPaymentsPageInterface $orderPaymentsPage |
||
103 | * @param OrderRepositoryInterface $orderRepository |
||
104 | */ |
||
105 | public function __construct( |
||
130 | |||
131 | /** |
||
132 | * @Given /^I proceed without selecting shipping address$/ |
||
133 | */ |
||
134 | public function iProceedWithoutSelectingShippingAddress() |
||
139 | |||
140 | /** |
||
141 | * @Given I am at the checkout addressing step |
||
142 | */ |
||
143 | public function iAmAtTheCheckoutAddressingStep() |
||
147 | |||
148 | /** |
||
149 | * @When /^I specify the shipping (address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)")$/ |
||
150 | * @When /^I (do not specify any shipping address) information$/ |
||
151 | */ |
||
152 | public function iSpecifyTheShippingAddressAs(AddressInterface $address) |
||
156 | |||
157 | /** |
||
158 | * @When /^I specify the billing (address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)")$/ |
||
159 | * @When /^I (do not specify any billing address) information$/ |
||
160 | */ |
||
161 | public function iSpecifyTheBillingAddressAs(AddressInterface $address) |
||
165 | |||
166 | /** |
||
167 | * @When /^I specified the shipping (address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)")$/ |
||
168 | */ |
||
169 | public function iSpecifiedTheShippingAddress(AddressInterface $address) |
||
175 | |||
176 | /** |
||
177 | * @When I choose the different billing address |
||
178 | */ |
||
179 | public function iChooseTheDifferentBillingAddress() |
||
183 | |||
184 | /** |
||
185 | * @When I specify the email as :email |
||
186 | * @When I do not specify the email |
||
187 | */ |
||
188 | public function iSpecifyTheEmail($email = null) |
||
192 | |||
193 | /** |
||
194 | * @When I select :shippingMethod shipping method |
||
195 | */ |
||
196 | public function iSelectShippingMethod($shippingMethod) |
||
200 | |||
201 | /** |
||
202 | * @Then I should not be able to select :shippingMethod shipping method |
||
203 | */ |
||
204 | public function iShouldNotBeAbleToSelectShippingMethod($shippingMethod) |
||
211 | |||
212 | /** |
||
213 | * @When I complete the addressing step |
||
214 | * @When I try to complete the addressing step |
||
215 | */ |
||
216 | public function iCompleteTheAddressingStep() |
||
220 | |||
221 | /** |
||
222 | * @When I complete the shipping step |
||
223 | */ |
||
224 | public function iCompleteTheShippingStep() |
||
228 | |||
229 | /** |
||
230 | * @When /^I proceed selecting "([^"]*)" as shipping country$/ |
||
231 | */ |
||
232 | public function iProceedSelectingShippingCountry($shippingCountry) |
||
246 | |||
247 | /** |
||
248 | * @When /^I proceed selecting "([^"]*)" as shipping country with "([^"]*)" method$/ |
||
249 | */ |
||
250 | public function iProceedSelectingShippingCountryAndShippingMethod($shippingCountry, $shippingMethodName) |
||
257 | |||
258 | /** |
||
259 | * @When /^I proceed selecting "([^"]+)" shipping method$/ |
||
260 | * @Given /^I chose "([^"]*)" shipping method$/ |
||
261 | */ |
||
262 | public function iProceedSelectingShippingMethod($shippingMethodName) |
||
266 | |||
267 | /** |
||
268 | * @When /^I choose "([^"]*)" payment method$/ |
||
269 | */ |
||
270 | public function iChoosePaymentMethod($paymentMethodName) |
||
276 | |||
277 | /** |
||
278 | * @When /^I proceed selecting "([^"]*)" as shipping country with "([^"]*)" payment method$/ |
||
279 | */ |
||
280 | public function iProceedSelectingShippingCountryAndPaymentMethod($shippingCountry, $paymentMethodName) |
||
286 | |||
287 | /** |
||
288 | * @When I proceed selecting :paymentMethodName payment method |
||
289 | */ |
||
290 | public function iProceedSelectingOfflinePaymentMethod($paymentMethodName) |
||
294 | |||
295 | /** |
||
296 | * @When /^I change shipping method to "([^"]*)"$/ |
||
297 | */ |
||
298 | public function iChangeShippingMethod($shippingMethodName) |
||
304 | |||
305 | /** |
||
306 | * @Given /^I proceed logging as "([^"]*)" with "([^"]*)" password$/ |
||
307 | */ |
||
308 | public function iProceedLoggingAs($login, $password) |
||
315 | |||
316 | /** |
||
317 | * @When /^I proceed as guest "([^"]*)" with "([^"]*)" as shipping country$/ |
||
318 | */ |
||
319 | public function iProceedLoggingAsGuestWithAsShippingCountry($email, $shippingCountry) |
||
326 | |||
327 | /** |
||
328 | * @When I confirm my order |
||
329 | */ |
||
330 | public function iConfirmMyOrder() |
||
334 | |||
335 | /** |
||
336 | * @Then I should see the thank you page |
||
337 | */ |
||
338 | public function iShouldSeeTheThankYouPage() |
||
346 | |||
347 | /** |
||
348 | * @Then I should be redirected back to the thank you page |
||
349 | */ |
||
350 | public function iShouldBeRedirectedBackToTheThankYouPage() |
||
356 | |||
357 | /** |
||
358 | * @Then I should be redirected back to the order payment page |
||
359 | */ |
||
360 | public function iShouldBeRedirectedBackToTheOrderPaymentPage() |
||
366 | |||
367 | /** |
||
368 | * @Then I should be on the checkout shipping step |
||
369 | */ |
||
370 | public function iShouldBeOnTheCheckoutShippingStep() |
||
377 | |||
378 | /** |
||
379 | * @Then I should see two cancelled payments and new one ready to be paid |
||
380 | */ |
||
381 | public function iShouldSeeTwoCancelledPaymentsAndNewOneReadyToBePaid() |
||
386 | |||
387 | /** |
||
388 | * @Then /^I should(?:| also) be notified that the "([^"]+)" and the "([^"]+)" in (shipping|billing) details are required$/ |
||
389 | */ |
||
390 | public function iShouldBeNotifiedThatTheAndTheInShippingDetailsAreRequired($firstElement, $secondElement, $type) |
||
395 | |||
396 | /** |
||
397 | * @Then I should be informed that my order cannot be shipped to this address |
||
398 | */ |
||
399 | public function iShouldBeInformedThatMyOrderCannotBeShippedToThisAddress() |
||
406 | |||
407 | /** |
||
408 | * @param string $type |
||
409 | * @param string $element |
||
410 | * @param string $expectedMessage |
||
411 | * |
||
412 | * @throws \InvalidArgumentException |
||
413 | */ |
||
414 | private function assertElementValidationMessage($type, $element, $expectedMessage) |
||
422 | |||
423 | /** |
||
424 | * @return OrderInterface |
||
425 | * |
||
426 | * @throws \RuntimeException |
||
427 | */ |
||
428 | private function getLastOrder() |
||
440 | } |
||
441 |