|
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\Page\Admin\Customer; |
|
13
|
|
|
|
|
14
|
|
|
use Sylius\Behat\Page\SymfonyPage; |
|
15
|
|
|
use Webmozart\Assert\Assert; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @author Magdalena Banasiak <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class ShowPage extends SymfonyPage implements ShowPageInterface |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* {@inheritdoc} |
|
24
|
|
|
*/ |
|
25
|
|
|
public function isRegistered() |
|
26
|
|
|
{ |
|
27
|
|
|
$username = $this->getDocument()->find('css', '#username'); |
|
28
|
|
|
|
|
29
|
|
|
return null !== $username; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* {@inheritdoc} |
|
34
|
|
|
*/ |
|
35
|
|
|
public function deleteAccount() |
|
36
|
|
|
{ |
|
37
|
|
|
$deleteButton = $this->getElement('delete_account_button'); |
|
38
|
|
|
$deleteButton->pressButton('Delete'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritdoc} |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getCustomerEmail() |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->getElement('customer_email')->getText(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* {@inheritdoc} |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getCustomerName() |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->getElement('customer_name')->getText(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritdoc} |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getRegistrationDate() |
|
61
|
|
|
{ |
|
62
|
|
|
return new \DateTime(str_replace('Customer since ', '', $this->getElement('registration_date')->getText())); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* {@inheritdoc} |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getDefaultAddress() |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->getElement('default_address')->getText(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritdoc} |
|
75
|
|
|
*/ |
|
76
|
|
|
public function hasAccount() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->hasElement('no_account'); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* {@inheritdoc} |
|
83
|
|
|
*/ |
|
84
|
|
|
public function isSubscribedToNewsletter() |
|
85
|
|
|
{ |
|
86
|
|
|
$subscribedToNewsletter = $this->getElement('subscribed_to_newsletter'); |
|
|
|
|
|
|
87
|
|
|
if ($subscribedToNewsletter->find('css', 'i.green')) { |
|
|
|
|
|
|
88
|
|
|
return true; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
return false; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* {@inheritdoc} |
|
96
|
|
|
*/ |
|
97
|
|
|
public function hasDefaultAddressProvinceName($provinceName) |
|
98
|
|
|
{ |
|
99
|
|
|
$defaultAddressProvince = $this->getElement('default_address')->getText(); |
|
|
|
|
|
|
100
|
|
|
|
|
101
|
|
|
return false !== stripos($defaultAddressProvince, $provinceName); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* {@inheritdoc} |
|
106
|
|
|
*/ |
|
107
|
|
|
public function hasVerifiedEmail() |
|
108
|
|
|
{ |
|
109
|
|
|
$verifiedEmail = $this->getElement('verified_email'); |
|
110
|
|
|
if ($verifiedEmail->find('css', 'i.green')) { |
|
|
|
|
|
|
111
|
|
|
return true; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
return false; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* {@inheritdoc} |
|
119
|
|
|
*/ |
|
120
|
|
|
public function getGroupName() |
|
121
|
|
|
{ |
|
122
|
|
|
$group = $this->getElement('group'); |
|
123
|
|
|
|
|
124
|
|
|
Assert::notNull($group, 'There should be element group on page.'); |
|
125
|
|
|
|
|
126
|
|
|
list($text, $groupName) = explode(':', $group->getText()); |
|
|
|
|
|
|
127
|
|
|
|
|
128
|
|
|
return trim($groupName); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* {@inheritdoc} |
|
133
|
|
|
*/ |
|
134
|
|
|
public function hasEmailVerificationInformation() |
|
135
|
|
|
{ |
|
136
|
|
|
return null === $this->getDocument()->find('css', '#verified-email'); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* {@inheritdoc} |
|
141
|
|
|
*/ |
|
142
|
|
|
public function hasImpersonateButton() |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->hasElement('impersonate_button'); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* {@inheritdoc} |
|
149
|
|
|
*/ |
|
150
|
|
|
public function impersonate() |
|
151
|
|
|
{ |
|
152
|
|
|
$this->getElement('impersonate_button')->click(); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* {@inheritdoc} |
|
157
|
|
|
*/ |
|
158
|
|
|
public function getSuccessFlashMessage() |
|
159
|
|
|
{ |
|
160
|
|
|
return trim($this->getElement('flash_message')->getText()); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* {@inheritdoc} |
|
165
|
|
|
*/ |
|
166
|
|
|
public function getRouteName() |
|
167
|
|
|
{ |
|
168
|
|
|
return 'sylius_admin_customer_show'; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* {@inheritdoc} |
|
173
|
|
|
*/ |
|
174
|
|
|
protected function getDefinedElements() |
|
175
|
|
|
{ |
|
176
|
|
|
return array_merge(parent::getDefinedElements(), [ |
|
177
|
|
|
'customer_email' => '#info .content.extra > a', |
|
178
|
|
|
'customer_name' => '#info .content > a', |
|
179
|
|
|
'default_address' => '#defaultAddress address', |
|
180
|
|
|
'delete_account_button' => '#actions', |
|
181
|
|
|
'flash_message' => '.ui.icon.positive.message .content p', |
|
182
|
|
|
'group' => '.group', |
|
183
|
|
|
'impersonate_button' => '#impersonate', |
|
184
|
|
|
'no_account' => '#no-account', |
|
185
|
|
|
'registration_date' => '#info .content .date', |
|
186
|
|
|
'subscribed_to_newsletter' => '#subscribed-to-newsletter', |
|
187
|
|
|
'verified_email' => '#verified-email', |
|
188
|
|
|
]); |
|
189
|
|
|
} |
|
190
|
|
|
} |
|
191
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.