Completed
Push — a-bulwa-travis-is-2 ( 7c64aa )
by Kamil
41:24
created

ManagingOrdersContext::getNormalizedElementName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
namespace Sylius\Behat\Context\Ui\Admin;
13
14
use Behat\Behat\Context\Context;
15
use Sylius\Behat\NotificationType;
16
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface;
17
use Sylius\Behat\Page\Admin\Order\ShowPageInterface;
18
use Sylius\Behat\Page\Admin\Order\UpdatePageInterface;
19
use Sylius\Behat\Service\NotificationCheckerInterface;
20
use Sylius\Behat\Service\SharedSecurityServiceInterface;
21
use Sylius\Behat\Service\SharedStorageInterface;
22
use Sylius\Component\Core\Formatter\StringInflector;
23
use Sylius\Component\Core\Model\AdminUserInterface;
24
use Sylius\Component\Core\Model\CustomerInterface;
25
use Sylius\Component\Core\Model\OrderInterface;
26
use Webmozart\Assert\Assert;
27
28
/**
29
 * @author Paweł Jędrzejewski <[email protected]>
30
 * @author Grzegorz Sadowski <[email protected]>
31
 */
32
final class ManagingOrdersContext implements Context
33
{
34
    /**
35
     * @var SharedStorageInterface
36
     */
37
    private $sharedStorage;
38
39
    /**
40
     * @var IndexPageInterface
41
     */
42
    private $indexPage;
43
44
    /**
45
     * @var ShowPageInterface
46
     */
47
    private $showPage;
48
49
    /**
50
     * @var UpdatePageInterface
51
     */
52
    private $updatePage;
53
54
    /**
55
     * @var NotificationCheckerInterface
56
     */
57
    private $notificationChecker;
58
59
    /**
60
     * @var SharedSecurityServiceInterface
61
     */
62
    private $sharedSecurityService;
63
64
    /**
65
     * @param SharedStorageInterface $sharedStorage
66
     * @param IndexPageInterface $indexPage
67
     * @param ShowPageInterface $showPage
68
     * @param UpdatePageInterface $updatePage
69
     * @param NotificationCheckerInterface $notificationChecker
70
     * @param SharedSecurityServiceInterface $sharedSecurityService
71
     */
72
    public function __construct(
73
        SharedStorageInterface $sharedStorage,
74
        IndexPageInterface $indexPage,
75
        ShowPageInterface $showPage,
76
        UpdatePageInterface $updatePage,
77
        NotificationCheckerInterface $notificationChecker,
78
        SharedSecurityServiceInterface $sharedSecurityService
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $sharedSecurityService exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
79
    ) {
80
        $this->sharedStorage = $sharedStorage;
81
        $this->indexPage = $indexPage;
82
        $this->showPage = $showPage;
83
        $this->updatePage = $updatePage;
84
        $this->notificationChecker = $notificationChecker;
85
        $this->sharedSecurityService = $sharedSecurityService;
86
    }
87
88
    /**
89
     * @Given I am browsing orders
90
     * @When I browse orders
91
     */
92
    public function iBrowseOrders()
93
    {
94
        $this->indexPage->open();
95
    }
96
97
    /**
98
     * @Given /^I am viewing the summary of (this order)$/
99
     * @When I view the summary of the order :order
100
     * @When /^I view the summary of (this order made by "[^"]+")$/
101
     */
102
    public function iSeeTheOrder(OrderInterface $order)
103
    {
104
        $this->showPage->open(['id' => $order->getId()]);
105
    }
106
107
    /**
108
     * @When /^I mark (this order) as paid$/
109
     */
110
    public function iMarkThisOrderAsAPaid(OrderInterface $order)
111
    {
112
        $this->showPage->completeOrderLastPayment($order);
113
    }
114
115
    /**
116
     * @When specify its tracking code as :trackingCode
117
     */
118
    public function specifyItsTrackingCodeAs($trackingCode)
119
    {
120
        $this->showPage->specifyTrackingCode($trackingCode);
121
        $this->sharedStorage->set('tracking_code', $trackingCode);
122
    }
123
124
    /**
125
     * @When /^I ship (this order)$/
126
     */
127
    public function iShipThisOrder(OrderInterface $order)
128
    {
129
        $this->showPage->shipOrder($order);
130
    }
131
132
    /**
133
     * @When I switch the way orders are sorted by :fieldName
134
     */
135
    public function iSwitchSortingBy($fieldName)
136
    {
137
        $this->indexPage->sortBy($fieldName);
138
    }
139
140
    /**
141
     * @Then I should see a single order from customer :customer
142
     */
143
    public function iShouldSeeASingleOrderFromCustomer(CustomerInterface $customer)
144
    {
145
        Assert::true(
146
            $this->indexPage->isSingleResourceOnPage(['customer' => $customer->getEmail()]),
147
            sprintf('Cannot find order for customer "%s" in the list.', $customer->getEmail())
148
        );
149
    }
150
151
    /**
152
     * @Then it should have been placed by the customer :customerEmail
153
     */
154
    public function itShouldBePlacedByCustomer($customerEmail)
155
    {
156
        Assert::true(
157
            $this->showPage->hasCustomer($customerEmail),
158
            sprintf('Cannot find customer "%s".', $customerEmail)
159
        );
160
    }
161
162
    /**
163
     * @Then it should be shipped to :customerName, :street, :postcode, :city, :countryName
164
     * @Then this order should be shipped to :customerName, :street, :postcode, :city, :countryName
165
     * @Then /^(this order) should still be shipped to "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"$/
166
     */
167
    public function itShouldBeShippedTo(OrderInterface $order = null, $customerName, $street, $postcode, $city, $countryName)
0 ignored issues
show
Coding Style introduced by
Parameters which have default values should be placed at the end.

If you place a parameter with a default value before a parameter with a default value, the default value of the first parameter will never be used as it will always need to be passed anyway:

// $a must always be passed; it's default value is never used.
function someFunction($a = 5, $b) { }
Loading history...
168
    {
169
        if (null !== $order) {
170
            $this->iSeeTheOrder($order);
171
        }
172
173
        Assert::true(
174
            $this->showPage->hasShippingAddress($customerName, $street, $postcode, $city, $countryName),
175
            sprintf('Cannot find shipping address "%s, %s %s, %s".', $street, $postcode, $city, $countryName)
176
        );
177
    }
178
179
    /**
180
     * @Then it should be billed to :customerName, :street, :postcode, :city, :countryName
181
     */
182
    public function itShouldBeBilledTo($customerName, $street, $postcode, $city, $countryName)
183
    {
184
        Assert::true(
185
            $this->showPage->hasBillingAddress($customerName, $street, $postcode, $city, $countryName),
186
            sprintf('Cannot find shipping address "%s, %s %s, %s".', $street, $postcode, $city, $countryName)
187
        );
188
    }
189
190
    /**
191
     * @Then it should be shipped via the :shippingMethodName shipping method
192
     */
193
    public function itShouldBeShippedViaShippingMethod($shippingMethodName)
194
    {
195
        Assert::true(
196
            $this->showPage->hasShipment($shippingMethodName),
197
            sprintf('Cannot find shipment "%s".', $shippingMethodName)
198
        );
199
    }
200
201
    /**
202
     * @Then it should be paid with :paymentMethodName
203
     */
204
    public function itShouldBePaidWith($paymentMethodName)
205
    {
206
        Assert::true(
207
            $this->showPage->hasPayment($paymentMethodName),
208
            sprintf('Cannot find payment "%s".', $paymentMethodName)
209
        );
210
    }
211
212
    /**
213
     * @Then /^it should have (\d+) items$/
214
     */
215
    public function itShouldHaveAmountOfItems($amount)
216
    {
217
        $itemsCount = $this->showPage->countItems();
218
219
        Assert::same(
220
            (int) $amount,
221
            $itemsCount,
222
            sprintf('There should be %d items, but get %d.', $amount, $itemsCount)
223
        );
224
    }
225
226
    /**
227
     * @Then the product named :productName should be in the items list
228
     */
229
    public function theProductShouldBeInTheItemsList($productName)
230
    {
231
        Assert::true(
232
            $this->showPage->isProductInTheList($productName),
233
            sprintf('Product %s is not in the item list.', $productName)
234
        );
235
    }
236
237
    /**
238
     * @Then the order's items total should be :itemsTotal
239
     */
240
    public function theOrdersItemsTotalShouldBe($itemsTotal)
241
    {
242
        $itemsTotalOnPage = $this->showPage->getItemsTotal();
243
244
        Assert::eq(
245
            $itemsTotalOnPage,
246
            $itemsTotal,
247
            'Items total is %s, but should be %s.'
248
        );
249
    }
250
251
    /**
252
     * @Then /^the order's total should(?:| still) be "([^"]+)"$/
253
     */
254
    public function theOrdersTotalShouldBe($total)
255
    {
256
        $totalOnPage = $this->showPage->getTotal();
257
258
        Assert::eq(
259
            $totalOnPage,
260
            $total,
261
            'Total is %s, but should be %s.'
262
        );
263
    }
264
265
    /**
266
     * @Then there should be a shipping charge :shippingCharge
267
     */
268
    public function theOrdersShippingChargesShouldBe($shippingCharge)
269
    {
270
        Assert::true(
271
            $this->showPage->hasShippingCharge($shippingCharge),
272
            sprintf('Shipping charges is not "%s".', $shippingCharge)
273
        );
274
    }
275
276
    /**
277
     * @Then the order's shipping total should be :shippingTotal
278
     */
279
    public function theOrdersShippingTotalShouldBe($shippingTotal)
280
    {
281
        $shippingTotalOnPage = $this->showPage->getShippingTotal();
282
283
        Assert::eq(
284
            $shippingTotal,
285
            $shippingTotalOnPage,
286
            sprintf('Shipping total is "%s", but should be "%s".', $shippingTotalOnPage, $shippingTotal)
287
        );
288
    }
289
290
    /**
291
     * @Then the order's payment should (also) be :paymentAmount
292
     */
293
    public function theOrdersPaymentShouldBe($paymentAmount)
294
    {
295
        $actualPaymentAmount = $this->showPage->getPaymentAmount();
296
297
        Assert::eq($paymentAmount, $actualPaymentAmount);
298
    }
299
300
    /**
301
     * @Then the order should have tax :tax
302
     */
303
    public function theOrderShouldHaveTax($tax)
304
    {
305
        Assert::true(
306
            $this->showPage->hasTax($tax),
307
            sprintf('Order should have tax "%s", but it does not.', $tax)
308
        );
309
    }
310
311
    /**
312
     * @Then /^the order's tax total should(?:| still) be "([^"]+)"$/
313
     */
314
    public function theOrdersTaxTotalShouldBe($taxTotal)
315
    {
316
        $taxTotalOnPage = $this->showPage->getTaxTotal();
317
318
        Assert::eq(
319
            $taxTotal,
320
            $taxTotalOnPage,
321
            sprintf('Tax total is "%s", but should be "%s".', $taxTotalOnPage, $taxTotal)
322
        );
323
    }
324
325
    /**
326
     * @Then the order's promotion discount should be :promotionDiscount
327
     */
328
    public function theOrdersPromotionDiscountShouldBe($promotionDiscount)
329
    {
330
        Assert::true(
331
            $this->showPage->hasPromotionDiscount($promotionDiscount),
332
            sprintf('Promotion discount is not "%s".', $promotionDiscount)
333
        );
334
    }
335
336
    /**
337
     * @Then /^the order's promotion total should(?:| still) be "([^"]+)"$/
338
     */
339
    public function theOrdersPromotionTotalShouldBe($promotionTotal)
340
    {
341
        $promotionTotalOnPage = $this->showPage->getPromotionTotal();
342
343
        Assert::eq(
344
            $promotionTotalOnPage,
345
            $promotionTotal,
346
            'Promotion total is %s, but should be %s.'
347
        );
348
    }
349
350
    /**
351
     * @When I check :itemName data
352
     */
353
    public function iCheckData($itemName)
354
    {
355
        $this->sharedStorage->set('item', $itemName);
356
    }
357
358
    /**
359
     * @Then /^(its) code should be "([^"]+)"$/
360
     */
361
    public function itemCodeShouldBe($itemName, $code)
362
    {
363
        $itemCodeOnPage = $this->showPage->getItemCode($itemName);
364
365
        Assert::same(
366
            $itemCodeOnPage,
367
            $code,
368
            'Item code is %s, but should be %s.'
369
        );
370
    }
371
372
    /**
373
     * @Then /^(its) unit price should be ([^"]+)$/
374
     */
375
    public function itemUnitPriceShouldBe($itemName, $unitPrice)
376
    {
377
        $itemUnitPriceOnPage = $this->showPage->getItemUnitPrice($itemName);
378
379
        Assert::eq(
380
            $itemUnitPriceOnPage,
381
            $unitPrice,
382
            'Item unit price is %s, but should be %s.'
383
        );
384
    }
385
386
    /**
387
     * @Then /^(its) discounted unit price should be ([^"]+)$/
388
     */
389
    public function itemDiscountedUnitPriceShouldBe($itemName, $discountedUnitPrice)
390
    {
391
        $itemUnitPriceOnPage = $this->showPage->getItemDiscountedUnitPrice($itemName);
392
393
        Assert::eq(
394
            $itemUnitPriceOnPage,
395
            $discountedUnitPrice,
396
            'Item discounted unit price is %s, but should be %s.'
397
        );
398
    }
399
400
    /**
401
     * @Then /^(its) quantity should be ([^"]+)$/
402
     */
403
    public function itemQuantityShouldBe($itemName, $quantity)
404
    {
405
        $itemQuantityOnPage = $this->showPage->getItemQuantity($itemName);
406
407
        Assert::eq(
408
            $itemQuantityOnPage,
409
            $quantity,
410
            'Item quantity is %s, but should be %s.'
411
        );
412
    }
413
414
    /**
415
     * @Then /^(its) subtotal should be ([^"]+)$/
416
     */
417
    public function itemSubtotalShouldBe($itemName, $subtotal)
418
    {
419
        $itemSubtotalOnPage = $this->showPage->getItemSubtotal($itemName);
420
421
        Assert::eq(
422
            $itemSubtotalOnPage,
423
            $subtotal,
424
            'Item subtotal is %s, but should be %s.'
425
        );
426
    }
427
428
    /**
429
     * @Then /^(its) discount should be ([^"]+)$/
430
     * @Then the :itemName should have :discount discount
431
     */
432
    public function theItemShouldHaveDiscount($itemName, $discount)
433
    {
434
        $itemDiscountOnPage = $this->showPage->getItemDiscount($itemName);
435
436
        Assert::eq(
437
            $itemDiscountOnPage,
438
            $discount,
439
            'Item discount is %s, but should be %s.'
440
        );
441
    }
442
443
    /**
444
     * @Then /^(its) tax should be ([^"]+)$/
445
     */
446
    public function itemTaxShouldBe($itemName, $tax)
447
    {
448
        $itemTaxOnPage = $this->showPage->getItemTax($itemName);
449
450
        Assert::eq(
451
            $itemTaxOnPage,
452
            $tax,
453
            'Item tax is %s, but should be %s.'
454
        );
455
    }
456
457
    /**
458
     * @Then /^(its) total should be ([^"]+)$/
459
     */
460
    public function itemTotalShouldBe($itemName, $total)
461
    {
462
        $itemTotalOnPage = $this->showPage->getItemTotal($itemName);
463
464
        Assert::eq(
465
            $itemTotalOnPage,
466
            $total,
467
            'Item total is %s, but should be %s.'
468
        );
469
    }
470
471
    /**
472
     * @Then I should be notified that the order's payment has been successfully completed
473
     */
474
    public function iShouldBeNotifiedThatTheOrderSPaymentHasBeenSuccessfullyCompleted()
475
    {
476
        $this->notificationChecker->checkNotification('Payment has been successfully updated.', NotificationType::success());
477
    }
478
479
    /**
480
     * @Then it should have payment state :paymentState
481
     */
482
    public function itShouldHavePaymentState($paymentState)
483
    {
484
        Assert::true(
485
            $this->showPage->hasPayment($paymentState),
486
            sprintf('It should have payment with %s state', $paymentState)
487
        );
488
    }
489
490
    /**
491
     * @Then /^I should not be able to mark (this order) as paid again$/
492
     */
493
    public function iShouldNotBeAbleToFinalizeItsPayment(OrderInterface $order)
494
    {
495
        Assert::false(
496
            $this->showPage->canCompleteOrderLastPayment($order),
497
            'It should not have complete payment button.'
498
        );
499
    }
500
501
    /**
502
     * @Then I should be notified that the order has been successfully shipped
503
     */
504
    public function iShouldBeNotifiedThatTheOrderHasBeenSuccessfullyShipped()
505
    {
506
        $this->notificationChecker->checkNotification('Shipment has been successfully updated.', NotificationType::success());
507
    }
508
509
    /**
510
     * @Then /^I should not be able to ship (this order)$/
511
     */
512
    public function iShouldNotBeAbleToShipThisOrder(OrderInterface $order)
513
    {
514
        Assert::false(
515
            $this->showPage->canShipOrder($order),
516
            'It should not have ship shipment button.'
517
        );
518
    }
519
520
    /**
521
     * @When I cancel this order
522
     */
523
    public function iCancelThisOrder()
524
    {
525
        $this->showPage->cancelOrder();
526
    }
527
528
    /**
529
     * @Then I should be notified that it has been successfully updated
530
     */
531
    public function iShouldBeNotifiedAboutItHasBeenSuccessfullyCanceled()
532
    {
533
        $this->notificationChecker->checkNotification(
534
            'Order has been successfully updated.',
535
            NotificationType::success()
536
        );
537
    }
538
539
    /**
540
     * @Then I should not be able to cancel this order
541
     */
542
    public function iShouldNotBeAbleToCancelThisOrder()
543
    {
544
        Assert::false(
545
            $this->showPage->hasCancelButton(),
546
            'There should not be a cancel button, but it is.'
547
        );
548
    }
549
550
    /**
551
     * @Then this order should have state :state
552
     * @Then its state should be :state
553
     */
554
    public function itsStateShouldBe($state)
555
    {
556
        Assert::same(
557
            $this->showPage->getOrderState(),
558
            $state,
559
            'The order state should be %2$s, but it is %s.'
560
        );
561
    }
562
563
    /**
564
     * @Then it should( still) have a :state state
565
     */
566
    public function itShouldHaveState($state)
567
    {
568
        Assert::true(
569
            $this->indexPage->isSingleResourceOnPage(['state' => $state]),
570
            sprintf('Cannot find order with "%s" state in the list.', $state)
571
        );
572
    }
573
574
    /**
575
     * @Then /^(the administrator) should know about (this additional note) for (this order made by "[^"]+")$/
576
     */
577
    public function theCustomerServiceShouldKnowAboutThisAdditionalNotes(AdminUserInterface $user, $note, OrderInterface $order)
578
    {
579
        $this->sharedSecurityService->performActionAsAdminUser($user, function () use ($note, $order) {
580
            $this->showPage->open(['id' => $order->getId()]);
581
            Assert::true($this->showPage->hasNote($note), sprintf('I should see %s note, but I do not see', $note));
582
        });
583
    }
584
585
    /**
586
     * @Then I should see an order with :orderNumber number
587
     */
588
    public function iShouldSeeOrderWithNumber($orderNumber)
589
    {
590
        Assert::true(
591
            $this->indexPage->isSingleResourceOnPage(['number' => $orderNumber]),
592
            sprintf('Cannot find order with "%s" number in the list.', $orderNumber)
593
        );
594
    }
595
596
    /**
597
     * @Then the first order should have number :number
598
     */
599
    public function theFirstOrderShouldHaveNumber($number)
600
    {
601
        $actualNumber = $this->indexPage->getColumnFields('number')[0];
602
603
        Assert::eq(
604
            $actualNumber,
605
            $number,
606
            sprintf('Expected first order\'s number to be %s, but it is %s.', $number, $actualNumber)
607
        );
608
    }
609
610
    /**
611
     * @Then it should have shipment in state :shipmentState
612
     */
613
    public function itShouldHaveShipmentState($shipmentState)
614
    {
615
        Assert::true(
616
            $this->showPage->hasShipment($shipmentState),
617
            sprintf('It should have shipment with %s state', $shipmentState)
618
        );
619
    }
620
621
    /**
622
     * @Then order :orderNumber should have shipment state :shippingState
623
     */
624
    public function thisOrderShipmentStateShouldBe($shippingState)
625
    {
626
        Assert::true(
627
            $this->indexPage->isSingleResourceOnPage(['shippingState' => $shippingState]),
628
            sprintf('Order should have %s shipping state', $shippingState)
629
        );
630
    }
631
632
    /**
633
     * @Then the order :order should have order payment state :orderPaymentState
634
     * @Then /^(this order) should have order payment state "([^"]+)"$/
635
     * @Then /^(its) payment state should be "([^"]+)"$/
636
     */
637
    public function theOrderShouldHavePaymentState(OrderInterface $order, $orderPaymentState)
0 ignored issues
show
Unused Code introduced by
The parameter $order is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
638
    {
639
        Assert::true(
640
            $this->indexPage->isSingleResourceOnPage(['paymentState' => $orderPaymentState]),
641
            sprintf('Cannot find order with "%s" order payment state in the list.', $orderPaymentState)
642
        );
643
    }
644
645
    /**
646
     * @Then the order :order should have order shipping state :orderShipmentState
647
     * @Then /^(this order) should have order shipping state "([^"]+)"$/
648
     * @Then /^(its) shipping state should be "([^"]+)"$/
649
     */
650
    public function theOrderShouldHaveShipmentState(OrderInterface $order, $orderShipmentState)
0 ignored issues
show
Unused Code introduced by
The parameter $order is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
651
    {
652
        Assert::true(
653
            $this->indexPage->isSingleResourceOnPage(['shippingState' => $orderShipmentState]),
654
            sprintf('Cannot find order with "%s" order shipping state on the list.', $orderShipmentState)
655
        );
656
    }
657
658
    /**
659
     * @Then /^there should be(?:| only) (\d+) payments?$/
660
     */
661
    public function theOrderShouldHaveNumberOfPayments($number)
662
    {
663
        $actualNumberOfPayments = $this->showPage->getPaymentsCount();
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $actualNumberOfPayments exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
664
665
        Assert::same((int) $number, $actualNumberOfPayments);
666
    }
667
668
    /**
669
     * @Then I should see the order :orderNumber with total :total
670
     */
671
    public function iShouldSeeTheOrderWithTotal($orderNumber, $total)
672
    {
673
        Assert::true(
674
            $this->indexPage->isSingleResourceOnPage(['total' => $total]),
675
            sprintf('The total of order "%s" is not "%s".', $orderNumber, $total)
676
        );
677
    }
678
679
    /**
680
     * @When /^I want to modify a customer's shipping address of (this order)$/
681
     */
682
    public function iWantToModifyACustomerSShippingAddress(OrderInterface $order)
683
    {
684
        $this->updatePage->open(['id' => $order->getId()]);
685
    }
686
687
    /**
688
     * @When I specify the first name as :firstName
689
     * @When I do not specify the first name
690
     */
691
    public function iSpecifyTheFirstNameAs($firstName = null)
692
    {
693
        $this->updatePage->specifyFirstName($firstName);
694
    }
695
696
    /**
697
     * @When I specify the last name as :lastName
698
     * @When I do not specify the last name
699
     */
700
    public function iSpecifyTheLastNameAs($lastName = null)
701
    {
702
        $this->updatePage->specifyLastName($lastName);
703
    }
704
705
    /**
706
     * @When I specify the street as :street
707
     * @When I do not specify the street
708
     */
709
    public function iSpecifyTheStreetAs($street = null)
710
    {
711
        $this->updatePage->specifyStreet($street);
712
    }
713
714
    /**
715
     * @When I specify the city as :city
716
     * @When I do not specify the city
717
     */
718
    public function iSpecifyTheCityAs($city = null)
719
    {
720
        $this->updatePage->specifyCity($city);
721
    }
722
723
    /**
724
     * @When I specify the postcode as :postcode
725
     */
726
    public function iSpecifyThePostcodeAs($postcode)
727
    {
728
        $this->updatePage->specifyPostcode($postcode);
729
    }
730
731
    /**
732
     * @When I choose :country as the country
733
     */
734
    public function iChooseCountryAs($country)
735
    {
736
        $this->updatePage->chooseCountry($country);
737
    }
738
739
    /**
740
     * @When I save my changes
741
     * @When I try to save my changes
742
     */
743
    public function iSaveMyChanges()
744
    {
745
        $this->updatePage->saveChanges();
746
    }
747
748
    /**
749
     * @When I specify their shipping address as :city, :street, :postcode, :country for :firstAndLastName
750
     */
751
    public function iSpecifyTheirShippingAddressAsFor($city, $street, $postcode, $country, $firstAndLastName)
752
    {
753
        $this->updatePage->specifyShippingAddress($city, $street, $postcode, $country, $firstAndLastName);
754
    }
755
756
    /**
757
     * @Then /^I should be notified that the (last name|first name|city|street) is required$/
758
     */
759
    public function iShouldBeNotifiedThatIsRequired($element)
760
    {
761
        Assert::same(
762
            $this->updatePage->getValidationMessage(StringInflector::nameToCode($element)),
763
            sprintf('Please enter %s.', $element)
764
        );
765
    }
766
767
    /**
768
     * @Then I should see :provinceName as province in the shipping address
769
     */
770
    public function iShouldSeeAsProvinceInTheShippingAddress($provinceName)
771
    {
772
        Assert::true(
773
            $this->showPage->hasShippingProvinceName($provinceName),
774
            sprintf('Cannot find shipping address with province %s', $provinceName)
775
        );
776
    }
777
778
    /**
779
     * @Then I should see :provinceName ad province in the billing address
780
     */
781
    public function iShouldSeeAdProvinceInTheBillingAddress($provinceName)
782
    {
783
        Assert::true(
784
            $this->showPage->hasBillingProvinceName($provinceName),
785
            sprintf('Cannot find shipping address with province %s', $provinceName)
786
        );
787
    }
788
}
789