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