|
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 as OrderShowPageInterface; |
|
19
|
|
|
use Sylius\Behat\Page\Admin\Shipment\IndexPageInterface; |
|
20
|
|
|
use Sylius\Behat\Page\Admin\Shipment\ShowPageInterface; |
|
21
|
|
|
use Sylius\Behat\Service\NotificationCheckerInterface; |
|
22
|
|
|
use Sylius\Component\Core\Model\Channel; |
|
23
|
|
|
use Sylius\Component\Core\Model\CustomerInterface; |
|
24
|
|
|
use Sylius\Component\Core\Model\OrderInterface; |
|
25
|
|
|
use Webmozart\Assert\Assert; |
|
26
|
|
|
|
|
27
|
|
|
final class ManagingShipmentsContext implements Context |
|
28
|
|
|
{ |
|
29
|
|
|
/** @var IndexPageInterface */ |
|
30
|
|
|
private $indexPage; |
|
31
|
|
|
|
|
32
|
|
|
/** @var OrderShowPageInterface */ |
|
33
|
|
|
private $orderShowPage; |
|
34
|
|
|
|
|
35
|
|
|
/** @var NotificationCheckerInterface */ |
|
36
|
|
|
private $notificationChecker; |
|
37
|
|
|
|
|
38
|
|
|
/** @var ShowPageInterface */ |
|
39
|
|
|
private $showPage; |
|
40
|
|
|
|
|
41
|
|
|
public function __construct( |
|
42
|
|
|
IndexPageInterface $indexPage, |
|
43
|
|
|
OrderShowPageInterface $orderShowPage, |
|
44
|
|
|
NotificationCheckerInterface $notificationChecker, |
|
45
|
|
|
ShowPageInterface $showPage |
|
46
|
|
|
) { |
|
47
|
|
|
$this->indexPage = $indexPage; |
|
48
|
|
|
$this->orderShowPage = $orderShowPage; |
|
49
|
|
|
$this->notificationChecker = $notificationChecker; |
|
50
|
|
|
$this->showPage = $showPage; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @When I browse shipments |
|
55
|
|
|
*/ |
|
56
|
|
|
public function iBrowseShipments(): void |
|
57
|
|
|
{ |
|
58
|
|
|
$this->indexPage->open(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @Then the shipment of the :orderNumber order should be :shippingState for :customer |
|
63
|
|
|
* @Then the shipment of the :orderNumber order should be :shippingState for :customer in :channel channel |
|
64
|
|
|
*/ |
|
65
|
|
|
public function shipmentOfOrderShouldBe( |
|
66
|
|
|
string $orderNumber, |
|
67
|
|
|
string $shippingState, |
|
68
|
|
|
CustomerInterface $customer, |
|
69
|
|
|
Channel $channel = null |
|
70
|
|
|
): void { |
|
71
|
|
|
$parameters = [ |
|
72
|
|
|
'number' => $orderNumber, |
|
73
|
|
|
'state' => $shippingState, |
|
74
|
|
|
'customer' => $customer->getEmail(), |
|
75
|
|
|
]; |
|
76
|
|
|
|
|
77
|
|
|
if ($channel !== null) { |
|
78
|
|
|
$parameters = ['channel' => $channel->getName()]; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
Assert::true($this->indexPage->isSingleResourceOnPage($parameters)); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @When I choose :shipmentState as a shipment state |
|
86
|
|
|
*/ |
|
87
|
|
|
public function iChooseShipmentState(string $shipmentState): void |
|
88
|
|
|
{ |
|
89
|
|
|
$this->indexPage->chooseStateToFilter($shipmentState); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @When I choose :channelName as a channel filter |
|
94
|
|
|
*/ |
|
95
|
|
|
public function iChooseChannelAsAChannelFilter(string $channelName): void |
|
96
|
|
|
{ |
|
97
|
|
|
$this->indexPage->chooseChannelFilter($channelName); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @When I filter |
|
102
|
|
|
*/ |
|
103
|
|
|
public function iFilter(): void |
|
104
|
|
|
{ |
|
105
|
|
|
$this->indexPage->filter(); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @When I view the first shipment of the order :order |
|
110
|
|
|
*/ |
|
111
|
|
|
public function iViewTheShipmentOfTheOrder(OrderInterface $order): void |
|
112
|
|
|
{ |
|
113
|
|
|
$this->showPage->open(['id' => $order->getShipments()->first()->getId()]); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @Then I should see( only) :count shipment(s) in the list |
|
118
|
|
|
* @Then I should see a single shipment in the list |
|
119
|
|
|
*/ |
|
120
|
|
|
public function iShouldSeeCountShipmentsInList(int $count = 1): void |
|
121
|
|
|
{ |
|
122
|
|
|
Assert::same($this->indexPage->countItems(), $count); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @Then I should see a shipment of order :orderNumber |
|
127
|
|
|
*/ |
|
128
|
|
|
public function iShouldSeeShipmentWithOrderNumber(string $orderNumber): void |
|
129
|
|
|
{ |
|
130
|
|
|
Assert::true($this->indexPage->isSingleResourceOnPage(['number' => $orderNumber])); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @Then I should not see a shipment of order :orderNumber |
|
135
|
|
|
*/ |
|
136
|
|
|
public function iShouldNotSeeShipmentWithOrderNumber(string $orderNumber): void |
|
137
|
|
|
{ |
|
138
|
|
|
Assert::false($this->indexPage->isSingleResourceOnPage(['number' => $orderNumber])); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @When I ship the shipment of order :orderNumber |
|
143
|
|
|
*/ |
|
144
|
|
|
public function iShipShipmentOfOrder(string $orderNumber): void |
|
145
|
|
|
{ |
|
146
|
|
|
$this->indexPage->shipShipmentOfOrderWithNumber($orderNumber); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @Then I should see the shipment of order :orderNumber as :shippingState |
|
151
|
|
|
*/ |
|
152
|
|
|
public function iShouldSeeTheShipmentOfOrderAs(string $orderNumber, string $shippingState): void |
|
153
|
|
|
{ |
|
154
|
|
|
Assert::same($shippingState, $this->indexPage->getShipmentStatusByOrderNumber($orderNumber)); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @Then I should be notified that the shipment has been successfully shipped |
|
159
|
|
|
*/ |
|
160
|
|
|
public function iShouldBeNotifiedThatTheShipmentHasBeenSuccessfullyShipped(): void |
|
161
|
|
|
{ |
|
162
|
|
|
$this->notificationChecker->checkNotification('Shipment has been successfully shipped.', NotificationType::success()); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* @When I move to the details of first shipment's order |
|
167
|
|
|
*/ |
|
168
|
|
|
public function iMoveToDetailsOfFirstShipment(): void |
|
169
|
|
|
{ |
|
170
|
|
|
$this->indexPage->showOrderPageForNthShipment(1); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @When I ship the shipment of order :orderNumber with :trackingCode tracking code |
|
175
|
|
|
*/ |
|
176
|
|
|
public function iShipTheShipmentOfOrderWithTrackingCode(string $orderNumber, string $trackingCode): void |
|
177
|
|
|
{ |
|
178
|
|
|
$this->indexPage->shipShipmentOfOrderWithTrackingCode($orderNumber, $trackingCode); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* @Then I should see order page with details of order :order |
|
183
|
|
|
*/ |
|
184
|
|
|
public function iShouldSeeOrderPageWithDetailsOfOrder(OrderInterface $order): void |
|
185
|
|
|
{ |
|
186
|
|
|
Assert::true($this->orderShowPage->isOpen(['id' => $order->getId()])); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* @Then /^I should see shipment for (the "[^"]+" order) as (\d+)(?:|st|nd|rd|th) in the list$/ |
|
191
|
|
|
*/ |
|
192
|
|
|
public function iShouldSeeShipmentForTheOrderInTheList(string $orderNumber, int $position): void |
|
193
|
|
|
{ |
|
194
|
|
|
Assert::true($this->indexPage->isShipmentWithOrderNumberInPosition($orderNumber, $position)); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* @Then I should see :amount :product units in the list |
|
199
|
|
|
*/ |
|
200
|
|
|
public function iShouldSeeUnitsInTheList(int $amount, string $productName): void |
|
201
|
|
|
{ |
|
202
|
|
|
Assert::same($this->showPage->getAmountOfUnits($productName), $amount); |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* @Then I should see the shipment of order :orderNumber shipped at :dateTime |
|
207
|
|
|
*/ |
|
208
|
|
|
public function iShouldSeeTheShippingDateAs(string $orderNumber, string $dateTime): void |
|
209
|
|
|
{ |
|
210
|
|
|
Assert::same($this->indexPage->getShippedAtDate($orderNumber), $dateTime); |
|
211
|
|
|
} |
|
212
|
|
|
} |
|
213
|
|
|
|