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
|
|
|
*/ |
119
|
|
|
public function iSpecifyItsEmailAs($email) |
120
|
|
|
{ |
121
|
|
|
$this->createPage->specifyEmail($email); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @When I add them |
126
|
|
|
* @When I try to add it |
127
|
|
|
*/ |
128
|
|
|
public function iAddIt() |
129
|
|
|
{ |
130
|
|
|
$this->createPage->create(); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @Then the customer :customer should appear in the store |
135
|
|
|
* @Then the customer :customer should still have this email |
136
|
|
|
*/ |
137
|
|
|
public function theCustomerShould(CustomerInterface $customer) |
138
|
|
|
{ |
139
|
|
|
$this->indexPage->open(); |
140
|
|
|
|
141
|
|
|
Assert::true( |
142
|
|
|
$this->indexPage->isSingleResourceOnPage(['email' => $customer->getEmail()]), |
143
|
|
|
sprintf('Customer with email %s should exist but it does not.', $customer->getEmail()) |
144
|
|
|
); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @When I select :gender as its gender |
149
|
|
|
*/ |
150
|
|
|
public function iSelectGender($gender) |
151
|
|
|
{ |
152
|
|
|
$this->createPage->chooseGender($gender); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @When I select :group as their group |
157
|
|
|
*/ |
158
|
|
|
public function iSelectGroup($group) |
159
|
|
|
{ |
160
|
|
|
$this->createPage->chooseGroup($group); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @When I specify its birthday as :birthday |
165
|
|
|
*/ |
166
|
|
|
public function iSpecifyItsBirthdayAs($birthday) |
167
|
|
|
{ |
168
|
|
|
$this->createPage->specifyBirthday($birthday); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @Given /^I want to edit (this customer)$/ |
173
|
|
|
* @Given I want to edit the customer :customer |
174
|
|
|
*/ |
175
|
|
|
public function iWantToEditThisCustomer(CustomerInterface $customer) |
176
|
|
|
{ |
177
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @Given I want to change my password |
182
|
|
|
*/ |
183
|
|
|
public function iWantToChangeMyPassword() |
184
|
|
|
{ |
185
|
|
|
$customer = $this->sharedStorage->get('customer'); |
186
|
|
|
|
187
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @When I save my changes |
192
|
|
|
* @When I try to save my changes |
193
|
|
|
*/ |
194
|
|
|
public function iSaveMyChanges() |
195
|
|
|
{ |
196
|
|
|
$this->updatePage->saveChanges(); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @Then /^(this customer) with name "([^"]*)" should appear in the store$/ |
201
|
|
|
*/ |
202
|
|
|
public function theCustomerWithNameShouldAppearInTheRegistry(CustomerInterface $customer, $name) |
203
|
|
|
{ |
204
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
205
|
|
|
|
206
|
|
|
Assert::eq( |
207
|
|
|
$name, |
208
|
|
|
$this->updatePage->getFullName(), |
209
|
|
|
sprintf('Customer should have name %s, but they have %s.', $name, $this->updatePage->getFullName()) |
210
|
|
|
); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @When I want to see all customers in store |
215
|
|
|
*/ |
216
|
|
|
public function iWantToSeeAllCustomersInStore() |
217
|
|
|
{ |
218
|
|
|
$this->indexPage->open(); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* @Then /^I should see (\d+) customers in the list$/ |
223
|
|
|
*/ |
224
|
|
|
public function iShouldSeeCustomersInTheList($amountOfCustomers) |
225
|
|
|
{ |
226
|
|
|
Assert::same( |
227
|
|
|
(int) $amountOfCustomers, |
228
|
|
|
$this->indexPage->countItems(), |
229
|
|
|
sprintf('Amount of customers should be equal %s, but is not.', $amountOfCustomers) |
230
|
|
|
); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* @Then I should see the customer :email in the list |
235
|
|
|
*/ |
236
|
|
|
public function iShouldSeeTheCustomerInTheList($email) |
237
|
|
|
{ |
238
|
|
|
Assert::true( |
239
|
|
|
$this->indexPage->isSingleResourceOnPage(['email' => $email]), |
240
|
|
|
sprintf('Customer with email %s should exist but it does not.', $email) |
241
|
|
|
); |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @Then /^I should be notified that ([^"]+) is required$/ |
246
|
|
|
*/ |
247
|
|
|
public function iShouldBeNotifiedThatFirstNameIsRequired($elementName) |
248
|
|
|
{ |
249
|
|
|
Assert::same($this->createPage->getValidationMessage($elementName), sprintf('Please enter your %s.', $elementName)); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @Then /^I should be notified that ([^"]+) should be ([^"]+)$/ |
254
|
|
|
*/ |
255
|
|
|
public function iShouldBeNotifiedThatTheElementShouldBe($elementName, $validationMessage) |
256
|
|
|
{ |
257
|
|
|
Assert::same( |
258
|
|
|
$this->updatePage->getValidationMessage($elementName), |
259
|
|
|
sprintf('%s must be %s.', ucfirst($elementName), $validationMessage) |
260
|
|
|
); |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* @Then the customer with email :email should not appear in the store |
265
|
|
|
*/ |
266
|
|
|
public function theCustomerShouldNotAppearInTheStore($email) |
267
|
|
|
{ |
268
|
|
|
$this->indexPage->open(); |
269
|
|
|
|
270
|
|
|
Assert::false( |
271
|
|
|
$this->indexPage->isSingleResourceOnPage(['email' => $email]), |
272
|
|
|
sprintf('Customer with email %s was created, but it should not.', $email) |
273
|
|
|
); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @When I remove its first name |
278
|
|
|
*/ |
279
|
|
|
public function iRemoveItsFirstName() |
280
|
|
|
{ |
281
|
|
|
$this->updatePage->changeFirstName(''); |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @Then /^(this customer) should have an empty first name$/ |
286
|
|
|
* @Then the customer :customer should still have an empty first name |
287
|
|
|
*/ |
288
|
|
|
public function theCustomerShouldStillHaveAnEmptyFirstName(CustomerInterface $customer) |
289
|
|
|
{ |
290
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
291
|
|
|
|
292
|
|
|
Assert::eq( |
293
|
|
|
'', |
294
|
|
|
$this->updatePage->getFirstName(), |
295
|
|
|
'Customer should have an empty first name, but it does not.' |
296
|
|
|
); |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* @When I remove its last name |
301
|
|
|
*/ |
302
|
|
|
public function iRemoveItsLastName() |
303
|
|
|
{ |
304
|
|
|
$this->updatePage->changeLastName(''); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @Then /^(this customer) should have an empty last name$/ |
309
|
|
|
* @Then the customer :customer should still have an empty last name |
310
|
|
|
*/ |
311
|
|
|
public function theCustomerShouldStillHaveAnEmptyLastName(CustomerInterface $customer) |
312
|
|
|
{ |
313
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
314
|
|
|
|
315
|
|
|
Assert::eq( |
316
|
|
|
'', |
317
|
|
|
$this->updatePage->getLastName(), |
318
|
|
|
'Customer should have an empty last name, but it does not.' |
319
|
|
|
); |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* @When I remove its email |
324
|
|
|
*/ |
325
|
|
|
public function iRemoveItsEmail() |
326
|
|
|
{ |
327
|
|
|
$this->updatePage->changeEmail(''); |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
/** |
331
|
|
|
* @Then I should be notified that email is not valid |
332
|
|
|
*/ |
333
|
|
|
public function iShouldBeNotifiedThatEmailIsNotValid() |
334
|
|
|
{ |
335
|
|
|
Assert::same($this->createPage->getValidationMessage('email'), 'This email is invalid.'); |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
/** |
339
|
|
|
* @Then I should be notified that email must be unique |
340
|
|
|
*/ |
341
|
|
|
public function iShouldBeNotifiedThatEmailMustBeUnique() |
342
|
|
|
{ |
343
|
|
|
Assert::same($this->createPage->getValidationMessage('email'), 'This email is already used.'); |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* @Then there should still be only one customer with email :email |
348
|
|
|
*/ |
349
|
|
|
public function thereShouldStillBeOnlyOneCustomerWithEmail($email) |
350
|
|
|
{ |
351
|
|
|
$this->indexPage->open(); |
352
|
|
|
|
353
|
|
|
Assert::true( |
354
|
|
|
$this->indexPage->isSingleResourceOnPage(['email' => $email]), |
355
|
|
|
sprintf('Customer with email %s cannot be found.', $email) |
356
|
|
|
); |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
/** |
360
|
|
|
* @Given I want to enable :customer |
361
|
|
|
* @Given I want to disable :customer |
362
|
|
|
*/ |
363
|
|
|
public function iWantToChangeStatusOf(CustomerInterface $customer) |
364
|
|
|
{ |
365
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
/** |
369
|
|
|
* @When I enable their account |
370
|
|
|
*/ |
371
|
|
|
public function iEnableIt() |
372
|
|
|
{ |
373
|
|
|
$this->updatePage->enable(); |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* @When I disable their account |
378
|
|
|
*/ |
379
|
|
|
public function iDisableIt() |
380
|
|
|
{ |
381
|
|
|
$this->updatePage->disable(); |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* @Then /^(this customer) should be enabled$/ |
386
|
|
|
*/ |
387
|
|
|
public function thisCustomerShouldBeEnabled(CustomerInterface $customer) |
388
|
|
|
{ |
389
|
|
|
$this->indexPage->open(); |
390
|
|
|
|
391
|
|
|
Assert::eq( |
392
|
|
|
'Enabled', |
393
|
|
|
$this->indexPage->getCustomerAccountStatus($customer), |
|
|
|
|
394
|
|
|
'Customer account should be enabled, but it does not.' |
395
|
|
|
); |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* @Then /^(this customer) should be disabled$/ |
400
|
|
|
*/ |
401
|
|
|
public function thisCustomerShouldBeDisabled(CustomerInterface $customer) |
402
|
|
|
{ |
403
|
|
|
$this->indexPage->open(); |
404
|
|
|
|
405
|
|
|
Assert::eq( |
406
|
|
|
'Disabled', |
407
|
|
|
$this->indexPage->getCustomerAccountStatus($customer), |
|
|
|
|
408
|
|
|
'Customer account should be disabled, but it does not.' |
409
|
|
|
); |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
/** |
413
|
|
|
* @When I specify its password as :password |
414
|
|
|
*/ |
415
|
|
|
public function iSpecifyItsPasswordAs($password) |
416
|
|
|
{ |
417
|
|
|
$this->createPage->specifyPassword($password); |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* @When I change my password to :password |
422
|
|
|
*/ |
423
|
|
|
public function iSpecifyMyPasswordAs($password) |
424
|
|
|
{ |
425
|
|
|
$this->updatePage->changePassword($password); |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
/** |
429
|
|
|
* @When I choose create account option |
430
|
|
|
*/ |
431
|
|
|
public function iChooseCreateAccountOption() |
432
|
|
|
{ |
433
|
|
|
$this->createPage->selectCreateAccount(); |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* @When I browse orders of a customer :customer |
438
|
|
|
*/ |
439
|
|
|
public function iBrowseOrdersOfACustomer(CustomerInterface $customer) |
440
|
|
|
{ |
441
|
|
|
$this->ordersIndexPage->open(['id' => $customer->getId()]); |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
/** |
445
|
|
|
* @Then the customer :customer should have an account created |
446
|
|
|
* @Then /^(this customer) should have an account created$/ |
447
|
|
|
*/ |
448
|
|
|
public function theyShouldHaveAnAccountCreated(CustomerInterface $customer) |
449
|
|
|
{ |
450
|
|
|
Assert::notNull( |
451
|
|
|
$customer->getUser()->getPassword(), |
452
|
|
|
'Customer should have an account, but they do not.' |
453
|
|
|
); |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* @When I view details of the customer :customer |
458
|
|
|
*/ |
459
|
|
|
public function iViewDetailsOfTheCustomer(CustomerInterface $customer) |
460
|
|
|
{ |
461
|
|
|
$this->showPage->open(['id' => $customer->getId()]); |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* @Then his name should be :name |
466
|
|
|
*/ |
467
|
|
|
public function hisNameShouldBe($name) |
468
|
|
|
{ |
469
|
|
|
Assert::same( |
470
|
|
|
$name, |
471
|
|
|
$this->showPage->getCustomerName(), |
472
|
|
|
'Customer name should be "%s", but it is not.' |
473
|
|
|
); |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* @Given he should be registered since :registrationDate |
478
|
|
|
*/ |
479
|
|
|
public function hisRegistrationDateShouldBe($registrationDate) |
480
|
|
|
{ |
481
|
|
|
Assert::eq( |
482
|
|
|
new \DateTime($registrationDate), |
483
|
|
|
$this->showPage->getRegistrationDate(), |
484
|
|
|
'Customer registration date should be "%s", but it is not.' |
485
|
|
|
); |
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
/** |
489
|
|
|
* @Given his email should be :email |
490
|
|
|
*/ |
491
|
|
|
public function hisEmailShouldBe($email) |
492
|
|
|
{ |
493
|
|
|
Assert::same( |
494
|
|
|
$email, |
495
|
|
|
$this->showPage->getCustomerEmail(), |
496
|
|
|
'Customer email should be "%s", but it is not' |
497
|
|
|
); |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
/** |
501
|
|
|
* @Then his default address should be :defaultAddress |
502
|
|
|
*/ |
503
|
|
|
public function hisShippingAddressShouldBe($defaultAddress) |
504
|
|
|
{ |
505
|
|
|
Assert::same( |
506
|
|
|
str_replace(',', '', $defaultAddress), |
507
|
|
|
$this->showPage->getDefaultAddress(), |
508
|
|
|
'Customer\'s default address should be "%s", but it is not.' |
509
|
|
|
); |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* @Then I should see information about no existing account for this customer |
514
|
|
|
*/ |
515
|
|
|
public function iShouldSeeInformationAboutNoExistingAccountForThisCustomer() |
516
|
|
|
{ |
517
|
|
|
Assert::true( |
518
|
|
|
$this->showPage->hasAccount(), |
519
|
|
|
'There should be information about no account, but there is none.' |
520
|
|
|
); |
521
|
|
|
} |
522
|
|
|
|
523
|
|
|
/** |
524
|
|
|
* @Then I should see that this customer is subscribed to the newsletter |
525
|
|
|
*/ |
526
|
|
|
public function iShouldSeeThatThisCustomerIsSubscribedToTheNewsletter() |
527
|
|
|
{ |
528
|
|
|
Assert::true( |
529
|
|
|
$this->showPage->isSubscribedToNewsletter(), |
530
|
|
|
'There should be information that this customer is subscribed to the newsletter.' |
531
|
|
|
); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* @Then I should not see information about email verification |
536
|
|
|
*/ |
537
|
|
|
public function iShouldSeeInformationAboutEmailVerification() |
538
|
|
|
{ |
539
|
|
|
Assert::true( |
540
|
|
|
$this->showPage->hasEmailVerificationInformation(), |
541
|
|
|
'There should be no information about email verification.' |
542
|
|
|
); |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
/** |
546
|
|
|
* @When I make them subscribed to the newsletter |
547
|
|
|
*/ |
548
|
|
|
public function iMakeThemSubscribedToTheNewsletter() |
549
|
|
|
{ |
550
|
|
|
$this->updatePage->subscribeToTheNewsletter(); |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
/** |
554
|
|
|
* @When I change the password of user :customer to :newPassword |
555
|
|
|
*/ |
556
|
|
|
public function iChangeThePasswordOfUserTo(CustomerInterface $customer, $newPassword) |
557
|
|
|
{ |
558
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
559
|
|
|
$this->updatePage->changePassword($newPassword); |
560
|
|
|
$this->updatePage->saveChanges(); |
561
|
|
|
} |
562
|
|
|
|
563
|
|
|
/** |
564
|
|
|
* @Given I reset their password |
565
|
|
|
*/ |
566
|
|
|
public function iResetTheirPassword() |
567
|
|
|
{ |
568
|
|
|
$this->showPage->resetPassword(); |
569
|
|
|
} |
570
|
|
|
|
571
|
|
|
/** |
572
|
|
|
* @Then this customer should be subscribed to the newsletter |
573
|
|
|
*/ |
574
|
|
|
public function thisCustomerShouldBeSubscribedToTheNewsletter() |
575
|
|
|
{ |
576
|
|
|
Assert::true( |
577
|
|
|
$this->updatePage->isSubscribedToTheNewsletter(), |
578
|
|
|
'This customer should subscribe to the newsletter.' |
579
|
|
|
); |
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
/** |
583
|
|
|
* @Then the province in the default address should be :provinceName |
584
|
|
|
*/ |
585
|
|
|
public function theProvinceInTheDefaultAddressShouldBe($provinceName) |
586
|
|
|
{ |
587
|
|
|
Assert::true( |
588
|
|
|
$this->showPage->hasDefaultAddressProvinceName($provinceName), |
589
|
|
|
sprintf('Cannot find shipping address with province %s', $provinceName) |
590
|
|
|
); |
591
|
|
|
} |
592
|
|
|
|
593
|
|
|
/** |
594
|
|
|
* @Then this customer should have :groupName as their group |
595
|
|
|
*/ |
596
|
|
|
public function thisCustomerShouldHaveAsTheirGroup($groupName) |
597
|
|
|
{ |
598
|
|
|
/** @var UpdatePageInterface|ShowPageInterface $currentPage */ |
599
|
|
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->updatePage, $this->showPage]); |
|
|
|
|
600
|
|
|
|
601
|
|
|
Assert::same( |
602
|
|
|
$groupName, |
603
|
|
|
$currentPage->getGroupName(), |
604
|
|
|
sprintf('Customer should have %s as group, but it does not.', $groupName) |
605
|
|
|
); |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* @Then I should see that this customer has verified the email |
610
|
|
|
*/ |
611
|
|
|
public function iShouldSeeThatThisCustomerHasVerifiedTheEmail() |
612
|
|
|
{ |
613
|
|
|
Assert::true( |
614
|
|
|
$this->showPage->hasVerifiedEmail(), |
615
|
|
|
'There should be information that this customer has verified the email.' |
616
|
|
|
); |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
/** |
620
|
|
|
* @Then I should see a single order in the list |
621
|
|
|
*/ |
622
|
|
|
public function iShouldSeeASingleOrderInTheList() |
623
|
|
|
{ |
624
|
|
|
Assert::same( |
625
|
|
|
1, |
626
|
|
|
$this->ordersIndexPage->countItems(), |
627
|
|
|
'Cannot find order in the list.' |
628
|
|
|
); |
629
|
|
|
} |
630
|
|
|
|
631
|
|
|
/** |
632
|
|
|
* @Then I should see the order with number :orderNumber in the list |
633
|
|
|
*/ |
634
|
|
|
public function iShouldSeeASingleOrderFromCustomer($orderNumber) |
635
|
|
|
{ |
636
|
|
|
Assert::true( |
637
|
|
|
$this->indexPage->isSingleResourceOnPage(['number' => $orderNumber]), |
638
|
|
|
sprintf('Cannot find order with number "%s" in the list.', $orderNumber) |
639
|
|
|
); |
640
|
|
|
} |
641
|
|
|
|
642
|
|
|
/** |
643
|
|
|
* @Then I should not see the order with number :orderNumber in the list |
644
|
|
|
*/ |
645
|
|
|
public function iShouldNotSeeASingleOrderFromCustomer($orderNumber) |
646
|
|
|
{ |
647
|
|
|
Assert::false( |
648
|
|
|
$this->indexPage->isSingleResourceOnPage(['number' => $orderNumber]), |
649
|
|
|
sprintf('Cannot find order with number "%s" in the list.', $orderNumber) |
650
|
|
|
); |
651
|
|
|
} |
652
|
|
|
} |
653
|
|
|
|
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: