Complex classes like ManagingOrdersContext often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ManagingOrdersContext, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
31 | final class ManagingOrdersContext implements Context |
||
32 | { |
||
33 | /** @var SharedStorageInterface */ |
||
34 | private $sharedStorage; |
||
35 | |||
36 | /** @var IndexPageInterface */ |
||
37 | private $indexPage; |
||
38 | |||
39 | /** @var ShowPageInterface */ |
||
40 | private $showPage; |
||
41 | |||
42 | /** @var UpdatePageInterface */ |
||
43 | private $updatePage; |
||
44 | |||
45 | /** @var HistoryPageInterface */ |
||
46 | private $historyPage; |
||
47 | |||
48 | /** @var NotificationCheckerInterface */ |
||
49 | private $notificationChecker; |
||
50 | |||
51 | /** @var SharedSecurityServiceInterface */ |
||
52 | private $sharedSecurityService; |
||
53 | |||
54 | public function __construct( |
||
71 | |||
72 | /** |
||
73 | * @Given I am browsing orders |
||
74 | * @When I browse orders |
||
75 | */ |
||
76 | public function iBrowseOrders() |
||
80 | |||
81 | /** |
||
82 | * @When I browse order's :order history |
||
83 | */ |
||
84 | public function iBrowseOrderHistory(OrderInterface $order) |
||
88 | |||
89 | /** |
||
90 | * @Given /^I am viewing the summary of (this order)$/ |
||
91 | * @When I view the summary of the order :order |
||
92 | */ |
||
93 | public function iSeeTheOrder(OrderInterface $order) |
||
97 | |||
98 | /** |
||
99 | * @When /^I mark (this order) as paid$/ |
||
100 | */ |
||
101 | public function iMarkThisOrderAsAPaid(OrderInterface $order) |
||
105 | |||
106 | /** |
||
107 | * @When /^I mark (this order)'s payment as refunded$/ |
||
108 | */ |
||
109 | public function iMarkThisOrderSPaymentAsRefunded(OrderInterface $order) |
||
113 | |||
114 | /** |
||
115 | * @When specify its tracking code as :trackingCode |
||
116 | */ |
||
117 | public function specifyItsTrackingCodeAs($trackingCode) |
||
122 | |||
123 | /** |
||
124 | * @When /^I ship (this order)$/ |
||
125 | */ |
||
126 | public function iShipThisOrder(OrderInterface $order) |
||
130 | |||
131 | /** |
||
132 | * @When I switch the way orders are sorted by :fieldName |
||
133 | */ |
||
134 | public function iSwitchSortingBy($fieldName) |
||
138 | |||
139 | /** |
||
140 | * @When I specify filter date from as :dateTime |
||
141 | */ |
||
142 | public function iSpecifyFilterDateFromAs($dateTime) |
||
146 | |||
147 | /** |
||
148 | * @When I specify filter date to as :dateTime |
||
149 | */ |
||
150 | public function iSpecifyFilterDateToAs($dateTime) |
||
154 | |||
155 | /** |
||
156 | * @When I choose :channelName as a channel filter |
||
157 | */ |
||
158 | public function iChooseChannelAsAChannelFilter($channelName) |
||
162 | |||
163 | /** |
||
164 | * @When I choose :currencyName as the filter currency |
||
165 | */ |
||
166 | public function iChooseCurrencyAsTheFilterCurrency($currencyName) |
||
170 | |||
171 | /** |
||
172 | * @When I specify filter total being greater than :total |
||
173 | */ |
||
174 | public function iSpecifyFilterTotalBeingGreaterThan($total) |
||
178 | |||
179 | /** |
||
180 | * @When I specify filter total being less than :total |
||
181 | */ |
||
182 | public function iSpecifyFilterTotalBeingLessThan($total) |
||
186 | |||
187 | /** |
||
188 | * @When I filter |
||
189 | */ |
||
190 | public function iFilter() |
||
194 | |||
195 | /** |
||
196 | * @Then I should see a single order from customer :customer |
||
197 | */ |
||
198 | public function iShouldSeeASingleOrderFromCustomer(CustomerInterface $customer) |
||
202 | |||
203 | /** |
||
204 | * @Then it should have been placed by the customer :customerEmail |
||
205 | */ |
||
206 | public function itShouldBePlacedByCustomer($customerEmail) |
||
210 | |||
211 | /** |
||
212 | * @Then it should be shipped to :customerName, :street, :postcode, :city, :countryName |
||
213 | * @Then /^(this order) should (?:|still )be shipped to "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"$/ |
||
214 | */ |
||
215 | public function itShouldBeShippedTo( |
||
229 | |||
230 | /** |
||
231 | * @Then it should be billed to :customerName, :street, :postcode, :city, :countryName |
||
232 | * @Then the order should be billed to :customerName, :street, :postcode, :city, :countryName |
||
233 | * @Then /^(this order) bill should (?:|still )be shipped to "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"$/ |
||
234 | */ |
||
235 | public function itShouldBeBilledTo( |
||
249 | |||
250 | /** |
||
251 | * @Then it should have no shipping address set |
||
252 | */ |
||
253 | public function itShouldHaveNoShippingAddressSet(): void |
||
257 | |||
258 | /** |
||
259 | * @Then it should be shipped via the :shippingMethodName shipping method |
||
260 | */ |
||
261 | public function itShouldBeShippedViaShippingMethod($shippingMethodName) |
||
265 | |||
266 | /** |
||
267 | * @Then it should be paid with :paymentMethodName |
||
268 | */ |
||
269 | public function itShouldBePaidWith($paymentMethodName) |
||
273 | |||
274 | /** |
||
275 | * @Then /^it should have (\d+) items$/ |
||
276 | * @Then I should see :amount orders in the list |
||
277 | * @Then I should see a single order in the list |
||
278 | */ |
||
279 | public function itShouldHaveAmountOfItems($amount = 1) |
||
283 | |||
284 | /** |
||
285 | * @Then the product named :productName should be in the items list |
||
286 | */ |
||
287 | public function theProductShouldBeInTheItemsList($productName) |
||
291 | |||
292 | /** |
||
293 | * @Then the order's items total should be :itemsTotal |
||
294 | */ |
||
295 | public function theOrdersItemsTotalShouldBe($itemsTotal) |
||
299 | |||
300 | /** |
||
301 | * @Then /^the order's total should(?:| still) be "([^"]+)"$/ |
||
302 | */ |
||
303 | public function theOrdersTotalShouldBe($total) |
||
307 | |||
308 | /** |
||
309 | * @Then there should be a shipping charge :shippingCharge |
||
310 | */ |
||
311 | public function theOrdersShippingChargesShouldBe($shippingCharge) |
||
315 | |||
316 | /** |
||
317 | * @Then the order's shipping total should be :shippingTotal |
||
318 | */ |
||
319 | public function theOrdersShippingTotalShouldBe($shippingTotal) |
||
323 | |||
324 | /** |
||
325 | * @Then the order's payment should (also) be :paymentAmount |
||
326 | */ |
||
327 | public function theOrdersPaymentShouldBe($paymentAmount) |
||
331 | |||
332 | /** |
||
333 | * @Then the order should have tax :tax |
||
334 | */ |
||
335 | public function theOrderShouldHaveTax($tax) |
||
339 | |||
340 | /** |
||
341 | * @Then /^the order's tax total should(?:| still) be "([^"]+)"$/ |
||
342 | */ |
||
343 | public function theOrdersTaxTotalShouldBe($taxTotal) |
||
347 | |||
348 | /** |
||
349 | * @Then the order's promotion discount should be :promotionAmount from :promotionName promotion |
||
350 | */ |
||
351 | public function theOrdersPromotionDiscountShouldBeFromPromotion(string $promotionAmount, string $promotionName): void |
||
352 | { |
||
353 | Assert::true($this->showPage->hasPromotionDiscount($promotionName, $promotionAmount)); |
||
354 | } |
||
355 | |||
356 | /** |
||
357 | * @Then the order's shipping promotion should be :promotion |
||
358 | */ |
||
359 | public function theOrdersShippingPromotionDiscountShouldBe($promotionData) |
||
363 | |||
364 | /** |
||
365 | * @Then /^the order's promotion total should(?:| still) be "([^"]+)"$/ |
||
366 | */ |
||
367 | public function theOrdersPromotionTotalShouldBe($promotionTotal) |
||
371 | |||
372 | /** |
||
373 | * @When I check :itemName data |
||
374 | */ |
||
375 | public function iCheckData($itemName) |
||
379 | |||
380 | /** |
||
381 | * @Then /^(its) code should be "([^"]+)"$/ |
||
382 | */ |
||
383 | public function itemCodeShouldBe($itemName, $code) |
||
387 | |||
388 | /** |
||
389 | * @Then /^(its) unit price should be ([^"]+)$/ |
||
390 | */ |
||
391 | public function itemUnitPriceShouldBe($itemName, $unitPrice) |
||
395 | |||
396 | /** |
||
397 | * @Then /^(its) discounted unit price should be ([^"]+)$/ |
||
398 | */ |
||
399 | public function itemDiscountedUnitPriceShouldBe($itemName, $discountedUnitPrice) |
||
403 | |||
404 | /** |
||
405 | * @Then /^(its) quantity should be ([^"]+)$/ |
||
406 | */ |
||
407 | public function itemQuantityShouldBe($itemName, $quantity) |
||
411 | |||
412 | /** |
||
413 | * @Then /^(its) subtotal should be ([^"]+)$/ |
||
414 | */ |
||
415 | public function itemSubtotalShouldBe($itemName, $subtotal) |
||
419 | |||
420 | /** |
||
421 | * @Then /^(its) discount should be ([^"]+)$/ |
||
422 | */ |
||
423 | public function theItemShouldHaveDiscount($itemName, $discount) |
||
427 | |||
428 | /** |
||
429 | * @Then /^(its) tax should be ([^"]+)$/ |
||
430 | */ |
||
431 | public function itemTaxShouldBe($itemName, $tax) |
||
435 | |||
436 | /** |
||
437 | * @Then /^(its) tax included in price should be ([^"]+)$/ |
||
438 | */ |
||
439 | public function itsTaxIncludedInPriceShouldBe(string $itemName, string $tax): void |
||
440 | { |
||
441 | Assert::same($this->showPage->getItemTaxIncludedInPrice($itemName), $tax); |
||
442 | } |
||
443 | |||
444 | /** |
||
445 | * @Then /^(its) total should be ([^"]+)$/ |
||
446 | */ |
||
447 | public function itemTotalShouldBe($itemName, $total) |
||
448 | { |
||
449 | Assert::eq($this->showPage->getItemTotal($itemName), $total); |
||
450 | } |
||
451 | |||
452 | /** |
||
453 | * @Then I should be notified that the order's payment has been successfully completed |
||
454 | */ |
||
455 | public function iShouldBeNotifiedThatTheOrderSPaymentHasBeenSuccessfullyCompleted() |
||
456 | { |
||
457 | $this->notificationChecker->checkNotification( |
||
458 | 'Payment has been successfully updated.', |
||
459 | NotificationType::success() |
||
460 | ); |
||
461 | } |
||
462 | |||
463 | /** |
||
464 | * @Then I should be notified that the order's payment has been successfully refunded |
||
465 | */ |
||
466 | public function iShouldBeNotifiedThatTheOrderSPaymentHasBeenSuccessfullyRefunded() |
||
467 | { |
||
468 | $this->notificationChecker->checkNotification( |
||
469 | 'Payment has been successfully refunded.', |
||
470 | NotificationType::success() |
||
471 | ); |
||
472 | } |
||
473 | |||
474 | /** |
||
475 | * @Then it should have payment state :paymentState |
||
476 | * @Then it should have payment with state :paymentState |
||
477 | */ |
||
478 | public function itShouldHavePaymentState($paymentState) |
||
479 | { |
||
480 | Assert::true($this->showPage->hasPayment($paymentState)); |
||
481 | } |
||
482 | |||
483 | /** |
||
484 | * @Then it should have order's payment state :orderPaymentState |
||
485 | */ |
||
486 | public function itShouldHaveOrderPaymentState($orderPaymentState) |
||
487 | { |
||
488 | Assert::same($this->showPage->getPaymentState(), $orderPaymentState); |
||
489 | } |
||
490 | |||
491 | /** |
||
492 | * @Then it should have order's shipping state :orderShippingState |
||
493 | */ |
||
494 | public function itShouldHaveOrderShippingState($orderShippingState) |
||
495 | { |
||
496 | Assert::same($this->showPage->getShippingState(), $orderShippingState); |
||
497 | } |
||
498 | |||
499 | /** |
||
500 | * @Then it's payment state should be refunded |
||
501 | */ |
||
502 | public function orderPaymentStateShouldBeRefunded() |
||
503 | { |
||
504 | Assert::same($this->showPage->getPaymentState(), 'Refunded'); |
||
505 | } |
||
506 | |||
507 | /** |
||
508 | * @Then /^I should not be able to mark (this order) as paid again$/ |
||
509 | */ |
||
510 | public function iShouldNotBeAbleToFinalizeItsPayment(OrderInterface $order) |
||
511 | { |
||
512 | Assert::false($this->showPage->canCompleteOrderLastPayment($order)); |
||
513 | } |
||
514 | |||
515 | /** |
||
516 | * @Then I should be notified that the order has been successfully shipped |
||
517 | */ |
||
518 | public function iShouldBeNotifiedThatTheOrderHasBeenSuccessfullyShipped() |
||
519 | { |
||
520 | $this->notificationChecker->checkNotification( |
||
521 | 'Shipment has been successfully updated.', |
||
522 | NotificationType::success() |
||
523 | ); |
||
524 | } |
||
525 | |||
526 | /** |
||
527 | * @Then /^I should not be able to ship (this order)$/ |
||
528 | */ |
||
529 | public function iShouldNotBeAbleToShipThisOrder(OrderInterface $order) |
||
530 | { |
||
531 | Assert::false($this->showPage->canShipOrder($order)); |
||
532 | } |
||
533 | |||
534 | /** |
||
535 | * @When I cancel this order |
||
536 | */ |
||
537 | public function iCancelThisOrder() |
||
538 | { |
||
539 | $this->showPage->cancelOrder(); |
||
540 | } |
||
541 | |||
542 | /** |
||
543 | * @Then I should be notified that it has been successfully updated |
||
544 | */ |
||
545 | public function iShouldBeNotifiedAboutItHasBeenSuccessfullyCanceled() |
||
546 | { |
||
547 | $this->notificationChecker->checkNotification( |
||
548 | 'Order has been successfully updated.', |
||
549 | NotificationType::success() |
||
550 | ); |
||
551 | } |
||
552 | |||
553 | /** |
||
554 | * @Then I should not be able to cancel this order |
||
555 | */ |
||
556 | public function iShouldNotBeAbleToCancelThisOrder() |
||
557 | { |
||
558 | Assert::false($this->showPage->hasCancelButton()); |
||
559 | } |
||
560 | |||
561 | /** |
||
562 | * @Then this order should have state :state |
||
563 | * @Then its state should be :state |
||
564 | */ |
||
565 | public function itsStateShouldBe($state) |
||
566 | { |
||
567 | Assert::same($this->showPage->getOrderState(), $state); |
||
568 | } |
||
569 | |||
570 | /** |
||
571 | * @Then it should( still) have a :state state |
||
572 | */ |
||
573 | public function itShouldHaveState($state) |
||
574 | { |
||
575 | Assert::true($this->indexPage->isSingleResourceOnPage(['state' => $state])); |
||
576 | } |
||
577 | |||
578 | /** |
||
579 | * @Then /^(the administrator) should know about (this additional note) for (this order made by "[^"]+")$/ |
||
580 | */ |
||
581 | public function theCustomerServiceShouldKnowAboutThisAdditionalNotes( |
||
582 | AdminUserInterface $user, |
||
583 | $note, |
||
584 | OrderInterface $order |
||
585 | ) { |
||
586 | $this->sharedSecurityService->performActionAsAdminUser( |
||
587 | $user, |
||
588 | function () use ($note, $order) { |
||
589 | $this->showPage->open(['id' => $order->getId()]); |
||
590 | |||
591 | Assert::true($this->showPage->hasNote($note)); |
||
592 | } |
||
593 | ); |
||
594 | } |
||
595 | |||
596 | /** |
||
597 | * @Then I should see an order with :orderNumber number |
||
598 | */ |
||
599 | public function iShouldSeeOrderWithNumber($orderNumber) |
||
600 | { |
||
601 | Assert::true($this->indexPage->isSingleResourceOnPage(['number' => $orderNumber])); |
||
602 | } |
||
603 | |||
604 | /** |
||
605 | * @Then I should not see an order with :orderNumber number |
||
606 | */ |
||
607 | public function iShouldNotSeeOrderWithNumber($orderNumber) |
||
608 | { |
||
609 | Assert::false($this->indexPage->isSingleResourceOnPage(['number' => $orderNumber])); |
||
610 | } |
||
611 | |||
612 | /** |
||
613 | * @Then I should not see any orders with currency :currencyCode |
||
614 | */ |
||
615 | public function iShouldNotSeeAnyOrderWithCurrency($currencyCode) |
||
616 | { |
||
617 | Assert::false($this->indexPage->isSingleResourceOnPage(['currencyCode' => $currencyCode])); |
||
618 | } |
||
619 | |||
620 | /** |
||
621 | * @Then the first order should have number :number |
||
622 | */ |
||
623 | public function theFirstOrderShouldHaveNumber($number) |
||
624 | { |
||
625 | Assert::eq($this->indexPage->getColumnFields('number')[0], $number); |
||
626 | } |
||
627 | |||
628 | /** |
||
629 | * @Then it should have shipment in state :shipmentState |
||
630 | */ |
||
631 | public function itShouldHaveShipmentState($shipmentState) |
||
632 | { |
||
633 | Assert::true($this->showPage->hasShipment($shipmentState)); |
||
634 | } |
||
635 | |||
636 | /** |
||
637 | * @Then order :orderNumber should have shipment state :shippingState |
||
638 | */ |
||
639 | public function thisOrderShipmentStateShouldBe($shippingState) |
||
640 | { |
||
641 | Assert::true($this->indexPage->isSingleResourceOnPage(['shippingState' => $shippingState])); |
||
642 | } |
||
643 | |||
644 | /** |
||
645 | * @Then the order :order should have order payment state :orderPaymentState |
||
646 | * @Then /^(this order) should have order payment state "([^"]+)"$/ |
||
647 | */ |
||
648 | public function theOrderShouldHavePaymentState(OrderInterface $order, $orderPaymentState) |
||
649 | { |
||
650 | Assert::true($this->indexPage->isSingleResourceOnPage(['paymentState' => $orderPaymentState])); |
||
651 | } |
||
652 | |||
653 | /** |
||
654 | * @Then the order :order should have order shipping state :orderShippingState |
||
655 | * @Then /^(this order) should have order shipping state "([^"]+)"$/ |
||
656 | */ |
||
657 | public function theOrderShouldHaveShippingState(OrderInterface $order, $orderShippingState) |
||
658 | { |
||
659 | Assert::true($this->indexPage->isSingleResourceOnPage(['shippingState' => $orderShippingState])); |
||
660 | } |
||
661 | |||
662 | /** |
||
663 | * @Then /^there should be(?:| only) (\d+) payments?$/ |
||
664 | */ |
||
665 | public function theOrderShouldHaveNumberOfPayments($number) |
||
666 | { |
||
667 | Assert::same($this->showPage->getPaymentsCount(), (int) $number); |
||
668 | } |
||
669 | |||
670 | /** |
||
671 | * @Then I should see the order :orderNumber with total :total |
||
672 | */ |
||
673 | public function iShouldSeeTheOrderWithTotal($orderNumber, $total) |
||
674 | { |
||
675 | Assert::true($this->indexPage->isSingleResourceOnPage(['total' => $total])); |
||
676 | } |
||
677 | |||
678 | /** |
||
679 | * @When /^I want to modify a customer's (?:billing|shipping) address of (this order)$/ |
||
680 | */ |
||
681 | public function iWantToModifyACustomerSShippingAddress(OrderInterface $order) |
||
682 | { |
||
683 | $this->updatePage->open(['id' => $order->getId()]); |
||
684 | } |
||
685 | |||
686 | /** |
||
687 | * @When I save my changes |
||
688 | * @When I try to save my changes |
||
689 | */ |
||
690 | public function iSaveMyChanges() |
||
691 | { |
||
692 | $this->updatePage->saveChanges(); |
||
693 | } |
||
694 | |||
695 | /** |
||
696 | * @When /^I specify their (?:|new )shipping (address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)")$/ |
||
697 | */ |
||
698 | public function iSpecifyTheirShippingAddressAsFor(AddressInterface $address) |
||
699 | { |
||
700 | $this->updatePage->specifyShippingAddress($address); |
||
701 | } |
||
702 | |||
703 | /** |
||
704 | * @When /^I specify their (?:|new )billing (address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)")$/ |
||
705 | */ |
||
706 | public function iSpecifyTheirBillingAddressAsFor(AddressInterface $address) |
||
707 | { |
||
708 | $this->updatePage->specifyBillingAddress($address); |
||
709 | } |
||
710 | |||
711 | /** |
||
712 | * @Then /^I should be notified that the "([^"]+)", the "([^"]+)", the "([^"]+)" and the "([^"]+)" in (shipping|billing) details are required$/ |
||
713 | */ |
||
714 | public function iShouldBeNotifiedThatTheAndTheInShippingDetailsAreRequired($firstElement, $secondElement, $thirdElement, $fourthElement, $type) |
||
715 | { |
||
716 | $this->assertElementValidationMessage($type, $firstElement, sprintf('Please enter %s.', $firstElement)); |
||
717 | $this->assertElementValidationMessage($type, $secondElement, sprintf('Please enter %s.', $secondElement)); |
||
718 | $this->assertElementValidationMessage($type, $thirdElement, sprintf('Please enter %s.', $thirdElement)); |
||
719 | $this->assertElementValidationMessage($type, $fourthElement, sprintf('Please enter %s.', $fourthElement)); |
||
720 | } |
||
721 | |||
722 | /** |
||
723 | * @Then I should see :provinceName as province in the shipping address |
||
724 | */ |
||
725 | public function iShouldSeeAsProvinceInTheShippingAddress($provinceName) |
||
726 | { |
||
727 | Assert::true($this->showPage->hasShippingProvinceName($provinceName)); |
||
728 | } |
||
729 | |||
730 | /** |
||
731 | * @Then I should see :provinceName ad province in the billing address |
||
732 | */ |
||
733 | public function iShouldSeeAdProvinceInTheBillingAddress($provinceName) |
||
734 | { |
||
735 | Assert::true($this->showPage->hasBillingProvinceName($provinceName)); |
||
736 | } |
||
737 | |||
738 | /** |
||
739 | * @Then /^(the administrator) should know about IP address of (this order made by "[^"]+")$/ |
||
740 | */ |
||
741 | public function theAdministratorShouldKnowAboutIPAddressOfThisOrderMadeBy( |
||
742 | AdminUserInterface $user, |
||
743 | OrderInterface $order |
||
744 | ) { |
||
745 | $this->sharedSecurityService->performActionAsAdminUser( |
||
746 | $user, |
||
747 | function () use ($order) { |
||
748 | $this->showPage->open(['id' => $order->getId()]); |
||
749 | |||
750 | Assert::notSame($this->showPage->getIpAddressAssigned(), ''); |
||
751 | } |
||
752 | ); |
||
753 | } |
||
754 | |||
755 | /** |
||
756 | * @When /^I (clear old billing address) information$/ |
||
757 | */ |
||
758 | public function iSpecifyTheBillingAddressAs(AddressInterface $address) |
||
759 | { |
||
760 | $this->updatePage->specifyBillingAddress($address); |
||
761 | } |
||
762 | |||
763 | /** |
||
764 | * @When /^I (clear old shipping address) information$/ |
||
765 | */ |
||
766 | public function iSpecifyTheShippingAddressAs(AddressInterface $address) |
||
767 | { |
||
768 | $this->updatePage->specifyShippingAddress($address); |
||
769 | } |
||
770 | |||
771 | /** |
||
772 | * @When /^I do not specify new information$/ |
||
773 | */ |
||
774 | public function iDoNotSpecifyNewInformation() |
||
775 | { |
||
776 | // Intentionally left blank to fulfill context expectation |
||
777 | } |
||
778 | |||
779 | /** |
||
780 | * @Then /^(the administrator) should see that (order placed by "[^"]+") has "([^"]+)" currency$/ |
||
781 | */ |
||
782 | public function theAdministratorShouldSeeThatThisOrderHasBeenPlacedIn(AdminUserInterface $user, OrderInterface $order, $currency) |
||
783 | { |
||
784 | $this->sharedSecurityService->performActionAsAdminUser($user, function () use ($order, $currency) { |
||
785 | $this->showPage->open(['id' => $order->getId()]); |
||
786 | |||
787 | Assert::same($this->showPage->getOrderCurrency(), $currency); |
||
788 | }); |
||
789 | } |
||
790 | |||
791 | /** |
||
792 | * @Then /^(the administrator) should see the order with total "([^"]+)" in order list$/ |
||
793 | */ |
||
794 | public function theAdministratorShouldSeeTheOrderWithTotalInOrderList(AdminUserInterface $user, $total) |
||
795 | { |
||
796 | $this->sharedSecurityService->performActionAsAdminUser($user, function () use ($total) { |
||
797 | $this->indexPage->open(); |
||
798 | |||
799 | Assert::true($this->indexPage->isSingleResourceOnPage(['total' => $total])); |
||
800 | }); |
||
801 | } |
||
802 | |||
803 | /** |
||
804 | * @Then there should be :count changes in the registry |
||
805 | */ |
||
806 | public function thereShouldBeCountChangesInTheRegistry($count) |
||
807 | { |
||
808 | Assert::same($this->historyPage->countShippingAddressChanges(), (int) $count); |
||
809 | } |
||
810 | |||
811 | /** |
||
812 | * @Then I should not be able to refund this payment |
||
813 | */ |
||
814 | public function iShouldNotBeAbleToRefundThisPayment() |
||
815 | { |
||
816 | Assert::false($this->showPage->hasRefundButton()); |
||
817 | } |
||
818 | |||
819 | /** |
||
820 | * @Then I should not see information about shipments |
||
821 | */ |
||
822 | public function iShouldNotSeeInformationAboutShipments(): void |
||
826 | |||
827 | /** |
||
828 | * @Then the :productName product's unit price should be :price |
||
829 | */ |
||
830 | public function productUnitPriceShouldBe(string $productName, string $price): void |
||
831 | { |
||
832 | Assert::same($this->showPage->getItemUnitPrice($productName), $price); |
||
833 | } |
||
834 | |||
835 | /** |
||
836 | * @Then the :productName product's item discount should be :price |
||
837 | */ |
||
838 | public function productItemDiscountShouldBe(string $productName, string $price): void |
||
839 | { |
||
840 | Assert::same($this->showPage->getItemDiscount($productName), $price); |
||
841 | } |
||
842 | |||
843 | /** |
||
844 | * @Then the :productName product's order discount should be :price |
||
845 | */ |
||
846 | public function productOrderDiscountShouldBe(string $productName, string $price): void |
||
847 | { |
||
848 | Assert::same($this->showPage->getItemOrderDiscount($productName), $price); |
||
849 | } |
||
850 | |||
851 | /** |
||
852 | * @Then the :productName product's quantity should be :quantity |
||
853 | */ |
||
854 | public function productQuantityShouldBe(string $productName, string $quantity): void |
||
855 | { |
||
856 | Assert::same($this->showPage->getItemQuantity($productName), $quantity); |
||
857 | } |
||
858 | |||
859 | /** |
||
860 | * @Then the :productName product's subtotal should be :subTotal |
||
861 | */ |
||
862 | public function productSubtotalShouldBe(string $productName, string $subTotal): void |
||
863 | { |
||
864 | Assert::same($this->showPage->getItemSubtotal($productName), $subTotal); |
||
865 | } |
||
866 | |||
867 | /** |
||
868 | * @Then the :productName product's discounted unit price should be :price |
||
869 | */ |
||
870 | public function productDiscountedUnitPriceShouldBe(string $productName, string $price): void |
||
871 | { |
||
872 | Assert::same($this->showPage->getItemDiscountedUnitPrice($productName), $price); |
||
873 | } |
||
874 | |||
875 | /** |
||
876 | * @Then I should be informed that there are no payments |
||
877 | */ |
||
878 | public function iShouldSeeInformationAboutNoPayments(): void |
||
883 | |||
884 | /** |
||
885 | * @param string $type |
||
886 | * @param string $element |
||
887 | * @param string $expectedMessage |
||
888 | * |
||
889 | * @throws \InvalidArgumentException |
||
890 | */ |
||
891 | private function assertElementValidationMessage($type, $element, $expectedMessage) |
||
896 | } |
||
897 |