These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the Sylius package. |
||
5 | * |
||
6 | * (c) Paweł Jędrzejewski |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | declare(strict_types=1); |
||
13 | |||
14 | namespace Sylius\Behat\Context\Ui\Admin; |
||
15 | |||
16 | use Behat\Behat\Context\Context; |
||
17 | use Sylius\Behat\NotificationType; |
||
18 | use Sylius\Behat\Page\Admin\Order\HistoryPageInterface; |
||
19 | use Sylius\Behat\Page\Admin\Order\IndexPageInterface; |
||
20 | use Sylius\Behat\Page\Admin\Order\ShowPageInterface; |
||
21 | use Sylius\Behat\Page\Admin\Order\UpdatePageInterface; |
||
22 | use Sylius\Behat\Service\NotificationCheckerInterface; |
||
23 | use Sylius\Behat\Service\SharedSecurityServiceInterface; |
||
24 | use Sylius\Behat\Service\SharedStorageInterface; |
||
25 | use Sylius\Component\Addressing\Model\AddressInterface; |
||
26 | use Sylius\Component\Core\Model\AdminUserInterface; |
||
27 | use Sylius\Component\Core\Model\CustomerInterface; |
||
28 | use Sylius\Component\Core\Model\OrderInterface; |
||
29 | use Webmozart\Assert\Assert; |
||
30 | |||
31 | final class ManagingOrdersContext implements Context |
||
32 | { |
||
33 | /** |
||
34 | * @var SharedStorageInterface |
||
35 | */ |
||
36 | private $sharedStorage; |
||
37 | |||
38 | /** |
||
39 | * @var IndexPageInterface |
||
40 | */ |
||
41 | private $indexPage; |
||
42 | |||
43 | /** |
||
44 | * @var ShowPageInterface |
||
45 | */ |
||
46 | private $showPage; |
||
47 | |||
48 | /** |
||
49 | * @var UpdatePageInterface |
||
50 | */ |
||
51 | private $updatePage; |
||
52 | |||
53 | /** |
||
54 | * @var HistoryPageInterface |
||
55 | */ |
||
56 | private $historyPage; |
||
57 | |||
58 | /** |
||
59 | * @var NotificationCheckerInterface |
||
60 | */ |
||
61 | private $notificationChecker; |
||
62 | |||
63 | /** |
||
64 | * @var SharedSecurityServiceInterface |
||
65 | */ |
||
66 | private $sharedSecurityService; |
||
67 | |||
68 | /** |
||
69 | * @param SharedStorageInterface $sharedStorage |
||
70 | * @param IndexPageInterface $indexPage |
||
71 | * @param ShowPageInterface $showPage |
||
72 | * @param UpdatePageInterface $updatePage |
||
73 | * @param HistoryPageInterface $historyPage |
||
74 | * @param NotificationCheckerInterface $notificationChecker |
||
75 | * @param SharedSecurityServiceInterface $sharedSecurityService |
||
76 | */ |
||
77 | public function __construct( |
||
78 | SharedStorageInterface $sharedStorage, |
||
79 | IndexPageInterface $indexPage, |
||
80 | ShowPageInterface $showPage, |
||
81 | UpdatePageInterface $updatePage, |
||
82 | HistoryPageInterface $historyPage, |
||
83 | NotificationCheckerInterface $notificationChecker, |
||
84 | SharedSecurityServiceInterface $sharedSecurityService |
||
85 | ) { |
||
86 | $this->sharedStorage = $sharedStorage; |
||
87 | $this->indexPage = $indexPage; |
||
88 | $this->showPage = $showPage; |
||
89 | $this->updatePage = $updatePage; |
||
90 | $this->historyPage = $historyPage; |
||
91 | $this->notificationChecker = $notificationChecker; |
||
92 | $this->sharedSecurityService = $sharedSecurityService; |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @Given I am browsing orders |
||
97 | * @When I browse orders |
||
98 | */ |
||
99 | public function iBrowseOrders() |
||
100 | { |
||
101 | $this->indexPage->open(); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * @When I browse order's :order history |
||
106 | */ |
||
107 | public function iBrowseOrderHistory(OrderInterface $order) |
||
108 | { |
||
109 | $this->historyPage->open(['id' => $order->getId()]); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @Given /^I am viewing the summary of (this order)$/ |
||
114 | * @When I view the summary of the order :order |
||
115 | */ |
||
116 | public function iSeeTheOrder(OrderInterface $order) |
||
117 | { |
||
118 | $this->showPage->open(['id' => $order->getId()]); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @When /^I mark (this order) as paid$/ |
||
123 | */ |
||
124 | public function iMarkThisOrderAsAPaid(OrderInterface $order) |
||
125 | { |
||
126 | $this->showPage->completeOrderLastPayment($order); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @When /^I mark (this order)'s payment as refunded$/ |
||
131 | */ |
||
132 | public function iMarkThisOrderSPaymentAsRefunded(OrderInterface $order) |
||
133 | { |
||
134 | $this->showPage->refundOrderLastPayment($order); |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @When specify its tracking code as :trackingCode |
||
139 | */ |
||
140 | public function specifyItsTrackingCodeAs($trackingCode) |
||
141 | { |
||
142 | $this->showPage->specifyTrackingCode($trackingCode); |
||
143 | $this->sharedStorage->set('tracking_code', $trackingCode); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * @When /^I ship (this order)$/ |
||
148 | */ |
||
149 | public function iShipThisOrder(OrderInterface $order) |
||
150 | { |
||
151 | $this->showPage->shipOrder($order); |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * @When I switch the way orders are sorted by :fieldName |
||
156 | */ |
||
157 | public function iSwitchSortingBy($fieldName) |
||
158 | { |
||
159 | $this->indexPage->sortBy($fieldName); |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * @When I specify filter date from as :dateTime |
||
164 | */ |
||
165 | public function iSpecifyFilterDateFromAs($dateTime) |
||
166 | { |
||
167 | $this->indexPage->specifyFilterDateFrom($dateTime); |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * @When I specify filter date to as :dateTime |
||
172 | */ |
||
173 | public function iSpecifyFilterDateToAs($dateTime) |
||
174 | { |
||
175 | $this->indexPage->specifyFilterDateTo($dateTime); |
||
176 | } |
||
177 | |||
178 | /** |
||
179 | * @When I choose :channelName as a channel filter |
||
180 | */ |
||
181 | public function iChooseChannelAsAChannelFilter($channelName) |
||
182 | { |
||
183 | $this->indexPage->chooseChannelFilter($channelName); |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * @When I choose :currencyName as the filter currency |
||
188 | */ |
||
189 | public function iChooseCurrencyAsTheFilterCurrency($currencyName) |
||
190 | { |
||
191 | $this->indexPage->chooseCurrencyFilter($currencyName); |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * @When I specify filter total being greater than :total |
||
196 | */ |
||
197 | public function iSpecifyFilterTotalBeingGreaterThan($total) |
||
198 | { |
||
199 | $this->indexPage->specifyFilterTotalGreaterThan($total); |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * @When I specify filter total being less than :total |
||
204 | */ |
||
205 | public function iSpecifyFilterTotalBeingLessThan($total) |
||
206 | { |
||
207 | $this->indexPage->specifyFilterTotalLessThan($total); |
||
208 | } |
||
209 | |||
210 | /** |
||
211 | * @When I filter |
||
212 | */ |
||
213 | public function iFilter() |
||
214 | { |
||
215 | $this->indexPage->filter(); |
||
216 | } |
||
217 | |||
218 | /** |
||
219 | * @Then I should see a single order from customer :customer |
||
220 | */ |
||
221 | public function iShouldSeeASingleOrderFromCustomer(CustomerInterface $customer) |
||
222 | { |
||
223 | Assert::true($this->indexPage->isSingleResourceOnPage(['customer' => $customer->getEmail()])); |
||
224 | } |
||
225 | |||
226 | /** |
||
227 | * @Then it should have been placed by the customer :customerEmail |
||
228 | */ |
||
229 | public function itShouldBePlacedByCustomer($customerEmail) |
||
230 | { |
||
231 | Assert::true($this->showPage->hasCustomer($customerEmail)); |
||
232 | } |
||
233 | |||
234 | /** |
||
235 | * @Then it should be shipped to :customerName, :street, :postcode, :city, :countryName |
||
236 | * @Then /^(this order) should (?:|still )be shipped to "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"$/ |
||
237 | */ |
||
238 | public function itShouldBeShippedTo( |
||
239 | OrderInterface $order = null, |
||
240 | $customerName, |
||
241 | $street, |
||
242 | $postcode, |
||
243 | $city, |
||
244 | $countryName |
||
245 | ) { |
||
246 | if (null !== $order) { |
||
247 | $this->iSeeTheOrder($order); |
||
248 | } |
||
249 | |||
250 | Assert::true($this->showPage->hasShippingAddress($customerName, $street, $postcode, $city, $countryName)); |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * @Then it should be billed to :customerName, :street, :postcode, :city, :countryName |
||
255 | * @Then the order should be billed to :customerName, :street, :postcode, :city, :countryName |
||
256 | * @Then /^(this order) bill should (?:|still )be shipped to "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"$/ |
||
257 | */ |
||
258 | public function itShouldBeBilledTo( |
||
259 | OrderInterface $order = null, |
||
260 | $customerName, |
||
261 | $street, |
||
262 | $postcode, |
||
263 | $city, |
||
264 | $countryName |
||
265 | ) { |
||
266 | if (null !== $order) { |
||
267 | $this->iSeeTheOrder($order); |
||
268 | } |
||
269 | |||
270 | Assert::true($this->showPage->hasBillingAddress($customerName, $street, $postcode, $city, $countryName)); |
||
271 | } |
||
272 | |||
273 | /** |
||
274 | * @Then it should be shipped via the :shippingMethodName shipping method |
||
275 | */ |
||
276 | public function itShouldBeShippedViaShippingMethod($shippingMethodName) |
||
277 | { |
||
278 | Assert::true($this->showPage->hasShipment($shippingMethodName)); |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * @Then it should be paid with :paymentMethodName |
||
283 | */ |
||
284 | public function itShouldBePaidWith($paymentMethodName) |
||
285 | { |
||
286 | Assert::true($this->showPage->hasPayment($paymentMethodName)); |
||
287 | } |
||
288 | |||
289 | /** |
||
290 | * @Then /^it should have (\d+) items$/ |
||
291 | * @Then I should see :amount orders in the list |
||
292 | * @Then I should see a single order in the list |
||
293 | */ |
||
294 | public function itShouldHaveAmountOfItems($amount = 1) |
||
295 | { |
||
296 | Assert::same($this->showPage->countItems(), (int) $amount); |
||
297 | } |
||
298 | |||
299 | /** |
||
300 | * @Then the product named :productName should be in the items list |
||
301 | */ |
||
302 | public function theProductShouldBeInTheItemsList($productName) |
||
303 | { |
||
304 | Assert::true($this->showPage->isProductInTheList($productName)); |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * @Then the order's items total should be :itemsTotal |
||
309 | */ |
||
310 | public function theOrdersItemsTotalShouldBe($itemsTotal) |
||
311 | { |
||
312 | Assert::eq($this->showPage->getItemsTotal(), $itemsTotal); |
||
313 | } |
||
314 | |||
315 | /** |
||
316 | * @Then /^the order's total should(?:| still) be "([^"]+)"$/ |
||
317 | */ |
||
318 | public function theOrdersTotalShouldBe($total) |
||
319 | { |
||
320 | Assert::eq($this->showPage->getTotal(), $total); |
||
321 | } |
||
322 | |||
323 | /** |
||
324 | * @Then there should be a shipping charge :shippingCharge |
||
325 | */ |
||
326 | public function theOrdersShippingChargesShouldBe($shippingCharge) |
||
327 | { |
||
328 | Assert::true($this->showPage->hasShippingCharge($shippingCharge)); |
||
329 | } |
||
330 | |||
331 | /** |
||
332 | * @Then the order's shipping total should be :shippingTotal |
||
333 | */ |
||
334 | public function theOrdersShippingTotalShouldBe($shippingTotal) |
||
335 | { |
||
336 | Assert::eq($this->showPage->getShippingTotal(), $shippingTotal); |
||
337 | } |
||
338 | |||
339 | /** |
||
340 | * @Then the order's payment should (also) be :paymentAmount |
||
341 | */ |
||
342 | public function theOrdersPaymentShouldBe($paymentAmount) |
||
343 | { |
||
344 | Assert::eq($this->showPage->getPaymentAmount(), $paymentAmount); |
||
345 | } |
||
346 | |||
347 | /** |
||
348 | * @Then the order should have tax :tax |
||
349 | */ |
||
350 | public function theOrderShouldHaveTax($tax) |
||
351 | { |
||
352 | Assert::true($this->showPage->hasTax($tax)); |
||
353 | } |
||
354 | |||
355 | /** |
||
356 | * @Then /^the order's tax total should(?:| still) be "([^"]+)"$/ |
||
357 | */ |
||
358 | public function theOrdersTaxTotalShouldBe($taxTotal) |
||
359 | { |
||
360 | Assert::eq($this->showPage->getTaxTotal(), $taxTotal); |
||
361 | } |
||
362 | |||
363 | /** |
||
364 | * @Then the order's promotion discount should be :promotionDiscount |
||
365 | */ |
||
366 | public function theOrdersPromotionDiscountShouldBe($promotionDiscount) |
||
367 | { |
||
368 | Assert::true($this->showPage->hasPromotionDiscount($promotionDiscount)); |
||
369 | } |
||
370 | |||
371 | /** |
||
372 | * @Then the order's shipping promotion should be :promotion |
||
373 | */ |
||
374 | public function theOrdersShippingPromotionDiscountShouldBe($promotionData) |
||
375 | { |
||
376 | Assert::same($this->showPage->getShippingPromotionData(), $promotionData); |
||
377 | } |
||
378 | |||
379 | /** |
||
380 | * @Then /^the order's promotion total should(?:| still) be "([^"]+)"$/ |
||
381 | */ |
||
382 | public function theOrdersPromotionTotalShouldBe($promotionTotal) |
||
383 | { |
||
384 | Assert::eq($this->showPage->getPromotionTotal(), $promotionTotal); |
||
385 | } |
||
386 | |||
387 | /** |
||
388 | * @When I check :itemName data |
||
389 | */ |
||
390 | public function iCheckData($itemName) |
||
391 | { |
||
392 | $this->sharedStorage->set('item', $itemName); |
||
393 | } |
||
394 | |||
395 | /** |
||
396 | * @Then /^(its) code should be "([^"]+)"$/ |
||
397 | */ |
||
398 | public function itemCodeShouldBe($itemName, $code) |
||
399 | { |
||
400 | Assert::same($this->showPage->getItemCode($itemName), $code); |
||
401 | } |
||
402 | |||
403 | /** |
||
404 | * @Then /^(its) unit price should be ([^"]+)$/ |
||
405 | */ |
||
406 | public function itemUnitPriceShouldBe($itemName, $unitPrice) |
||
407 | { |
||
408 | Assert::eq($this->showPage->getItemUnitPrice($itemName), $unitPrice); |
||
409 | } |
||
410 | |||
411 | /** |
||
412 | * @Then /^(its) discounted unit price should be ([^"]+)$/ |
||
413 | */ |
||
414 | public function itemDiscountedUnitPriceShouldBe($itemName, $discountedUnitPrice) |
||
415 | { |
||
416 | Assert::eq($this->showPage->getItemDiscountedUnitPrice($itemName), $discountedUnitPrice); |
||
417 | } |
||
418 | |||
419 | /** |
||
420 | * @Then /^(its) quantity should be ([^"]+)$/ |
||
421 | */ |
||
422 | public function itemQuantityShouldBe($itemName, $quantity) |
||
423 | { |
||
424 | Assert::eq($this->showPage->getItemQuantity($itemName), $quantity); |
||
425 | } |
||
426 | |||
427 | /** |
||
428 | * @Then /^(its) subtotal should be ([^"]+)$/ |
||
429 | */ |
||
430 | public function itemSubtotalShouldBe($itemName, $subtotal) |
||
431 | { |
||
432 | Assert::eq($this->showPage->getItemSubtotal($itemName), $subtotal); |
||
433 | } |
||
434 | |||
435 | /** |
||
436 | * @Then /^(its) discount should be ([^"]+)$/ |
||
437 | */ |
||
438 | public function theItemShouldHaveDiscount($itemName, $discount) |
||
439 | { |
||
440 | Assert::eq($this->showPage->getItemDiscount($itemName), $discount); |
||
441 | } |
||
442 | |||
443 | /** |
||
444 | * @Then /^(its) tax should be ([^"]+)$/ |
||
445 | */ |
||
446 | public function itemTaxShouldBe($itemName, $tax) |
||
447 | { |
||
448 | Assert::eq($this->showPage->getItemTax($itemName), $tax); |
||
449 | } |
||
450 | |||
451 | /** |
||
452 | * @Then /^(its) total should be ([^"]+)$/ |
||
453 | */ |
||
454 | public function itemTotalShouldBe($itemName, $total) |
||
455 | { |
||
456 | Assert::eq($this->showPage->getItemTotal($itemName), $total); |
||
457 | } |
||
458 | |||
459 | /** |
||
460 | * @Then I should be notified that the order's payment has been successfully completed |
||
461 | */ |
||
462 | public function iShouldBeNotifiedThatTheOrderSPaymentHasBeenSuccessfullyCompleted() |
||
463 | { |
||
464 | $this->notificationChecker->checkNotification( |
||
465 | 'Payment has been successfully updated.', |
||
466 | NotificationType::success() |
||
467 | ); |
||
468 | } |
||
469 | |||
470 | /** |
||
471 | * @Then I should be notified that the order's payment has been successfully refunded |
||
472 | */ |
||
473 | public function iShouldBeNotifiedThatTheOrderSPaymentHasBeenSuccessfullyRefunded() |
||
474 | { |
||
475 | $this->notificationChecker->checkNotification( |
||
476 | 'Payment has been successfully refunded.', |
||
477 | NotificationType::success() |
||
478 | ); |
||
479 | } |
||
480 | |||
481 | /** |
||
482 | * @Then it should have payment state :paymentState |
||
483 | * @Then it should have payment with state :paymentState |
||
484 | */ |
||
485 | public function itShouldHavePaymentState($paymentState) |
||
486 | { |
||
487 | Assert::true($this->showPage->hasPayment($paymentState)); |
||
488 | } |
||
489 | |||
490 | /** |
||
491 | * @Then it should have order's payment state :orderPaymentState |
||
492 | */ |
||
493 | public function itShouldHaveOrderPaymentState($orderPaymentState) |
||
494 | { |
||
495 | Assert::same($this->showPage->getPaymentState(), $orderPaymentState); |
||
496 | } |
||
497 | |||
498 | /** |
||
499 | * @Then it should have order's shipping state :orderShippingState |
||
500 | */ |
||
501 | public function itShouldHaveOrderShippingState($orderShippingState) |
||
502 | { |
||
503 | Assert::same($this->showPage->getShippingState(), $orderShippingState); |
||
504 | } |
||
505 | |||
506 | /** |
||
507 | * @Then it's payment state should be refunded |
||
508 | */ |
||
509 | public function orderPaymentStateShouldBeRefunded() |
||
510 | { |
||
511 | Assert::same($this->showPage->getPaymentState(), 'Refunded'); |
||
512 | } |
||
513 | |||
514 | /** |
||
515 | * @Then /^I should not be able to mark (this order) as paid again$/ |
||
516 | */ |
||
517 | public function iShouldNotBeAbleToFinalizeItsPayment(OrderInterface $order) |
||
518 | { |
||
519 | Assert::false($this->showPage->canCompleteOrderLastPayment($order)); |
||
520 | } |
||
521 | |||
522 | /** |
||
523 | * @Then I should be notified that the order has been successfully shipped |
||
524 | */ |
||
525 | public function iShouldBeNotifiedThatTheOrderHasBeenSuccessfullyShipped() |
||
526 | { |
||
527 | $this->notificationChecker->checkNotification( |
||
528 | 'Shipment has been successfully updated.', |
||
529 | NotificationType::success() |
||
530 | ); |
||
531 | } |
||
532 | |||
533 | /** |
||
534 | * @Then /^I should not be able to ship (this order)$/ |
||
535 | */ |
||
536 | public function iShouldNotBeAbleToShipThisOrder(OrderInterface $order) |
||
537 | { |
||
538 | Assert::false($this->showPage->canShipOrder($order)); |
||
539 | } |
||
540 | |||
541 | /** |
||
542 | * @When I cancel this order |
||
543 | */ |
||
544 | public function iCancelThisOrder() |
||
545 | { |
||
546 | $this->showPage->cancelOrder(); |
||
547 | } |
||
548 | |||
549 | /** |
||
550 | * @Then I should be notified that it has been successfully updated |
||
551 | */ |
||
552 | public function iShouldBeNotifiedAboutItHasBeenSuccessfullyCanceled() |
||
553 | { |
||
554 | $this->notificationChecker->checkNotification( |
||
555 | 'Order has been successfully updated.', |
||
556 | NotificationType::success() |
||
557 | ); |
||
558 | } |
||
559 | |||
560 | /** |
||
561 | * @Then I should not be able to cancel this order |
||
562 | */ |
||
563 | public function iShouldNotBeAbleToCancelThisOrder() |
||
564 | { |
||
565 | Assert::false($this->showPage->hasCancelButton()); |
||
566 | } |
||
567 | |||
568 | /** |
||
569 | * @Then this order should have state :state |
||
570 | * @Then its state should be :state |
||
571 | */ |
||
572 | public function itsStateShouldBe($state) |
||
573 | { |
||
574 | Assert::same($this->showPage->getOrderState(), $state); |
||
575 | } |
||
576 | |||
577 | /** |
||
578 | * @Then it should( still) have a :state state |
||
579 | */ |
||
580 | public function itShouldHaveState($state) |
||
581 | { |
||
582 | Assert::true($this->indexPage->isSingleResourceOnPage(['state' => $state])); |
||
583 | } |
||
584 | |||
585 | /** |
||
586 | * @Then /^(the administrator) should know about (this additional note) for (this order made by "[^"]+")$/ |
||
587 | */ |
||
588 | public function theCustomerServiceShouldKnowAboutThisAdditionalNotes( |
||
589 | AdminUserInterface $user, |
||
590 | $note, |
||
591 | OrderInterface $order |
||
592 | ) { |
||
593 | $this->sharedSecurityService->performActionAsAdminUser( |
||
594 | $user, |
||
595 | function () use ($note, $order) { |
||
596 | $this->showPage->open(['id' => $order->getId()]); |
||
597 | |||
598 | Assert::true($this->showPage->hasNote($note)); |
||
599 | } |
||
600 | ); |
||
601 | } |
||
602 | |||
603 | /** |
||
604 | * @Then I should see an order with :orderNumber number |
||
605 | */ |
||
606 | public function iShouldSeeOrderWithNumber($orderNumber) |
||
607 | { |
||
608 | Assert::true($this->indexPage->isSingleResourceOnPage(['number' => $orderNumber])); |
||
609 | } |
||
610 | |||
611 | /** |
||
612 | * @Then I should not see an order with :orderNumber number |
||
613 | */ |
||
614 | public function iShouldNotSeeOrderWithNumber($orderNumber) |
||
615 | { |
||
616 | Assert::false($this->indexPage->isSingleResourceOnPage(['number' => $orderNumber])); |
||
617 | } |
||
618 | |||
619 | /** |
||
620 | * @Then I should not see any orders with currency :currencyCode |
||
621 | */ |
||
622 | public function iShouldNotSeeAnyOrderWithCurrency($currencyCode) |
||
623 | { |
||
624 | Assert::false($this->indexPage->isSingleResourceOnPage(['currencyCode' => $currencyCode])); |
||
625 | } |
||
626 | |||
627 | /** |
||
628 | * @Then the first order should have number :number |
||
629 | */ |
||
630 | public function theFirstOrderShouldHaveNumber($number) |
||
631 | { |
||
632 | Assert::eq($this->indexPage->getColumnFields('number')[0], $number); |
||
633 | } |
||
634 | |||
635 | /** |
||
636 | * @Then it should have shipment in state :shipmentState |
||
637 | */ |
||
638 | public function itShouldHaveShipmentState($shipmentState) |
||
639 | { |
||
640 | Assert::true($this->showPage->hasShipment($shipmentState)); |
||
641 | } |
||
642 | |||
643 | /** |
||
644 | * @Then order :orderNumber should have shipment state :shippingState |
||
645 | */ |
||
646 | public function thisOrderShipmentStateShouldBe($shippingState) |
||
647 | { |
||
648 | Assert::true($this->indexPage->isSingleResourceOnPage(['shippingState' => $shippingState])); |
||
649 | } |
||
650 | |||
651 | /** |
||
652 | * @Then the order :order should have order payment state :orderPaymentState |
||
653 | * @Then /^(this order) should have order payment state "([^"]+)"$/ |
||
654 | */ |
||
655 | public function theOrderShouldHavePaymentState(OrderInterface $order, $orderPaymentState) |
||
656 | { |
||
657 | Assert::true($this->indexPage->isSingleResourceOnPage(['paymentState' => $orderPaymentState])); |
||
658 | } |
||
659 | |||
660 | /** |
||
661 | * @Then the order :order should have order shipping state :orderShippingState |
||
662 | * @Then /^(this order) should have order shipping state "([^"]+)"$/ |
||
663 | */ |
||
664 | public function theOrderShouldHaveShippingState(OrderInterface $order, $orderShippingState) |
||
0 ignored issues
–
show
|
|||
665 | { |
||
666 | Assert::true($this->indexPage->isSingleResourceOnPage(['shippingState' => $orderShippingState])); |
||
667 | } |
||
668 | |||
669 | /** |
||
670 | * @Then /^there should be(?:| only) (\d+) payments?$/ |
||
671 | */ |
||
672 | public function theOrderShouldHaveNumberOfPayments($number) |
||
673 | { |
||
674 | Assert::same($this->showPage->getPaymentsCount(), (int) $number); |
||
675 | } |
||
676 | |||
677 | /** |
||
678 | * @Then I should see the order :orderNumber with total :total |
||
679 | */ |
||
680 | public function iShouldSeeTheOrderWithTotal($orderNumber, $total) |
||
681 | { |
||
682 | Assert::true($this->indexPage->isSingleResourceOnPage(['total' => $total])); |
||
683 | } |
||
684 | |||
685 | /** |
||
686 | * @When /^I want to modify a customer's (?:billing|shipping) address of (this order)$/ |
||
687 | */ |
||
688 | public function iWantToModifyACustomerSShippingAddress(OrderInterface $order) |
||
689 | { |
||
690 | $this->updatePage->open(['id' => $order->getId()]); |
||
691 | } |
||
692 | |||
693 | /** |
||
694 | * @When I save my changes |
||
695 | * @When I try to save my changes |
||
696 | */ |
||
697 | public function iSaveMyChanges() |
||
698 | { |
||
699 | $this->updatePage->saveChanges(); |
||
700 | } |
||
701 | |||
702 | /** |
||
703 | * @When /^I specify their (?:|new )shipping (address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)")$/ |
||
704 | */ |
||
705 | public function iSpecifyTheirShippingAddressAsFor(AddressInterface $address) |
||
706 | { |
||
707 | $this->updatePage->specifyShippingAddress($address); |
||
708 | } |
||
709 | |||
710 | /** |
||
711 | * @When /^I specify their (?:|new )billing (address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)")$/ |
||
712 | */ |
||
713 | public function iSpecifyTheirBillingAddressAsFor(AddressInterface $address) |
||
714 | { |
||
715 | $this->updatePage->specifyBillingAddress($address); |
||
716 | } |
||
717 | |||
718 | /** |
||
719 | * @Then /^I should be notified that the "([^"]+)", the "([^"]+)", the "([^"]+)" and the "([^"]+)" in (shipping|billing) details are required$/ |
||
720 | */ |
||
721 | public function iShouldBeNotifiedThatTheAndTheInShippingDetailsAreRequired($firstElement, $secondElement, $thirdElement, $fourthElement, $type) |
||
722 | { |
||
723 | $this->assertElementValidationMessage($type, $firstElement, sprintf('Please enter %s.', $firstElement)); |
||
724 | $this->assertElementValidationMessage($type, $secondElement, sprintf('Please enter %s.', $secondElement)); |
||
725 | $this->assertElementValidationMessage($type, $thirdElement, sprintf('Please enter %s.', $thirdElement)); |
||
726 | $this->assertElementValidationMessage($type, $fourthElement, sprintf('Please enter %s.', $fourthElement)); |
||
727 | } |
||
728 | |||
729 | /** |
||
730 | * @Then I should see :provinceName as province in the shipping address |
||
731 | */ |
||
732 | public function iShouldSeeAsProvinceInTheShippingAddress($provinceName) |
||
733 | { |
||
734 | Assert::true($this->showPage->hasShippingProvinceName($provinceName)); |
||
735 | } |
||
736 | |||
737 | /** |
||
738 | * @Then I should see :provinceName ad province in the billing address |
||
739 | */ |
||
740 | public function iShouldSeeAdProvinceInTheBillingAddress($provinceName) |
||
741 | { |
||
742 | Assert::true($this->showPage->hasBillingProvinceName($provinceName)); |
||
743 | } |
||
744 | |||
745 | /** |
||
746 | * @Then /^(the administrator) should know about IP address of (this order made by "[^"]+")$/ |
||
747 | */ |
||
748 | public function theAdministratorShouldKnowAboutIPAddressOfThisOrderMadeBy( |
||
749 | AdminUserInterface $user, |
||
750 | OrderInterface $order |
||
751 | ) { |
||
752 | $this->sharedSecurityService->performActionAsAdminUser( |
||
753 | $user, |
||
754 | function () use ($order) { |
||
755 | $this->showPage->open(['id' => $order->getId()]); |
||
756 | |||
757 | Assert::notSame($this->showPage->getIpAddressAssigned(), ''); |
||
758 | } |
||
759 | ); |
||
760 | } |
||
761 | |||
762 | /** |
||
763 | * @When /^I (clear old billing address) information$/ |
||
764 | */ |
||
765 | public function iSpecifyTheBillingAddressAs(AddressInterface $address) |
||
766 | { |
||
767 | $this->updatePage->specifyBillingAddress($address); |
||
768 | } |
||
769 | |||
770 | /** |
||
771 | * @When /^I (clear old shipping address) information$/ |
||
772 | */ |
||
773 | public function iSpecifyTheShippingAddressAs(AddressInterface $address) |
||
774 | { |
||
775 | $this->updatePage->specifyShippingAddress($address); |
||
776 | } |
||
777 | |||
778 | /** |
||
779 | * @When /^I do not specify new information$/ |
||
780 | */ |
||
781 | public function iDoNotSpecifyNewInformation() |
||
782 | { |
||
783 | // Intentionally left blank to fulfill context expectation |
||
784 | } |
||
785 | |||
786 | /** |
||
787 | * @Then /^(the administrator) should see that (order placed by "[^"]+") has "([^"]+)" currency$/ |
||
788 | */ |
||
789 | public function theAdministratorShouldSeeThatThisOrderHasBeenPlacedIn(AdminUserInterface $user, OrderInterface $order, $currency) |
||
790 | { |
||
791 | $this->sharedSecurityService->performActionAsAdminUser($user, function () use ($order, $currency) { |
||
792 | $this->showPage->open(['id' => $order->getId()]); |
||
793 | |||
794 | Assert::same($this->showPage->getOrderCurrency(), $currency); |
||
795 | }); |
||
796 | } |
||
797 | |||
798 | /** |
||
799 | * @Then /^(the administrator) should see the order with total "([^"]+)" in order list$/ |
||
800 | */ |
||
801 | public function theAdministratorShouldSeeTheOrderWithTotalInOrderList(AdminUserInterface $user, $total) |
||
802 | { |
||
803 | $this->sharedSecurityService->performActionAsAdminUser($user, function () use ($total) { |
||
804 | $this->indexPage->open(); |
||
805 | |||
806 | Assert::true($this->indexPage->isSingleResourceOnPage(['total' => $total])); |
||
807 | }); |
||
808 | } |
||
809 | |||
810 | /** |
||
811 | * @Then there should be :count changes in the registry |
||
812 | */ |
||
813 | public function thereShouldBeCountChangesInTheRegistry($count) |
||
814 | { |
||
815 | Assert::same($this->historyPage->countShippingAddressChanges(), (int) $count); |
||
816 | } |
||
817 | |||
818 | /** |
||
819 | * @Then I should not be able to refund this payment |
||
820 | */ |
||
821 | public function iShouldNotBeAbleToRefundThisPayment() |
||
822 | { |
||
823 | Assert::false($this->showPage->hasRefundButton()); |
||
824 | } |
||
825 | |||
826 | /** |
||
827 | * @Then I should not see information about payments |
||
828 | */ |
||
829 | public function iShouldNotSeeInformationAboutPayments() |
||
830 | { |
||
831 | Assert::same($this->showPage->getPaymentsCount(), 0); |
||
832 | } |
||
833 | |||
834 | /** |
||
835 | * @Then I should not see information about shipments |
||
836 | */ |
||
837 | public function iShouldNotSeeInformationAboutShipments() |
||
838 | { |
||
839 | Assert::same($this->showPage->getShipmentsCount(), 0); |
||
840 | } |
||
841 | |||
842 | /** |
||
843 | * @param string $type |
||
844 | * @param string $element |
||
845 | * @param string $expectedMessage |
||
846 | * |
||
847 | * @throws \InvalidArgumentException |
||
848 | */ |
||
849 | private function assertElementValidationMessage($type, $element, $expectedMessage) |
||
850 | { |
||
851 | $element = sprintf('%s_%s', $type, implode('_', explode(' ', $element))); |
||
852 | Assert::true($this->updatePage->checkValidationMessageFor($element, $expectedMessage)); |
||
853 | } |
||
854 | } |
||
855 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.