|
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
|
|
|
* @When /^I view (their) details$/ |
|
459
|
|
|
*/ |
|
460
|
|
|
public function iViewDetailsOfTheCustomer(CustomerInterface $customer) |
|
461
|
|
|
{ |
|
462
|
|
|
$this->showPage->open(['id' => $customer->getId()]); |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
/** |
|
466
|
|
|
* @Then his name should be :name |
|
467
|
|
|
*/ |
|
468
|
|
|
public function hisNameShouldBe($name) |
|
469
|
|
|
{ |
|
470
|
|
|
Assert::same( |
|
471
|
|
|
$name, |
|
472
|
|
|
$this->showPage->getCustomerName(), |
|
473
|
|
|
'Customer name should be "%s", but it is not.' |
|
474
|
|
|
); |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
/** |
|
478
|
|
|
* @Given he should be registered since :registrationDate |
|
479
|
|
|
*/ |
|
480
|
|
|
public function hisRegistrationDateShouldBe($registrationDate) |
|
481
|
|
|
{ |
|
482
|
|
|
Assert::eq( |
|
483
|
|
|
new \DateTime($registrationDate), |
|
484
|
|
|
$this->showPage->getRegistrationDate(), |
|
485
|
|
|
'Customer registration date should be "%s", but it is not.' |
|
486
|
|
|
); |
|
487
|
|
|
} |
|
488
|
|
|
|
|
489
|
|
|
/** |
|
490
|
|
|
* @Given his email should be :email |
|
491
|
|
|
*/ |
|
492
|
|
|
public function hisEmailShouldBe($email) |
|
493
|
|
|
{ |
|
494
|
|
|
Assert::same( |
|
495
|
|
|
$email, |
|
496
|
|
|
$this->showPage->getCustomerEmail(), |
|
497
|
|
|
'Customer email should be "%s", but it is not' |
|
498
|
|
|
); |
|
499
|
|
|
} |
|
500
|
|
|
|
|
501
|
|
|
/** |
|
502
|
|
|
* @Then his default address should be :defaultAddress |
|
503
|
|
|
*/ |
|
504
|
|
|
public function hisShippingAddressShouldBe($defaultAddress) |
|
505
|
|
|
{ |
|
506
|
|
|
Assert::same( |
|
507
|
|
|
str_replace(',', '', $defaultAddress), |
|
508
|
|
|
$this->showPage->getDefaultAddress(), |
|
509
|
|
|
'Customer\'s default address should be "%s", but it is not.' |
|
510
|
|
|
); |
|
511
|
|
|
} |
|
512
|
|
|
|
|
513
|
|
|
/** |
|
514
|
|
|
* @Then I should see information about no existing account for this customer |
|
515
|
|
|
*/ |
|
516
|
|
|
public function iShouldSeeInformationAboutNoExistingAccountForThisCustomer() |
|
517
|
|
|
{ |
|
518
|
|
|
Assert::true( |
|
519
|
|
|
$this->showPage->hasAccount(), |
|
520
|
|
|
'There should be information about no account, but there is none.' |
|
521
|
|
|
); |
|
522
|
|
|
} |
|
523
|
|
|
|
|
524
|
|
|
/** |
|
525
|
|
|
* @Then I should see that this customer is subscribed to the newsletter |
|
526
|
|
|
*/ |
|
527
|
|
|
public function iShouldSeeThatThisCustomerIsSubscribedToTheNewsletter() |
|
528
|
|
|
{ |
|
529
|
|
|
Assert::true( |
|
530
|
|
|
$this->showPage->isSubscribedToNewsletter(), |
|
531
|
|
|
'There should be information that this customer is subscribed to the newsletter.' |
|
532
|
|
|
); |
|
533
|
|
|
} |
|
534
|
|
|
|
|
535
|
|
|
/** |
|
536
|
|
|
* @Then I should not see information about email verification |
|
537
|
|
|
*/ |
|
538
|
|
|
public function iShouldSeeInformationAboutEmailVerification() |
|
539
|
|
|
{ |
|
540
|
|
|
Assert::true( |
|
541
|
|
|
$this->showPage->hasEmailVerificationInformation(), |
|
542
|
|
|
'There should be no information about email verification.' |
|
543
|
|
|
); |
|
544
|
|
|
} |
|
545
|
|
|
|
|
546
|
|
|
/** |
|
547
|
|
|
* @When I make them subscribed to the newsletter |
|
548
|
|
|
*/ |
|
549
|
|
|
public function iMakeThemSubscribedToTheNewsletter() |
|
550
|
|
|
{ |
|
551
|
|
|
$this->updatePage->subscribeToTheNewsletter(); |
|
552
|
|
|
} |
|
553
|
|
|
|
|
554
|
|
|
/** |
|
555
|
|
|
* @When I change the password of user :customer to :newPassword |
|
556
|
|
|
*/ |
|
557
|
|
|
public function iChangeThePasswordOfUserTo(CustomerInterface $customer, $newPassword) |
|
558
|
|
|
{ |
|
559
|
|
|
$this->updatePage->open(['id' => $customer->getId()]); |
|
560
|
|
|
$this->updatePage->changePassword($newPassword); |
|
561
|
|
|
$this->updatePage->saveChanges(); |
|
562
|
|
|
} |
|
563
|
|
|
|
|
564
|
|
|
/** |
|
565
|
|
|
* @Then this customer should be subscribed to the newsletter |
|
566
|
|
|
*/ |
|
567
|
|
|
public function thisCustomerShouldBeSubscribedToTheNewsletter() |
|
568
|
|
|
{ |
|
569
|
|
|
Assert::true( |
|
570
|
|
|
$this->updatePage->isSubscribedToTheNewsletter(), |
|
571
|
|
|
'This customer should subscribe to the newsletter.' |
|
572
|
|
|
); |
|
573
|
|
|
} |
|
574
|
|
|
|
|
575
|
|
|
/** |
|
576
|
|
|
* @Then the province in the default address should be :provinceName |
|
577
|
|
|
*/ |
|
578
|
|
|
public function theProvinceInTheDefaultAddressShouldBe($provinceName) |
|
579
|
|
|
{ |
|
580
|
|
|
Assert::true( |
|
581
|
|
|
$this->showPage->hasDefaultAddressProvinceName($provinceName), |
|
582
|
|
|
sprintf('Cannot find shipping address with province %s', $provinceName) |
|
583
|
|
|
); |
|
584
|
|
|
} |
|
585
|
|
|
|
|
586
|
|
|
/** |
|
587
|
|
|
* @Then this customer should have :groupName as their group |
|
588
|
|
|
*/ |
|
589
|
|
|
public function thisCustomerShouldHaveAsTheirGroup($groupName) |
|
590
|
|
|
{ |
|
591
|
|
|
/** @var UpdatePageInterface|ShowPageInterface $currentPage */ |
|
592
|
|
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->updatePage, $this->showPage]); |
|
|
|
|
|
|
593
|
|
|
|
|
594
|
|
|
Assert::same( |
|
595
|
|
|
$groupName, |
|
596
|
|
|
$currentPage->getGroupName(), |
|
597
|
|
|
sprintf('Customer should have %s as group, but it does not.', $groupName) |
|
598
|
|
|
); |
|
599
|
|
|
} |
|
600
|
|
|
|
|
601
|
|
|
/** |
|
602
|
|
|
* @Then I should see that this customer has verified the email |
|
603
|
|
|
*/ |
|
604
|
|
|
public function iShouldSeeThatThisCustomerHasVerifiedTheEmail() |
|
605
|
|
|
{ |
|
606
|
|
|
Assert::true( |
|
607
|
|
|
$this->showPage->hasVerifiedEmail(), |
|
608
|
|
|
'There should be information that this customer has verified the email.' |
|
609
|
|
|
); |
|
610
|
|
|
} |
|
611
|
|
|
|
|
612
|
|
|
/** |
|
613
|
|
|
* @Then I should see a single order in the list |
|
614
|
|
|
*/ |
|
615
|
|
|
public function iShouldSeeASingleOrderInTheList() |
|
616
|
|
|
{ |
|
617
|
|
|
Assert::same( |
|
618
|
|
|
1, |
|
619
|
|
|
$this->ordersIndexPage->countItems(), |
|
620
|
|
|
'Cannot find order in the list.' |
|
621
|
|
|
); |
|
622
|
|
|
} |
|
623
|
|
|
|
|
624
|
|
|
/** |
|
625
|
|
|
* @Then I should see the order with number :orderNumber in the list |
|
626
|
|
|
*/ |
|
627
|
|
|
public function iShouldSeeASingleOrderFromCustomer($orderNumber) |
|
628
|
|
|
{ |
|
629
|
|
|
Assert::true( |
|
630
|
|
|
$this->indexPage->isSingleResourceOnPage(['number' => $orderNumber]), |
|
631
|
|
|
sprintf('Cannot find order with number "%s" in the list.', $orderNumber) |
|
632
|
|
|
); |
|
633
|
|
|
} |
|
634
|
|
|
|
|
635
|
|
|
/** |
|
636
|
|
|
* @Then I should not see the order with number :orderNumber in the list |
|
637
|
|
|
*/ |
|
638
|
|
|
public function iShouldNotSeeASingleOrderFromCustomer($orderNumber) |
|
639
|
|
|
{ |
|
640
|
|
|
Assert::false( |
|
641
|
|
|
$this->indexPage->isSingleResourceOnPage(['number' => $orderNumber]), |
|
642
|
|
|
sprintf('Cannot find order with number "%s" in the list.', $orderNumber) |
|
643
|
|
|
); |
|
644
|
|
|
} |
|
645
|
|
|
} |
|
646
|
|
|
|
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: