|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Spryker Commerce OS. |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types = 1); |
|
9
|
|
|
|
|
10
|
|
|
namespace PyzTest\Yves\Customer\Presentation; |
|
11
|
|
|
|
|
12
|
|
|
use PyzTest\Yves\Customer\CustomerPresentationTester; |
|
13
|
|
|
use PyzTest\Yves\Customer\PageObject\CustomerProfilePage; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Auto-generated group annotations |
|
17
|
|
|
* |
|
18
|
|
|
* @group PyzTest |
|
19
|
|
|
* @group Yves |
|
20
|
|
|
* @group Customer |
|
21
|
|
|
* @group Presentation |
|
22
|
|
|
* @group CustomerProfileCest |
|
23
|
|
|
* Add your own group annotations below this line |
|
24
|
|
|
*/ |
|
25
|
|
|
class CustomerProfileCest |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @param \PyzTest\Yves\Customer\CustomerPresentationTester $i |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
31
|
|
|
*/ |
|
32
|
|
|
public function _before(CustomerPresentationTester $i): void |
|
33
|
|
|
{ |
|
34
|
|
|
$i->amYves(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param \PyzTest\Yves\Customer\CustomerPresentationTester $i |
|
39
|
|
|
* |
|
40
|
|
|
* @return void |
|
41
|
|
|
*/ |
|
42
|
|
|
public function testICanUpdateProfileData(CustomerPresentationTester $i): void |
|
43
|
|
|
{ |
|
44
|
|
|
$i->amLoggedInCustomer(); |
|
45
|
|
|
$i->amOnPage(CustomerProfilePage::URL); |
|
46
|
|
|
|
|
47
|
|
|
$customerTransfer = CustomerProfilePage::getCustomerData(CustomerProfilePage::REGISTERED_CUSTOMER_EMAIL); |
|
48
|
|
|
|
|
49
|
|
|
$i->selectOption(CustomerProfilePage::FORM_FIELD_SELECTOR_SALUTATION, $customerTransfer->getSalutation()); |
|
50
|
|
|
$i->fillField(CustomerProfilePage::FORM_FIELD_SELECTOR_FIRST_NAME, $customerTransfer->getFirstName()); |
|
51
|
|
|
$i->fillField(CustomerProfilePage::FORM_FIELD_SELECTOR_LAST_NAME, $customerTransfer->getLastName()); |
|
52
|
|
|
$i->click('Submit', ['name' => 'profileForm']); |
|
53
|
|
|
|
|
54
|
|
|
$i->seeInSource(CustomerProfilePage::SUCCESS_MESSAGE); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param \PyzTest\Yves\Customer\CustomerPresentationTester $i |
|
59
|
|
|
* |
|
60
|
|
|
* @return void |
|
61
|
|
|
*/ |
|
62
|
|
|
public function testICanUpdateEmail(CustomerPresentationTester $i): void |
|
63
|
|
|
{ |
|
64
|
|
|
$i->amLoggedInCustomer(); |
|
65
|
|
|
$i->amOnPage(CustomerProfilePage::URL); |
|
66
|
|
|
|
|
67
|
|
|
$i->fillField(CustomerProfilePage::FORM_FIELD_SELECTOR_EMAIL, CustomerProfilePage::REGISTERED_CUSTOMER_EMAIL); |
|
68
|
|
|
$i->click(CustomerProfilePage::BUTTON_PROFILE_FORM_SUBMIT_TEXT, CustomerProfilePage::BUTTON_PROFILE_FORM_SUBMIT_SELECTOR); |
|
69
|
|
|
|
|
70
|
|
|
$i->seeInSource(CustomerProfilePage::CONFIRM_EMAIL_MESSAGE); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param \PyzTest\Yves\Customer\CustomerPresentationTester $i |
|
75
|
|
|
* |
|
76
|
|
|
* @return void |
|
77
|
|
|
*/ |
|
78
|
|
|
public function testICanNotUpdateEmailToAnAlreadyUsedOne(CustomerPresentationTester $i): void |
|
79
|
|
|
{ |
|
80
|
|
|
$i->amLoggedInCustomer(); |
|
81
|
|
|
$i->haveRegisteredCustomer(['email' => CustomerProfilePage::REGISTERED_CUSTOMER_EMAIL]); |
|
82
|
|
|
$i->amOnPage(CustomerProfilePage::URL); |
|
83
|
|
|
|
|
84
|
|
|
$i->fillField(CustomerProfilePage::FORM_FIELD_SELECTOR_EMAIL, CustomerProfilePage::REGISTERED_CUSTOMER_EMAIL); |
|
85
|
|
|
$i->click(CustomerProfilePage::BUTTON_PROFILE_FORM_SUBMIT_TEXT, CustomerProfilePage::BUTTON_PROFILE_FORM_SUBMIT_SELECTOR); |
|
86
|
|
|
|
|
87
|
|
|
$i->seeInSource(CustomerProfilePage::ERROR_MESSAGE_EMAIL); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param \PyzTest\Yves\Customer\CustomerPresentationTester $i |
|
92
|
|
|
* |
|
93
|
|
|
* @return void |
|
94
|
|
|
*/ |
|
95
|
|
|
public function testICanChangePassword(CustomerPresentationTester $i): void |
|
96
|
|
|
{ |
|
97
|
|
|
$customerTransfer = $i->amLoggedInCustomer(); |
|
98
|
|
|
$i->amOnPage(CustomerProfilePage::URL); |
|
99
|
|
|
|
|
100
|
|
|
$oldPassword = $customerTransfer->getPassword(); |
|
101
|
|
|
$newPassword = strrev($oldPassword); |
|
102
|
|
|
|
|
103
|
|
|
$i->fillField(CustomerProfilePage::FORM_FIELD_CHANGE_PASSWORD_SELECTOR_PASSWORD, $oldPassword); |
|
104
|
|
|
$i->fillField(CustomerProfilePage::FORM_FIELD_CHANGE_PASSWORD_SELECTOR_NEW_PASSWORD, $newPassword); |
|
105
|
|
|
$i->fillField(CustomerProfilePage::FORM_FIELD_CHANGE_PASSWORD_SELECTOR_NEW_PASSWORD_CONFIRM, $newPassword); |
|
106
|
|
|
$i->click(CustomerProfilePage::BUTTON_PROFILE_FORM_CHANGE_PASSWORD_SUBMIT_SELECTOR); |
|
107
|
|
|
|
|
108
|
|
|
$i->seeInSource(CustomerProfilePage::SUCCESS_MESSAGE_CHANGE_PASSWORD); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @param \PyzTest\Yves\Customer\CustomerPresentationTester $i |
|
113
|
|
|
* |
|
114
|
|
|
* @return void |
|
115
|
|
|
*/ |
|
116
|
|
|
public function testICanNotChangePasswordWhenNewPasswordsNotMatch(CustomerPresentationTester $i): void |
|
117
|
|
|
{ |
|
118
|
|
|
$i->amLoggedInCustomer(); |
|
119
|
|
|
$i->amOnPage(CustomerProfilePage::URL); |
|
120
|
|
|
|
|
121
|
|
|
$customerTransfer = CustomerProfilePage::getCustomerData(CustomerProfilePage::REGISTERED_CUSTOMER_EMAIL); |
|
122
|
|
|
$oldPassword = $customerTransfer->getPassword(); |
|
123
|
|
|
$newPassword = strrev($oldPassword); |
|
124
|
|
|
|
|
125
|
|
|
$i->fillField(CustomerProfilePage::FORM_FIELD_CHANGE_PASSWORD_SELECTOR_PASSWORD, $oldPassword); |
|
126
|
|
|
$i->fillField(CustomerProfilePage::FORM_FIELD_CHANGE_PASSWORD_SELECTOR_NEW_PASSWORD, $newPassword); |
|
127
|
|
|
$i->fillField(CustomerProfilePage::FORM_FIELD_CHANGE_PASSWORD_SELECTOR_NEW_PASSWORD_CONFIRM, 'not matching password'); |
|
128
|
|
|
$i->click(CustomerProfilePage::BUTTON_PROFILE_FORM_CHANGE_PASSWORD_SUBMIT_SELECTOR); |
|
129
|
|
|
|
|
130
|
|
|
$i->seeInSource(CustomerProfilePage::ERROR_MESSAGE_CHANGE_PASSWORD); |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|