Completed
Push — master ( 1f454c...9af5c7 )
by Michał
22s
created

iDoNotChooseCreateAccountOption()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

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 1
nc 1
nop 0
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\Page\Admin\Crud\IndexPageInterface;
16
use Sylius\Behat\Page\Admin\Customer\CreatePageInterface;
17
use Sylius\Behat\Page\Admin\Customer\ShowPageInterface;
18
use Sylius\Behat\Page\Admin\Customer\UpdatePageInterface;
19
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
20
use Sylius\Behat\Service\SharedStorageInterface;
21
use Sylius\Component\Core\Model\CustomerInterface;
22
use Webmozart\Assert\Assert;
23
24
/**
25
 * @author Anna Walasek <[email protected]>
26
 */
27
final class ManagingCustomersContext implements Context
28
{
29
    /**
30
     * @var SharedStorageInterface
31
     */
32
    private $sharedStorage;
33
34
    /**
35
     * @var IndexPageInterface
36
     */
37
    private $indexPage;
38
39
    /**
40
     * @var CreatePageInterface
41
     */
42
    private $createPage;
43
44
    /**
45
     * @var UpdatePageInterface
46
     */
47
    private $updatePage;
48
49
    /**
50
     * @var ShowPageInterface
51
     */
52
    private $showPage;
53
54
    /**
55
     * @var IndexPageInterface
56
     */
57
    private $ordersIndexPage;
58
59
    /**
60
     * @var CurrentPageResolverInterface
61
     */
62
    private $currentPageResolver;
63
64
    /**
65
     * @param SharedStorageInterface $sharedStorage
66
     * @param CreatePageInterface $createPage
67
     * @param IndexPageInterface $indexPage
68
     * @param UpdatePageInterface $updatePage
69
     * @param ShowPageInterface $showPage
70
     * @param IndexPageInterface $ordersIndexPage
71
     * @param CurrentPageResolverInterface $currentPageResolver
72
     */
73
    public function __construct(
74
        SharedStorageInterface $sharedStorage,
75
        CreatePageInterface $createPage,
76
        IndexPageInterface $indexPage,
77
        UpdatePageInterface $updatePage,
78
        ShowPageInterface $showPage,
79
        IndexPageInterface $ordersIndexPage,
80
        CurrentPageResolverInterface $currentPageResolver
81
    ) {
82
        $this->sharedStorage = $sharedStorage;
83
        $this->createPage = $createPage;
84
        $this->indexPage = $indexPage;
85
        $this->updatePage = $updatePage;
86
        $this->showPage = $showPage;
87
        $this->ordersIndexPage = $ordersIndexPage;
88
        $this->currentPageResolver = $currentPageResolver;
89
    }
90
91
    /**
92
     * @Given I want to create a new customer
93
     * @Given I want to create a new customer account
94
     */
95
    public function iWantToCreateANewCustomer()
96
    {
97
        $this->createPage->open();
98
    }
99
100
    /**
101
     * @When /^I specify (?:their|his) first name as "([^"]*)"$/
102
     */
103
    public function iSpecifyItsFirstNameAs($name)
104
    {
105
        $this->createPage->specifyFirstName($name);
106
    }
107
108
    /**
109
     * @When /^I specify (?:their|his) last name as "([^"]*)"$/
110
     */
111
    public function iSpecifyItsLastNameAs($name)
112
    {
113
        $this->createPage->specifyLastName($name);
114
    }
115
116
    /**
117
     * @When I specify their email as :name
118
     * @When I do not specify their email
119
     */
120
    public function iSpecifyItsEmailAs($email = null)
121
    {
122
        $this->createPage->specifyEmail($email);
123
    }
124
125
    /**
126
     * @When I add them
127
     * @When I try to add them
128
     */
129
    public function iAddIt()
130
    {
131
        $this->createPage->create();
132
    }
133
134
    /**
135
     * @Then the customer :customer should appear in the store
136
     * @Then the customer :customer should still have this email
137
     */
138
    public function theCustomerShould(CustomerInterface $customer)
139
    {
140
        $this->indexPage->open();
141
142
        Assert::true(
143
            $this->indexPage->isSingleResourceOnPage(['email' => $customer->getEmail()]),
144
            sprintf('Customer with email %s should exist but it does not.', $customer->getEmail())
145
        );
146
    }
147
148
    /**
149
     * @When I select :gender as its gender
150
     */
151
    public function iSelectGender($gender)
152
    {
153
        $this->createPage->chooseGender($gender);
154
    }
155
156
    /**
157
     * @When I select :group as their group
158
     */
159
    public function iSelectGroup($group)
160
    {
161
        $this->createPage->chooseGroup($group);
162
    }
163
164
    /**
165
     * @When I specify its birthday as :birthday
166
     */
167
    public function iSpecifyItsBirthdayAs($birthday)
168
    {
169
        $this->createPage->specifyBirthday($birthday);
170
    }
171
172
    /**
173
     * @Given /^I want to edit (this customer)$/
174
     * @Given I want to edit the customer :customer
175
     */
176
    public function iWantToEditThisCustomer(CustomerInterface $customer)
177
    {
178
        $this->updatePage->open(['id' => $customer->getId()]);
179
    }
180
181
    /**
182
     * @Given I want to change my password
183
     */
184
    public function iWantToChangeMyPassword()
185
    {
186
        $customer = $this->sharedStorage->get('customer');
187
188
        $this->updatePage->open(['id' => $customer->getId()]);
189
    }
190
191
    /**
192
     * @When I save my changes
193
     * @When I try to save my changes
194
     */
195
    public function iSaveMyChanges()
196
    {
197
        $this->updatePage->saveChanges();
198
    }
199
200
    /**
201
     * @Then /^(this customer) with name "([^"]*)" should appear in the store$/
202
     */
203
    public function theCustomerWithNameShouldAppearInTheRegistry(CustomerInterface $customer, $name)
204
    {
205
        $this->updatePage->open(['id' => $customer->getId()]);
206
207
        Assert::eq(
208
            $name,
209
            $this->updatePage->getFullName(),
210
            sprintf('Customer should have name %s, but they have %s.', $name, $this->updatePage->getFullName())
211
        );
212
    }
213
214
    /**
215
     * @When I want to see all customers in store
216
     */
217
    public function iWantToSeeAllCustomersInStore()
218
    {
219
        $this->indexPage->open();
220
    }
221
222
    /**
223
     * @Then /^I should see (\d+) customers in the list$/
224
     */
225
    public function iShouldSeeCustomersInTheList($amountOfCustomers)
226
    {
227
        Assert::same(
228
            (int) $amountOfCustomers,
229
            $this->indexPage->countItems(),
230
            sprintf('Amount of customers should be equal %s, but is not.', $amountOfCustomers)
231
        );
232
    }
233
234
    /**
235
     * @Then I should see the customer :email in the list
236
     */
237
    public function iShouldSeeTheCustomerInTheList($email)
238
    {
239
        Assert::true(
240
            $this->indexPage->isSingleResourceOnPage(['email' => $email]),
241
            sprintf('Customer with email %s should exist but it does not.', $email)
242
        );
243
    }
244
245
    /**
246
     * @Then /^I should be notified that ([^"]+) is required$/
247
     */
248
    public function iShouldBeNotifiedThatFirstNameIsRequired($elementName)
249
    {
250
        Assert::same($this->createPage->getValidationMessage($elementName), sprintf('Please enter your %s.', $elementName));
251
    }
252
253
    /**
254
     * @Then /^I should be notified that ([^"]+) should be ([^"]+)$/
255
     */
256
    public function iShouldBeNotifiedThatTheElementShouldBe($elementName, $validationMessage)
257
    {
258
        Assert::same(
259
            $this->updatePage->getValidationMessage($elementName),
260
            sprintf('%s must be %s.', ucfirst($elementName), $validationMessage)
261
        );
262
    }
263
264
    /**
265
     * @Then the customer with email :email should not appear in the store
266
     */
267
    public function theCustomerShouldNotAppearInTheStore($email)
268
    {
269
        $this->indexPage->open();
270
271
        Assert::false(
272
            $this->indexPage->isSingleResourceOnPage(['email' => $email]),
273
            sprintf('Customer with email %s was created, but it should not.', $email)
274
        );
275
    }
276
277
    /**
278
     * @When I remove its first name
279
     */
280
    public function iRemoveItsFirstName()
281
    {
282
        $this->updatePage->changeFirstName('');
283
    }
284
285
    /**
286
     * @Then /^(this customer) should have an empty first name$/
287
     * @Then the customer :customer should still have an empty first name
288
     */
289
    public function theCustomerShouldStillHaveAnEmptyFirstName(CustomerInterface $customer)
290
    {
291
        $this->updatePage->open(['id' => $customer->getId()]);
292
293
        Assert::eq(
294
            '',
295
            $this->updatePage->getFirstName(),
296
            'Customer should have an empty first name, but it does not.'
297
        );
298
    }
299
300
    /**
301
     * @When I remove its last name
302
     */
303
    public function iRemoveItsLastName()
304
    {
305
        $this->updatePage->changeLastName('');
306
    }
307
308
    /**
309
     * @Then /^(this customer) should have an empty last name$/
310
     * @Then the customer :customer should still have an empty last name
311
     */
312
    public function theCustomerShouldStillHaveAnEmptyLastName(CustomerInterface $customer)
313
    {
314
        $this->updatePage->open(['id' => $customer->getId()]);
315
316
        Assert::eq(
317
            '',
318
            $this->updatePage->getLastName(),
319
            'Customer should have an empty last name, but it does not.'
320
        );
321
    }
322
323
    /**
324
     * @When I remove its email
325
     */
326
    public function iRemoveItsEmail()
327
    {
328
        $this->updatePage->changeEmail('');
329
    }
330
331
    /**
332
     * @Then I should be notified that email is not valid
333
     */
334
    public function iShouldBeNotifiedThatEmailIsNotValid()
335
    {
336
        Assert::same($this->createPage->getValidationMessage('email'), 'This email is invalid.');
337
    }
338
339
    /**
340
     * @Then I should be notified that email must be unique
341
     */
342
    public function iShouldBeNotifiedThatEmailMustBeUnique()
343
    {
344
        Assert::same($this->createPage->getValidationMessage('email'), 'This email is already used.');
345
    }
346
347
    /**
348
     * @Then there should still be only one customer with email :email
349
     */
350
    public function thereShouldStillBeOnlyOneCustomerWithEmail($email)
351
    {
352
        $this->indexPage->open();
353
354
        Assert::true(
355
            $this->indexPage->isSingleResourceOnPage(['email' => $email]),
356
            sprintf('Customer with email %s cannot be found.', $email)
357
        );
358
    }
359
360
    /**
361
     * @Given I want to enable :customer
362
     * @Given I want to disable :customer
363
     */
364
    public function iWantToChangeStatusOf(CustomerInterface $customer)
365
    {
366
        $this->updatePage->open(['id' => $customer->getId()]);
367
    }
368
369
    /**
370
     * @When I enable their account
371
     */
372
    public function iEnableIt()
373
    {
374
        $this->updatePage->enable();
375
    }
376
377
    /**
378
     * @When I disable their account
379
     */
380
    public function iDisableIt()
381
    {
382
        $this->updatePage->disable();
383
    }
384
385
    /**
386
     * @Then /^(this customer) should be enabled$/
387
     */
388
    public function thisCustomerShouldBeEnabled(CustomerInterface $customer)
389
    {
390
        $this->indexPage->open();
391
392
        Assert::eq(
393
            'Enabled',
394
            $this->indexPage->getCustomerAccountStatus($customer),
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Sylius\Behat\Page\Admin\Crud\IndexPageInterface as the method getCustomerAccountStatus() does only exist in the following implementations of said interface: Sylius\Behat\Page\Admin\Customer\IndexPage.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
395
            'Customer account should be enabled, but it does not.'
396
        );
397
    }
398
399
    /**
400
     * @Then /^(this customer) should be disabled$/
401
     */
402
    public function thisCustomerShouldBeDisabled(CustomerInterface $customer)
403
    {
404
        $this->indexPage->open();
405
406
        Assert::eq(
407
            'Disabled',
408
            $this->indexPage->getCustomerAccountStatus($customer),
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Sylius\Behat\Page\Admin\Crud\IndexPageInterface as the method getCustomerAccountStatus() does only exist in the following implementations of said interface: Sylius\Behat\Page\Admin\Customer\IndexPage.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
409
            'Customer account should be disabled, but it does not.'
410
        );
411
    }
412
413
    /**
414
     * @When I specify their password as :password
415
     */
416
    public function iSpecifyItsPasswordAs($password)
417
    {
418
        $this->createPage->specifyPassword($password);
419
    }
420
421
    /**
422
     * @When I change my password to :password
423
     */
424
    public function iSpecifyMyPasswordAs($password)
425
    {
426
        $this->updatePage->changePassword($password);
427
    }
428
429
    /**
430
     * @When I choose create account option
431
     */
432
    public function iChooseCreateAccountOption()
433
    {
434
        $this->createPage->selectCreateAccount();
435
    }
436
437
    /**
438
     * @When I browse orders of a customer :customer
439
     */
440
    public function iBrowseOrdersOfACustomer(CustomerInterface $customer)
441
    {
442
        $this->ordersIndexPage->open(['id' => $customer->getId()]);
443
    }
444
445
    /**
446
     * @Then the customer :customer should have an account created
447
     * @Then /^(this customer) should have an account created$/
448
     */
449
    public function theyShouldHaveAnAccountCreated(CustomerInterface $customer)
450
    {
451
        Assert::notNull(
452
            $customer->getUser()->getPassword(),
453
            'Customer should have an account, but they do not.'
454
        );
455
    }
456
457
    /**
458
     * @When I view details of the customer :customer
459
     * @When /^I view (their) details$/
460
     */
461
    public function iViewDetailsOfTheCustomer(CustomerInterface $customer)
462
    {
463
        $this->showPage->open(['id' => $customer->getId()]);
464
    }
465
466
    /**
467
     * @Then his name should be :name
468
     */
469
    public function hisNameShouldBe($name)
470
    {
471
        Assert::same(
472
            $name,
473
            $this->showPage->getCustomerName(),
474
            'Customer name should be "%s", but it is not.'
475
        );
476
    }
477
478
    /**
479
     * @Given he should be registered since :registrationDate
480
     */
481
    public function hisRegistrationDateShouldBe($registrationDate)
482
    {
483
        Assert::eq(
484
            new \DateTime($registrationDate),
485
            $this->showPage->getRegistrationDate(),
486
            'Customer registration date should be "%s", but it is not.'
487
        );
488
    }
489
490
    /**
491
     * @Given his email should be :email
492
     */
493
    public function hisEmailShouldBe($email)
494
    {
495
        Assert::same(
496
            $email,
497
            $this->showPage->getCustomerEmail(),
498
            'Customer email should be "%s", but it is not'
499
        );
500
    }
501
502
    /**
503
     * @Then his default address should be :defaultAddress
504
     */
505
    public function hisShippingAddressShouldBe($defaultAddress)
506
    {
507
        Assert::same(
508
            str_replace(',', '', $defaultAddress),
509
            $this->showPage->getDefaultAddress(),
510
            'Customer\'s default address should be "%s", but it is not.'
511
        );
512
    }
513
514
    /**
515
     * @Then I should see information about no existing account for this customer
516
     */
517
    public function iShouldSeeInformationAboutNoExistingAccountForThisCustomer()
518
    {
519
        Assert::true(
520
            $this->showPage->hasAccount(),
521
            'There should be information about no account, but there is none.'
522
        );
523
    }
524
525
    /**
526
     * @Then I should see that this customer is subscribed to the newsletter
527
     */
528
    public function iShouldSeeThatThisCustomerIsSubscribedToTheNewsletter()
529
    {
530
        Assert::true(
531
            $this->showPage->isSubscribedToNewsletter(),
532
            'There should be information that this customer is subscribed to the newsletter.'
533
        );
534
    }
535
536
    /**
537
     * @Then I should not see information about email verification
538
     */
539
    public function iShouldSeeInformationAboutEmailVerification()
540
    {
541
        Assert::true(
542
            $this->showPage->hasEmailVerificationInformation(),
543
            'There should be no information about email verification.'
544
        );
545
    }
546
547
    /**
548
     * @When I make them subscribed to the newsletter
549
     */
550
    public function iMakeThemSubscribedToTheNewsletter()
551
    {
552
        $this->updatePage->subscribeToTheNewsletter();
553
    }
554
555
    /**
556
     * @When I change the password of user :customer to :newPassword
557
     */
558
    public function iChangeThePasswordOfUserTo(CustomerInterface $customer, $newPassword)
559
    {
560
        $this->updatePage->open(['id' => $customer->getId()]);
561
        $this->updatePage->changePassword($newPassword);
562
        $this->updatePage->saveChanges();
563
    }
564
565
    /**
566
     * @Then this customer should be subscribed to the newsletter
567
     */
568
    public function thisCustomerShouldBeSubscribedToTheNewsletter()
569
    {
570
        Assert::true(
571
            $this->updatePage->isSubscribedToTheNewsletter(),
572
            'This customer should subscribe to the newsletter.'
573
        );
574
    }
575
576
    /**
577
     * @Then the province in the default address should be :provinceName
578
     */
579
    public function theProvinceInTheDefaultAddressShouldBe($provinceName)
580
    {
581
        Assert::true(
582
            $this->showPage->hasDefaultAddressProvinceName($provinceName),
583
            sprintf('Cannot find shipping address with province %s', $provinceName)
584
        );
585
    }
586
587
    /**
588
     * @Then this customer should have :groupName as their group
589
     */
590
    public function thisCustomerShouldHaveAsTheirGroup($groupName)
591
    {
592
        /** @var UpdatePageInterface|ShowPageInterface $currentPage */
593
        $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->updatePage, $this->showPage]);
