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\Customer; |
22
|
|
|
use Sylius\Component\Customer\Model\CustomerInterface; |
23
|
|
|
use Webmozart\Assert\Assert; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @author Anna Walasek <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
final class ManagingCustomersContext implements Context |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @var SharedStorageInterface |
32
|
|
|
*/ |
33
|
|
|
private $sharedStorage; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var IndexPageInterface |
37
|
|
|
*/ |
38
|
|
|
private $indexPage; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var CreatePageInterface |
42
|
|
|
*/ |
43
|
|
|
private $createPage; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var UpdatePageInterface |
47
|
|
|
*/ |
48
|
|
|
private $updatePage; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var ShowPageInterface |
52
|
|
|
*/ |
53
|
|
|
private $showPage; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var CurrentPageResolverInterface |
57
|
|
|
*/ |
58
|
|
|
private $currentPageResolver; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param SharedStorageInterface $sharedStorage |
62
|
|
|
* @param CreatePageInterface $createPage |
63
|
|
|
* @param IndexPageInterface $indexPage |
64
|
|
|
* @param UpdatePageInterface $updatePage |
65
|
|
|
* @param ShowPageInterface $showPage |
66
|
|
|
* @param CurrentPageResolverInterface $currentPageResolver |
67
|
|
|
*/ |
68
|
|
|
public function __construct( |
69
|
|
|
SharedStorageInterface $sharedStorage, |
70
|
|
|
CreatePageInterface $createPage, |
71
|
|
|
IndexPageInterface $indexPage, |
72
|
|
|
UpdatePageInterface $updatePage, |
73
|
|
|
ShowPageInterface $showPage, |
74
|
|
|
CurrentPageResolverInterface $currentPageResolver |
75
|
|
|
) { |
76
|
|
|
$this->sharedStorage = $sharedStorage; |
77
|
|
|
$this->createPage = $createPage; |
78
|
|
|
$this->indexPage = $indexPage; |
79
|
|
|
$this->updatePage = $updatePage; |
80
|
|
|
$this->showPage = $showPage; |
81
|
|
|
$this->currentPageResolver = $currentPageResolver; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @Given I want to create a new customer |
86
|
|
|
* @Given I want to create a new customer account |
87
|
|
|
*/ |
88
|
|
|
public function iWantToCreateANewCustomer() |
89
|
|
|
{ |
90
|
|
|
$this->createPage->open(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @When /^I specify (?:their|his) first name as "([^"]*)"$/ |
95
|
|
|
*/ |
96
|
|
|
public function iSpecifyItsFirstNameAs($name) |
97
|
|
|
{ |
98
|
|
|
$this->createPage->specifyFirstName($name); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @When /^I specify (?:their|his) last name as "([^"]*)"$/ |
103
|
|
|
*/ |
104
|
|
|
public function iSpecifyItsLastNameAs($name) |
105
|
|
|
{ |
106
|
|
|
$this->createPage->specifyLastName($name); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @When I specify their email as :name |
111
|
|
|
*/ |
112
|
|
|
public function iSpecifyItsEmailAs($email) |
113
|
|
|
{ |
114
|
|
|
$this->createPage->specifyEmail($email); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @When I add them |
119
|
|
|
* @When I try to add it |
120
|
|
|
*/ |
121
|
|
|
public function iAddIt() |
122
|
|
|
{ |
123
|
|
|
$this->createPage->create(); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @Then the customer :customer should appear in the store |
128
|
|
|
* @Then the customer :customer should still have this email |
129
|
|
|
*/ |
130
|
|
|
public function theCustomerShould(CustomerInterface $customer) |
131
|
|
|
{ |
132
|
|
|
$this->indexPage->open(); |
133
|
|
|
|
134
|
|
|
Assert::true( |
135
|
|
|
$this->indexPage->isSingleResourceOnPage(['email' => $customer->getEmail()]), |
136
|
|
|
sprintf('Customer with email %s should exist but it does not.', $customer->getEmail()) |
137
|
|
|
); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @When I select :gender as its gender |
142
|
|
|
*/ |
143
|
|
|
public function iSelectGender($gender) |
144
|
|
|
{ |
145
|
|
|
$this->createPage->chooseGender($gender); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @When I select :group as their group |
150
|
|
|
*/ |
151
|
|
|
public function iSelectGroup($group) |
152
|
|
|
{ |
153
|
|
|
$this->createPage->chooseGroup($group); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @When I specify its birthday as :birthday |
158
|
|
|
*/ |
159
|
|
|
public function iSpecifyItsBirthdayAs($birthday) |
160
|
|
|
{ |
161
|
|
|
$this->createPage->specifyBirthday($birthday); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @Given /^I want to edit (this customer)$/ |
166
|
|
|
* @Given I want to edit the customer :customer |
167
|
|
|
*/ |
168
|
|
|
public function iWantToEditThisCustomer(CustomerInterface $customer) |
169
|
|
|
{ |
170
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @Given I want to change my password |
175
|
|
|
*/ |
176
|
|
|
public function iWantToChangeMyPassword() |
177
|
|
|
{ |
178
|
|
|
$customer = $this->sharedStorage->get('customer'); |
179
|
|
|
|
180
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @When I save my changes |
185
|
|
|
* @When I try to save my changes |
186
|
|
|
*/ |
187
|
|
|
public function iSaveMyChanges() |
188
|
|
|
{ |
189
|
|
|
$this->updatePage->saveChanges(); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @Then /^(this customer) with name "([^"]*)" should appear in the store$/ |
194
|
|
|
*/ |
195
|
|
|
public function theCustomerWithNameShouldAppearInTheRegistry(CustomerInterface $customer, $name) |
196
|
|
|
{ |
197
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
198
|
|
|
|
199
|
|
|
Assert::eq( |
200
|
|
|
$name, |
201
|
|
|
$this->updatePage->getFullName(), |
202
|
|
|
sprintf('Customer should have name %s, but they have %s.', $name, $this->updatePage->getFullName()) |
203
|
|
|
); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @When I want to see all customers in store |
208
|
|
|
*/ |
209
|
|
|
public function iWantToSeeAllCustomersInStore() |
210
|
|
|
{ |
211
|
|
|
$this->indexPage->open(); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @Then /^I should see (\d+) customers in the list$/ |
216
|
|
|
*/ |
217
|
|
|
public function iShouldSeeCustomersInTheList($amountOfCustomers) |
218
|
|
|
{ |
219
|
|
|
Assert::same( |
220
|
|
|
(int) $amountOfCustomers, |
221
|
|
|
$this->indexPage->countItems(), |
222
|
|
|
sprintf('Amount of customers should be equal %s, but is not.', $amountOfCustomers) |
223
|
|
|
); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* @Then I should see the customer :email in the list |
228
|
|
|
*/ |
229
|
|
|
public function iShouldSeeTheCustomerInTheList($email) |
230
|
|
|
{ |
231
|
|
|
Assert::true( |
232
|
|
|
$this->indexPage->isSingleResourceOnPage(['email' => $email]), |
233
|
|
|
sprintf('Customer with email %s should exist but it does not.', $email) |
234
|
|
|
); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @Then /^I should be notified that ([^"]+) is required$/ |
239
|
|
|
*/ |
240
|
|
|
public function iShouldBeNotifiedThatFirstNameIsRequired($elementName) |
241
|
|
|
{ |
242
|
|
|
Assert::same($this->createPage->getValidationMessage($elementName), sprintf('Please enter your %s.', $elementName)); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* @Then /^I should be notified that ([^"]+) should be ([^"]+)$/ |
247
|
|
|
*/ |
248
|
|
|
public function iShouldBeNotifiedThatTheElementShouldBe($elementName, $validationMessage) |
249
|
|
|
{ |
250
|
|
|
Assert::same( |
251
|
|
|
$this->updatePage->getValidationMessage($elementName), |
252
|
|
|
sprintf('%s must be %s.', ucfirst($elementName), $validationMessage) |
253
|
|
|
); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @Then the customer with email :email should not appear in the store |
258
|
|
|
*/ |
259
|
|
|
public function theCustomerShouldNotAppearInTheStore($email) |
260
|
|
|
{ |
261
|
|
|
$this->indexPage->open(); |
262
|
|
|
|
263
|
|
|
Assert::false( |
264
|
|
|
$this->indexPage->isSingleResourceOnPage(['email' => $email]), |
265
|
|
|
sprintf('Customer with email %s was created, but it should not.', $email) |
266
|
|
|
); |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* @When I remove its first name |
271
|
|
|
*/ |
272
|
|
|
public function iRemoveItsFirstName() |
273
|
|
|
{ |
274
|
|
|
$this->updatePage->changeFirstName(''); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* @Then /^(this customer) should have an empty first name$/ |
279
|
|
|
* @Then the customer :customer should still have an empty first name |
280
|
|
|
*/ |
281
|
|
|
public function theCustomerShouldStillHaveAnEmptyFirstName(CustomerInterface $customer) |
282
|
|
|
{ |
283
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
284
|
|
|
|
285
|
|
|
Assert::eq( |
286
|
|
|
'', |
287
|
|
|
$this->updatePage->getFirstName(), |
288
|
|
|
'Customer should have an empty first name, but it does not.' |
289
|
|
|
); |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @When I remove its last name |
294
|
|
|
*/ |
295
|
|
|
public function iRemoveItsLastName() |
296
|
|
|
{ |
297
|
|
|
$this->updatePage->changeLastName(''); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* @Then /^(this customer) should have an empty last name$/ |
302
|
|
|
* @Then the customer :customer should still have an empty last name |
303
|
|
|
*/ |
304
|
|
|
public function theCustomerShouldStillHaveAnEmptyLastName(CustomerInterface $customer) |
305
|
|
|
{ |
306
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
307
|
|
|
|
308
|
|
|
Assert::eq( |
309
|
|
|
'', |
310
|
|
|
$this->updatePage->getLastName(), |
311
|
|
|
'Customer should have an empty last name, but it does not.' |
312
|
|
|
); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @When I remove its email |
317
|
|
|
*/ |
318
|
|
|
public function iRemoveItsEmail() |
319
|
|
|
{ |
320
|
|
|
$this->updatePage->changeEmail(''); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* @Then I should be notified that email is not valid |
325
|
|
|
*/ |
326
|
|
|
public function iShouldBeNotifiedThatEmailIsNotValid() |
327
|
|
|
{ |
328
|
|
|
Assert::same($this->createPage->getValidationMessage('email'), 'This email is invalid.'); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* @Then I should be notified that email must be unique |
333
|
|
|
*/ |
334
|
|
|
public function iShouldBeNotifiedThatEmailMustBeUnique() |
335
|
|
|
{ |
336
|
|
|
Assert::same($this->createPage->getValidationMessage('email'), 'This email is already used.'); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @Then there should still be only one customer with email :email |
341
|
|
|
*/ |
342
|
|
|
public function thereShouldStillBeOnlyOneCustomerWithEmail($email) |
343
|
|
|
{ |
344
|
|
|
$this->indexPage->open(); |
345
|
|
|
|
346
|
|
|
Assert::true( |
347
|
|
|
$this->indexPage->isSingleResourceOnPage(['email' => $email]), |
348
|
|
|
sprintf('Customer with email %s cannot be found.', $email) |
349
|
|
|
); |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
/** |
353
|
|
|
* @Given I want to enable :customer |
354
|
|
|
* @Given I want to disable :customer |
355
|
|
|
*/ |
356
|
|
|
public function iWantToChangeStatusOf(CustomerInterface $customer) |
357
|
|
|
{ |
358
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* @When I enable their account |
363
|
|
|
*/ |
364
|
|
|
public function iEnableIt() |
365
|
|
|
{ |
366
|
|
|
$this->updatePage->enable(); |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* @When I disable their account |
371
|
|
|
*/ |
372
|
|
|
public function iDisableIt() |
373
|
|
|
{ |
374
|
|
|
$this->updatePage->disable(); |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
/** |
378
|
|
|
* @Then /^(this customer) should be enabled$/ |
379
|
|
|
*/ |
380
|
|
|
public function thisCustomerShouldBeEnabled(CustomerInterface $customer) |
381
|
|
|
{ |
382
|
|
|
$this->indexPage->open(); |
383
|
|
|
|
384
|
|
|
Assert::eq( |
385
|
|
|
'Enabled', |
386
|
|
|
$this->indexPage->getCustomerAccountStatus($customer), |
|
|
|
|
387
|
|
|
'Customer account should be enabled, but it does not.' |
388
|
|
|
); |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
/** |
392
|
|
|
* @Then /^(this customer) should be disabled$/ |
393
|
|
|
*/ |
394
|
|
|
public function thisCustomerShouldBeDisabled(CustomerInterface $customer) |
395
|
|
|
{ |
396
|
|
|
$this->indexPage->open(); |
397
|
|
|
|
398
|
|
|
Assert::eq( |
399
|
|
|
'Disabled', |
400
|
|
|
$this->indexPage->getCustomerAccountStatus($customer), |
|
|
|
|
401
|
|
|
'Customer account should be disabled, but it does not.' |
402
|
|
|
); |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* @When I specify its password as :password |
407
|
|
|
*/ |
408
|
|
|
public function iSpecifyItsPasswordAs($password) |
409
|
|
|
{ |
410
|
|
|
$this->createPage->specifyPassword($password); |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
/** |
414
|
|
|
* @When I change my password to :password |
415
|
|
|
*/ |
416
|
|
|
public function iSpecifyMyPasswordAs($password) |
417
|
|
|
{ |
418
|
|
|
$this->updatePage->changePassword($password); |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
/** |
422
|
|
|
* @When I choose create account option |
423
|
|
|
*/ |
424
|
|
|
public function iChooseCreateAccountOption() |
425
|
|
|
{ |
426
|
|
|
$this->createPage->selectCreateAccount(); |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* @Then the customer :customer should have an account created |
431
|
|
|
* @Then /^(this customer) should have an account created$/ |
432
|
|
|
*/ |
433
|
|
|
public function theyShouldHaveAnAccountCreated(CustomerInterface $customer) |
434
|
|
|
{ |
435
|
|
|
Assert::notNull( |
436
|
|
|
$customer->getUser()->getPassword(), |
|
|
|
|
437
|
|
|
'Customer should have an account, but they do not.' |
438
|
|
|
); |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
/** |
442
|
|
|
* @When I view details of the customer :customer |
443
|
|
|
*/ |
444
|
|
|
public function iViewDetailsOfTheCustomer(CustomerInterface $customer) |
445
|
|
|
{ |
446
|
|
|
$this->showPage->open(['id' => $customer->getId()]); |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
/** |
450
|
|
|
* @Then his name should be :name |
451
|
|
|
*/ |
452
|
|
|
public function hisNameShouldBe($name) |
453
|
|
|
{ |
454
|
|
|
Assert::same( |
455
|
|
|
$name, |
456
|
|
|
$this->showPage->getCustomerName(), |
457
|
|
|
'Customer name should be "%s", but it is not.' |
458
|
|
|
); |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
/** |
462
|
|
|
* @Given he should be registered since :registrationDate |
463
|
|
|
*/ |
464
|
|
|
public function hisRegistrationDateShouldBe($registrationDate) |
465
|
|
|
{ |
466
|
|
|
Assert::eq( |
467
|
|
|
new \DateTime($registrationDate), |
468
|
|
|
$this->showPage->getRegistrationDate(), |
469
|
|
|
'Customer registration date should be "%s", but it is not.' |
470
|
|
|
); |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
/** |
474
|
|
|
* @Given his email should be :email |
475
|
|
|
*/ |
476
|
|
|
public function hisEmailShouldBe($email) |
477
|
|
|
{ |
478
|
|
|
Assert::same( |
479
|
|
|
$email, |
480
|
|
|
$this->showPage->getCustomerEmail(), |
481
|
|
|
'Customer email should be "%s", but it is not' |
482
|
|
|
); |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* @Then his default address should be :defaultAddress |
487
|
|
|
*/ |
488
|
|
|
public function hisShippingAddressShouldBe($defaultAddress) |
489
|
|
|
{ |
490
|
|
|
Assert::same( |
491
|
|
|
str_replace(',', '', $defaultAddress), |
492
|
|
|
$this->showPage->getDefaultAddress(), |
493
|
|
|
'Customer\'s default address should be "%s", but it is not.' |
494
|
|
|
); |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
/** |
498
|
|
|
* @Then I should see information about no existing account for this customer |
499
|
|
|
*/ |
500
|
|
|
public function iShouldSeeInformationAboutNoExistingAccountForThisCustomer() |
501
|
|
|
{ |
502
|
|
|
Assert::true( |
503
|
|
|
$this->showPage->hasAccount(), |
504
|
|
|
'There should be information about no account, but there is none.' |
505
|
|
|
); |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
/** |
509
|
|
|
* @Then I should see that this customer is subscribed to the newsletter |
510
|
|
|
*/ |
511
|
|
|
public function iShouldSeeThatThisCustomerIsSubscribedToTheNewsletter() |
512
|
|
|
{ |
513
|
|
|
Assert::true( |
514
|
|
|
$this->showPage->isSubscribedToNewsletter(), |
515
|
|
|
'There should be information that this customer is subscribed to the newsletter.' |
516
|
|
|
); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
/** |
520
|
|
|
* @Then I should not see information about email verification |
521
|
|
|
*/ |
522
|
|
|
public function iShouldSeeInformationAboutEmailVerification() |
523
|
|
|
{ |
524
|
|
|
Assert::true( |
525
|
|
|
$this->showPage->hasEmailVerificationInformation(), |
526
|
|
|
'There should be no information about email verification.' |
527
|
|
|
); |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
/** |
531
|
|
|
* @When I make them subscribed to the newsletter |
532
|
|
|
*/ |
533
|
|
|
public function iMakeThemSubscribedToTheNewsletter() |
534
|
|
|
{ |
535
|
|
|
$this->updatePage->subscribeToTheNewsletter(); |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* @When I change the password of user :customer to :newPassword |
540
|
|
|
*/ |
541
|
|
|
public function iChangeThePasswordOfUserTo(CustomerInterface $customer, $newPassword) |
542
|
|
|
{ |
543
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
544
|
|
|
$this->updatePage->changePassword($newPassword); |
545
|
|
|
$this->updatePage->saveChanges(); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
/** |
549
|
|
|
* @Then this customer should be subscribed to the newsletter |
550
|
|
|
*/ |
551
|
|
|
public function thisCustomerShouldBeSubscribedToTheNewsletter() |
552
|
|
|
{ |
553
|
|
|
Assert::true( |
554
|
|
|
$this->updatePage->isSubscribedToTheNewsletter(), |
555
|
|
|
'This customer should subscribe to the newsletter.' |
556
|
|
|
); |
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
/** |
560
|
|
|
* @Then the province in the default address should be :provinceName |
561
|
|
|
*/ |
562
|
|
|
public function theProvinceInTheDefaultAddressShouldBe($provinceName) |
563
|
|
|
{ |
564
|
|
|
Assert::true( |
565
|
|
|
$this->showPage->hasDefaultAddressProvinceName($provinceName), |
566
|
|
|
sprintf('Cannot find shipping address with province %s', $provinceName) |
567
|
|
|
); |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
/** |
571
|
|
|
* @Then this customer should have :groupName as their group |
572
|
|
|
*/ |
573
|
|
|
public function thisCustomerShouldHaveAsTheirGroup($groupName) |
574
|
|
|
{ |
575
|
|
|
/** @var UpdatePageInterface|ShowPageInterface $currentPage */ |
576
|
|
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->updatePage, $this->showPage]); |
|
|
|
|
577
|
|
|
|
578
|
|
|
Assert::same( |
579
|
|
|
$groupName, |
580
|
|
|
$currentPage->getGroupName(), |
581
|
|
|
sprintf('Customer should have %s as group, but it does not.', $groupName) |
582
|
|
|
); |
583
|
|
|
} |
584
|
|
|
|
585
|
|
|
/** |
586
|
|
|
* @Then I should see that this customer has verified the email |
587
|
|
|
*/ |
588
|
|
|
public function iShouldSeeThatThisCustomerHasVerifiedTheEmail() |
589
|
|
|
{ |
590
|
|
|
Assert::true( |
591
|
|
|
$this->showPage->hasVerifiedEmail(), |
592
|
|
|
'There should be information that this customer has verified the email.' |
593
|
|
|
); |
594
|
|
|
} |
595
|
|
|
} |
596
|
|
|
|
Let’s take a look at an example:
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
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: