1 | <?php |
||
18 | final class CheckoutAddressingContext implements Context |
||
19 | { |
||
20 | /** |
||
21 | * @var SharedStorageInterface |
||
22 | */ |
||
23 | private $sharedStorage; |
||
24 | |||
25 | /** |
||
26 | * @var AddressPageInterface |
||
27 | */ |
||
28 | private $addressPage; |
||
29 | |||
30 | /** |
||
31 | * @var FactoryInterface |
||
32 | */ |
||
33 | private $addressFactory; |
||
34 | |||
35 | /** |
||
36 | * @var AddressComparatorInterface |
||
37 | */ |
||
38 | private $addressComparator; |
||
39 | |||
40 | /** |
||
41 | * @var SelectShippingPageInterface |
||
42 | */ |
||
43 | private $selectShippingPage; |
||
44 | |||
45 | /** |
||
46 | * @param SharedStorageInterface $sharedStorage |
||
47 | * @param AddressPageInterface $addressPage |
||
48 | * @param FactoryInterface $addressFactory |
||
49 | * @param AddressComparatorInterface $addressComparator |
||
50 | * @param SelectShippingPageInterface $selectShippingPage |
||
51 | */ |
||
52 | public function __construct( |
||
65 | |||
66 | /** |
||
67 | * @Given I am at the checkout addressing step |
||
68 | * @When I go back to addressing step of the checkout |
||
69 | */ |
||
70 | public function iAmAtTheCheckoutAddressingStep() |
||
74 | |||
75 | /** |
||
76 | * @Given /^I have completed addressing step with email "([^"]+)" and ("[^"]+" based shipping address)$/ |
||
77 | * @When /^I complete addressing step with email "([^"]+)" and ("[^"]+" based shipping address)$/ |
||
78 | */ |
||
79 | public function iCompleteAddressingStepWithEmail($email, AddressInterface $address) |
||
86 | |||
87 | /** |
||
88 | * @When I specify the province name manually as :provinceName for shipping address |
||
89 | */ |
||
90 | public function iSpecifyTheProvinceNameManuallyAsForShippingAddress($provinceName) |
||
94 | |||
95 | /** |
||
96 | * @When I specify the province name manually as :provinceName for billing address |
||
97 | */ |
||
98 | public function iSpecifyTheProvinceNameManuallyAsForBillingAddress($provinceName) |
||
102 | |||
103 | /** |
||
104 | * @When I try to open checkout addressing page |
||
105 | */ |
||
106 | public function iTryToOpenCheckoutAddressingPage() |
||
110 | |||
111 | /** |
||
112 | * @When /^I choose ("[^"]+" street) for shipping address$/ |
||
113 | */ |
||
114 | public function iChooseForShippingAddress(AddressInterface $address) |
||
118 | |||
119 | /** |
||
120 | * @When /^I choose ("[^"]+" street) for billing address$/ |
||
121 | */ |
||
122 | public function iChooseForBillingAddress(AddressInterface $address) |
||
127 | |||
128 | /** |
||
129 | * @When /^I specify the shipping (address as "[^"]+", "[^"]+", "[^"]+", "[^"]+" for "[^"]+")$/ |
||
130 | * @When /^I specify the shipping (address for "[^"]+" from "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+")$/ |
||
131 | * @When /^I (do not specify any shipping address) information$/ |
||
132 | * @When /^I change the shipping (address to "[^"]+", "[^"]+", "[^"]+", "[^"]+" for "[^"]+")$/ |
||
133 | */ |
||
134 | public function iSpecifyTheShippingAddressAs(AddressInterface $address) |
||
145 | |||
146 | /** |
||
147 | * @When I specify shipping country province as :province |
||
148 | */ |
||
149 | public function iSpecifyShippingCountryProvinceAs($province) |
||
153 | |||
154 | /** |
||
155 | * @When I specify billing country province as :province |
||
156 | */ |
||
157 | public function iSpecifyBillingCountryProvinceAs($province) |
||
161 | |||
162 | /** |
||
163 | * @When /^I specify the billing (address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)")$/ |
||
164 | * @When /^I specify the billing (address for "([^"]+)" from "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)")$/ |
||
165 | * @When /^I (do not specify any billing address) information$/ |
||
166 | */ |
||
167 | public function iSpecifyTheBillingAddressAs(AddressInterface $address) |
||
180 | |||
181 | /** |
||
182 | * @When /^I specified the shipping (address as "[^"]+", "[^"]+", "[^"]+", "[^"]+" for "[^"]+")$/ |
||
183 | */ |
||
184 | public function iSpecifiedTheShippingAddress(AddressInterface $address = null) |
||
198 | |||
199 | /** |
||
200 | * @When I specify the email as :email |
||
201 | * @When I do not specify the email |
||
202 | */ |
||
203 | public function iSpecifyTheEmail($email = null) |
||
207 | |||
208 | /** |
||
209 | * @When I complete the addressing step |
||
210 | * @When I try to complete the addressing step |
||
211 | */ |
||
212 | public function iCompleteTheAddressingStep() |
||
216 | |||
217 | /** |
||
218 | * @When I go back to store |
||
219 | */ |
||
220 | public function iGoBackToStore() |
||
224 | |||
225 | /** |
||
226 | * @When /^I proceed selecting ("[^"]+" as shipping country)$/ |
||
227 | */ |
||
228 | public function iProceedSelectingShippingCountry(CountryInterface $shippingCountry = null) |
||
239 | |||
240 | /** |
||
241 | * @When /^I proceed as guest "([^"]*)" with ("[^"]+" as shipping country)$/ |
||
242 | */ |
||
243 | public function iProceedLoggingAsGuestWithAsShippingCountry($email, CountryInterface $shippingCountry = null) |
||
255 | |||
256 | /** |
||
257 | * @When I specify the password as :password |
||
258 | */ |
||
259 | public function iSpecifyThePasswordAs($password) |
||
263 | |||
264 | /** |
||
265 | * @When I sign in |
||
266 | */ |
||
267 | public function iSignIn() |
||
271 | |||
272 | /** |
||
273 | * @Then I should have :countryName selected as country |
||
274 | */ |
||
275 | public function iShouldHaveSelectedAsCountry($countryName) |
||
279 | |||
280 | /** |
||
281 | * @Then I should have no country selected |
||
282 | */ |
||
283 | public function iShouldHaveNoCountrySelected() |
||
287 | |||
288 | /** |
||
289 | * @Then I should be able to log in |
||
290 | */ |
||
291 | public function iShouldBeAbleToLogIn() |
||
295 | |||
296 | /** |
||
297 | * @Then the login form should no longer be accessible |
||
298 | */ |
||
299 | public function theLoginFormShouldNoLongerBeAccessible() |
||
303 | |||
304 | /** |
||
305 | * @Then I should be notified about bad credentials |
||
306 | */ |
||
307 | public function iShouldBeNotifiedAboutBadCredentials() |
||
311 | |||
312 | /** |
||
313 | * @Then I should be redirected to the addressing step |
||
314 | * @Then I should be on the checkout addressing step |
||
315 | */ |
||
316 | public function iShouldBeRedirectedToTheAddressingStep() |
||
320 | |||
321 | /** |
||
322 | * @Then I should be able to go to the shipping step again |
||
323 | */ |
||
324 | public function iShouldBeAbleToGoToTheShippingStepAgain() |
||
330 | |||
331 | /** |
||
332 | * @Then I should not be able to specify province name manually for shipping address |
||
333 | */ |
||
334 | public function iShouldNotBeAbleToSpecifyProvinceNameManuallyForShippingAddress() |
||
338 | |||
339 | /** |
||
340 | * @Then I should not be able to specify province name manually for billing address |
||
341 | */ |
||
342 | public function iShouldNotBeAbleToSpecifyProvinceNameManuallyForBillingAddress() |
||
346 | |||
347 | /** |
||
348 | * @Then /^(address "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+") should be filled as shipping address$/ |
||
349 | */ |
||
350 | public function addressShouldBeFilledAsShippingAddress(AddressInterface $address) |
||
354 | |||
355 | /** |
||
356 | * @Then /^(address "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+") should be filled as billing address$/ |
||
357 | */ |
||
358 | public function addressShouldBeFilledAsBillingAddress(AddressInterface $address) |
||
362 | |||
363 | /** |
||
364 | * @Then /^I should(?:| also) be notified that the "([^"]+)" and the "([^"]+)" in (shipping|billing) details are required$/ |
||
365 | */ |
||
366 | public function iShouldBeNotifiedThatTheAndTheInShippingDetailsAreRequired($firstElement, $secondElement, $type) |
||
371 | |||
372 | /** |
||
373 | * @return AddressInterface |
||
374 | */ |
||
375 | private function createDefaultAddress() |
||
389 | |||
390 | /** |
||
391 | * @param string $type |
||
392 | * @param string $element |
||
393 | * @param string $expectedMessage |
||
394 | * |
||
395 | * @throws \InvalidArgumentException |
||
396 | */ |
||
397 | private function assertElementValidationMessage($type, $element, $expectedMessage) |
||
402 | } |
||
403 |