0 ignored issues
show
Documentation introduced by
array($this->updatePage, $this->showPage) is of type array<integer,object<Syl...\\ShowPageInterface>"}>, but the function expects a array<integer,object<Syl...\SymfonyPageInterface>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
594
595
        Assert::same(
596
            $groupName,
597
            $currentPage->getGroupName(),
598
            sprintf('Customer should have %s as group, but it does not.', $groupName)
599
        );
600
    }
601
602
    /**
603
     * @Then I should see that this customer has verified the email
604
     */
605
    public function iShouldSeeThatThisCustomerHasVerifiedTheEmail()
606
    {
607
        Assert::true(
608
            $this->showPage->hasVerifiedEmail(),
609
            'There should be information that this customer has verified the email.'
610
        );
611
    }
612
613
    /**
614
     * @Then I should see a single order in the list
615
     */
616
    public function iShouldSeeASingleOrderInTheList()
617
    {
618
        Assert::same(
619
            1,
620
            $this->ordersIndexPage->countItems(),
621
            'Cannot find order in the list.'
622
        );
623
    }
624
625
    /**
626
     * @Then I should see the order with number :orderNumber in the list
627
     */
628
    public function iShouldSeeASingleOrderFromCustomer($orderNumber)
629
    {
630
        Assert::true(
631
            $this->indexPage->isSingleResourceOnPage(['number' => $orderNumber]),
632
            sprintf('Cannot find order with number "%s" in the list.', $orderNumber)
633
        );
634
    }
