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 specifyFirstName($firstName) |
34
|
|
|
{ |
35
|
|
|
$this->getDocument()->fillField('First name', $firstName); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* {@inheritdoc} |
40
|
|
|
*/ |
41
|
|
|
public function specifyLastName($lastName) |
42
|
|
|
{ |
43
|
|
|
$this->getDocument()->fillField('Last name', $lastName); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
|
|
public function specifyEmail($email) |
50
|
|
|
{ |
51
|
|
|
$this->getDocument()->fillField('Email', $email); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
|
|
public function saveChanges() |
58
|
|
|
{ |
59
|
|
|
$this->getDocument()->pressButton('Save changes'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* {@inheritdoc} |
64
|
|
|
*/ |
65
|
|
|
public function checkValidationMessageFor($element, $message) |
66
|
|
|
{ |
67
|
|
|
$foundedElement = $this->getFieldElement($element); |
68
|
|
|
if (null === $foundedElement) { |
69
|
|
|
throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '.pointing'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return $message === $foundedElement->find('css', '.form-error')->getText(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
|
|
protected function getDefinedElements() |
79
|
|
|
{ |
80
|
|
|
return array_merge(parent::getDefinedElements(), [ |
81
|
|
|
'first name' => '#sylius_customer_profile_firstName', |
82
|
|
|
'last name' => '#sylius_customer_profile_lastName', |
83
|
|
|
'email' => '#sylius_customer_profile_email', |
84
|
|
|
]); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param string $element |
89
|
|
|
* |
90
|
|
|
* @return \Behat\Mink\Element\NodeElement|null |
91
|
|
|
* |
92
|
|
|
* @throws ElementNotFoundException |
93
|
|
|
*/ |
94
|
|
|
private function getFieldElement($element) |
95
|
|
|
{ |
96
|
|
|
$element = $this->getElement($element); |
97
|
|
|
while (null !== $element && !($element->hasClass('field'))) { |
98
|
|
|
$element = $element->getParent(); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
return $element; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|