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\ShowPageInterface; |
19
|
|
|
use Sylius\Behat\Page\Admin\Payment\IndexPageInterface; |
20
|
|
|
use Sylius\Behat\Service\NotificationCheckerInterface; |
21
|
|
|
use Sylius\Component\Core\Model\CustomerInterface; |
22
|
|
|
use Sylius\Component\Core\Model\OrderInterface; |
23
|
|
|
use Webmozart\Assert\Assert; |
24
|
|
|
|
25
|
|
|
final class ManagingPaymentsContext implements Context |
26
|
|
|
{ |
27
|
|
|
/** @var IndexPageInterface */ |
28
|
|
|
private $indexPage; |
29
|
|
|
|
30
|
|
|
/** @var ShowPageInterface */ |
31
|
|
|
private $orderShowPage; |
32
|
|
|
|
33
|
|
|
/** @var NotificationCheckerInterface */ |
34
|
|
|
private $notificationChecker; |
35
|
|
|
|
36
|
|
|
public function __construct( |
37
|
|
|
IndexPageInterface $indexPage, |
38
|
|
|
ShowPageInterface $orderShowPage, |
39
|
|
|
NotificationCheckerInterface $notificationChecker |
40
|
|
|
) { |
41
|
|
|
$this->indexPage = $indexPage; |
42
|
|
|
$this->orderShowPage = $orderShowPage; |
43
|
|
|
$this->notificationChecker = $notificationChecker; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @When I browse payments |
48
|
|
|
* @Given I am browsing payments |
49
|
|
|
*/ |
50
|
|
|
public function iAmBrowsingPayments(): void |
51
|
|
|
{ |
52
|
|
|
$this->indexPage->open(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @When I choose :paymentState as a payment state |
57
|
|
|
*/ |
58
|
|
|
public function iChooseAsAPaymentState(string $paymentState): void |
59
|
|
|
{ |
60
|
|
|
$this->indexPage->chooseStateToFilter($paymentState); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @When I complete the payment of order :orderNumber |
65
|
|
|
*/ |
66
|
|
|
public function iCompleteThePaymentOfOrder(string $orderNumber): void |
67
|
|
|
{ |
68
|
|
|
$this->indexPage->completePaymentOfOrderWithNumber($orderNumber); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @When I filter |
73
|
|
|
*/ |
74
|
|
|
public function iFilter(): void |
75
|
|
|
{ |
76
|
|
|
$this->indexPage->filter(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @When I go to the details of the first payment's order |
81
|
|
|
*/ |
82
|
|
|
public function iGoToTheDetailsOfTheFirstPaymentSOrder(): void |
83
|
|
|
{ |
84
|
|
|
$this->indexPage->showOrderPageForNthPayment(1); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @When I choose :channelName as a channel filter |
89
|
|
|
*/ |
90
|
|
|
public function iChooseChannelAsAChannelFilter(string $channelName): void |
91
|
|
|
{ |
92
|
|
|
$this->indexPage->chooseChannelFilter($channelName); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @Then I should see :count payments in the list |
97
|
|
|
* @Then I should see a single payment in the list |
98
|
|
|
*/ |
99
|
|
|
public function iShouldSeePaymentsInTheList(int $count = 1): void |
100
|
|
|
{ |
101
|
|
|
Assert::same($count, $this->indexPage->countItems()); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @Then the payment of the :orderNumber order should be :paymentState for :customer |
106
|
|
|
*/ |
107
|
|
|
public function thePaymentOfTheOrderShouldBeFor( |
108
|
|
|
string $orderNumber, |
109
|
|
|
string $paymentState, |
110
|
|
|
CustomerInterface $customer |
111
|
|
|
): void { |
112
|
|
|
$parameters = [ |
113
|
|
|
'number' => $orderNumber, |
114
|
|
|
'state' => $paymentState, |
115
|
|
|
'customer' => $customer->getEmail(), |
116
|
|
|
]; |
117
|
|
|
|
118
|
|
|
Assert::true($this->indexPage->isSingleResourceOnPage($parameters)); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @Then I should see order page with details of order :order |
123
|
|
|
*/ |
124
|
|
|
public function iShouldSeeOrderPageWithDetailsOfOrder(OrderInterface $order): void |
125
|
|
|
{ |
126
|
|
|
Assert::true($this->orderShowPage->isOpen(['id' => $order->getId()])); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @Then I should see (also) the payment of the :orderNumber order |
131
|
|
|
*/ |
132
|
|
|
public function iShouldSeeThePaymentOfTheOrder(string $orderNumber): void |
133
|
|
|
{ |
134
|
|
|
Assert::true($this->indexPage->isSingleResourceOnPage(['number' => $orderNumber])); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @Then I should see the payment of order :orderNumber as :paymentState |
139
|
|
|
*/ |
140
|
|
|
public function iShouldSeeThePaymentOfOrderAs(string $orderNumber, string $paymentState): void |
141
|
|
|
{ |
142
|
|
|
Assert::same($paymentState, $this->indexPage->getPaymentStateByOrderNumber($orderNumber)); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @Then I should be notified that the payment has been completed |
147
|
|
|
*/ |
148
|
|
|
public function iShouldBeNotifiedThatThePaymentHasBeenCompleted(): void |
149
|
|
|
{ |
150
|
|
|
$this->notificationChecker->checkNotification('Payment has been completed.', NotificationType::success()); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @Then I should not see a payment of order :orderNumber |
155
|
|
|
* @Then I should not see the payment of the :orderNumber order |
156
|
|
|
*/ |
157
|
|
|
public function iShouldNotSeeAPaymentOfOrder(string $orderNumber): void |
158
|
|
|
{ |
159
|
|
|
Assert::false($this->indexPage->isSingleResourceOnPage(['number' => $orderNumber])); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @Then /^I should see payment for (the "[^"]+" order) as (\d+)(?:|st|nd|rd|th) in the list$/ |
164
|
|
|
*/ |
165
|
|
|
public function iShouldSeePaymentForTheOrderInTheList(string $orderNumber, int $position): void |
166
|
|
|
{ |
167
|
|
|
Assert::true($this->indexPage->isPaymentWithOrderNumberInPosition($orderNumber, $position)); |
168
|
|
|
} |
169
|
|
|
} |
170
|
|
|
|