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