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
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Sylius\Behat\Context\Ui\Shop; |
15
|
|
|
|
16
|
|
|
use Behat\Behat\Context\Context; |
17
|
|
|
use Sylius\Behat\NotificationType; |
18
|
|
|
use Sylius\Behat\Page\PageInterface; |
19
|
|
|
use Sylius\Behat\Page\Shop\Contact\ContactPageInterface; |
20
|
|
|
use Sylius\Behat\Service\NotificationCheckerInterface; |
21
|
|
|
use Webmozart\Assert\Assert; |
22
|
|
|
|
23
|
|
|
final class ContactContext implements Context |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var ContactPageInterface |
27
|
|
|
*/ |
28
|
|
|
private $contactPage; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var NotificationCheckerInterface |
32
|
|
|
*/ |
33
|
|
|
private $notificationChecker; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param ContactPageInterface $contactPage |
37
|
|
|
* @param NotificationCheckerInterface $notificationChecker |
38
|
|
|
*/ |
39
|
|
|
public function __construct( |
40
|
|
|
ContactPageInterface $contactPage, |
41
|
|
|
NotificationCheckerInterface $notificationChecker |
42
|
|
|
) { |
43
|
|
|
$this->contactPage = $contactPage; |
44
|
|
|
$this->notificationChecker = $notificationChecker; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @When I want to request contact |
49
|
|
|
*/ |
50
|
|
|
public function iWantToRequestContact() |
51
|
|
|
{ |
52
|
|
|
$this->contactPage->open(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @When I specify the email as :email |
57
|
|
|
* @When I do not specify the email |
58
|
|
|
*/ |
59
|
|
|
public function iSpecifyTheEmail($email = null) |
60
|
|
|
{ |
61
|
|
|
$this->contactPage->specifyEmail($email); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @When I specify the message as :message |
66
|
|
|
* @When I do not specify the message |
67
|
|
|
*/ |
68
|
|
|
public function iSpecifyTheMessage($message = null) |
69
|
|
|
{ |
70
|
|
|
$this->contactPage->specifyMessage($message); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @When I send it |
75
|
|
|
* @When I try to send it |
76
|
|
|
*/ |
77
|
|
|
public function iSendIt() |
78
|
|
|
{ |
79
|
|
|
$this->contactPage->send(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @Then I should be notified that the contact request has been submitted successfully |
84
|
|
|
*/ |
85
|
|
|
public function iShouldBeNotifiedThatTheContactRequestHasBeenSubmittedSuccessfully() |
86
|
|
|
{ |
87
|
|
|
$this->notificationChecker->checkNotification( |
88
|
|
|
'Your contact request has been submitted successfully.', |
89
|
|
|
NotificationType::success() |
90
|
|
|
); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @Then /^I should be notified that the (email|message) is required$/ |
95
|
|
|
*/ |
96
|
|
|
public function iShouldBeNotifiedThatElementIsRequired($element) |
97
|
|
|
{ |
98
|
|
|
Assert::same($this->contactPage->getValidationMessageFor($element), sprintf('Please enter your %s.', $element)); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @Then I should be notified that the email is invalid |
103
|
|
|
*/ |
104
|
|
|
public function iShouldBeNotifiedThatEmailIsInvalid() |
105
|
|
|
{ |
106
|
|
|
Assert::same($this->contactPage->getValidationMessageFor('email'), 'This email is invalid.'); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @Then I should be notified that a problem occurred while sending the contact request |
111
|
|
|
*/ |
112
|
|
|
public function iShouldBeNotifiedThatAProblemOccurredWhileSendingTheContactRequest() |
113
|
|
|
{ |
114
|
|
|
$this->notificationChecker->checkNotification( |
115
|
|
|
'A problem occurred while sending the contact request. Please try again later.', |
116
|
|
|
NotificationType::failure() |
117
|
|
|
); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|