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\Shop\Account; |
13
|
|
|
|
14
|
|
|
use Behat\Mink\Exception\ElementNotFoundException; |
15
|
|
|
use Sylius\Behat\Page\SymfonyPage; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Grzegorz Sadowski <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class ProfileUpdatePage extends SymfonyPage implements ProfileUpdatePageInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
public function getRouteName() |
26
|
|
|
{ |
27
|
|
|
return 'sylius_shop_account_profile_update'; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
|
public function checkValidationMessageFor($element, $message) |
34
|
|
|
{ |
35
|
|
|
$errorLabel = $this->getElement($element)->getParent()->find('css', '.sylius-validation-error'); |
36
|
|
|
|
37
|
|
|
if (null === $errorLabel) { |
38
|
|
|
throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '.sylius-validation-error'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
return $message === $errorLabel->getText(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
|
|
public function specifyFirstName($firstName) |
48
|
|
|
{ |
49
|
|
|
$this->getDocument()->fillField('First name', $firstName); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
|
|
public function specifyLastName($lastName) |
56
|
|
|
{ |
57
|
|
|
$this->getDocument()->fillField('Last name', $lastName); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
|
|
public function specifyEmail($email) |
64
|
|
|
{ |
65
|
|
|
$this->getDocument()->fillField('Email', $email); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
|
|
public function saveChanges() |
72
|
|
|
{ |
73
|
|
|
$this->getDocument()->pressButton('Save changes'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function subscribeToTheNewsletter() |
77
|
|
|
{ |
78
|
|
|
$this->getDocument()->checkField('Subscribe to the newsletter'); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* {@inheritdoc} |
83
|
|
|
*/ |
84
|
|
|
public function isSubscribedToTheNewsletter() |
85
|
|
|
{ |
86
|
|
|
return $this->getDocument()->hasCheckedField('Subscribe to the newsletter'); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* {@inheritdoc} |
91
|
|
|
*/ |
92
|
|
|
protected function getDefinedElements() |
93
|
|
|
{ |
94
|
|
|
return array_merge(parent::getDefinedElements(), [ |
95
|
|
|
'first_name' => '#sylius_customer_profile_firstName', |
96
|
|
|
'last_name' => '#sylius_customer_profile_lastName', |
97
|
|
|
'email' => '#sylius_customer_profile_email', |
98
|
|
|
]); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|