635
636
    /**
637
     * @Then I should not see the order with number :orderNumber in the list
638
     */
639
    public function iShouldNotSeeASingleOrderFromCustomer($orderNumber)
640
    {
641
        Assert::false(
642
            $this->indexPage->isSingleResourceOnPage(['number' => $orderNumber]),
643
            sprintf('Cannot find order with number "%s" in the list.', $orderNumber)
644
        );
645
    }
646
647
    /**
648
     * @When I do not specify any information
649
     */
650
    public function iDoNotSpecifyAnyInformation()
651
    {
652
        // Intentionally left blank.
653
    }
654
655
    /**
656
     * @Then I should not be able to specify their password
657
     */
658
    public function iShouldNotBeAbleToSpecifyItPassword()
659
    {
660
        Assert::true(
661
            $this->createPage->isUserFormHidden(),
662
            'There should not be password field, but it is.'
663
         );
664
    }
665
666
    /**
667
     * @Then I should still be on the customer creation page
668
     */
669
    public function iShouldBeOnTheCustomerCreationPage()
670
    {
671
        Assert::true(
672
            $this->createPage->isOpen(),
673
            'The customer creation page should be open, but it is not.'
674
        );
675
    }
676
677
    /**
678
     * @Then I should be able to select create account option
679
     */
