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\Contact; |
13
|
|
|
|
14
|
|
|
use Behat\Mink\Exception\ElementNotFoundException; |
15
|
|
|
use Sylius\Behat\Page\SymfonyPage; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Grzegorz Sadowski <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class ContactPage extends SymfonyPage implements ContactPageInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
public function getRouteName() |
26
|
|
|
{ |
27
|
|
|
return 'sylius_shop_contact_request'; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
|
public function specifyEmail($email) |
34
|
|
|
{ |
35
|
|
|
$this->getDocument()->fillField('Email', $email); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* {@inheritdoc} |
40
|
|
|
*/ |
41
|
|
|
public function specifyMessage($message) |
42
|
|
|
{ |
43
|
|
|
$this->getDocument()->fillField('Message', $message); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function send() |
47
|
|
|
{ |
48
|
|
|
$this->getDocument()->pressButton('Send'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritdoc} |
53
|
|
|
* |
54
|
|
|
* @throws ElementNotFoundException |
55
|
|
|
*/ |
56
|
|
|
public function getValidationMessageFor($element) |
57
|
|
|
{ |
58
|
|
|
$errorLabel = $this->getElement($element)->getParent()->find('css', '.sylius-validation-error'); |
59
|
|
|
|
60
|
|
|
if (null === $errorLabel) { |
61
|
|
|
throw new ElementNotFoundException( |
62
|
|
|
$this->getSession(), |
63
|
|
|
'Validation message', 'css', '.sylius-validation-error') |
64
|
|
|
; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return $errorLabel->getText(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
|
|
protected function getDefinedElements() |
74
|
|
|
{ |
75
|
|
|
return array_merge(parent::getDefinedElements(), [ |
76
|
|
|
'email' => '#sylius_contact_email', |
77
|
|
|
'message' => '#sylius_contact_message', |
78
|
|
|
]); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|