680
    public function iShouldBeAbleToSelectCreateAccountOption()
681
    {
682
        Assert::false(
683
            $this->createPage->hasCheckedCreateOption(),
684
            'The create account option should not be selected, but it is.'
685
        );
686
    }
687
688
    /**
689
     * @Then I should be able to specify their password
690
     */
691
    public function iShouldBeAbleToSpecifyItPassword()
692
    {
693
        Assert::true(
694
            $this->createPage->hasPasswordField(),
695
            'There should be password field, but it is not.'
696
        );
697
    }
698
699
    /**
700
     * @Then I should not be able to select create account option
701
     */
702
    public function iShouldNotBeAbleToSelectCreateAccountOption()
703
    {
704
        Assert::true(
705
            $this->createPage->hasCheckedCreateOption(),
706
            'The create account option should be selected, but it is not.'
707
        );
708
    }
709
710
    /**
711
     * @When I do not choose create account option
712
     */
713
    public function iDoNotChooseCreateAccountOption()
714
    {
715
        // Intentionally left blank.
716
    }
717
718
    /**
719
     * @Then I should not see create account option
720
     */
721
    public function iShouldNotSeeCreateAccountOption()
722
    {
723
        Assert::false(
724
            $this->createPage->hasCreateOption(),
0 ignored issues
show
Bug introduced by
The method hasCreateOption() does not exist on Sylius\Behat\Page\Admin\...mer\CreatePageInterface. Did you maybe mean create()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
725
            'The create account option should not be on customer creation page, but it is.'
726
        );
727
    }
728
729
    /**
730
     * @Then /^I should be notified that the password must be at least (\d+) characters long$/
731
     */
732
    public function iShouldBeNotifiedThatThePasswordMustBeAtLeastCharactersLong($amountOfCharacters)
733
    {
734
        Assert::same($this->createPage->getValidationMessage('password'), sprintf('Password must be at least %d characters long.', $amountOfCharacters));
735
    }
736
}
737