1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
final class ContactFormCest |
6
|
|
|
{ |
7
|
|
|
public function _before(FunctionalTester $I): void |
8
|
|
|
{ |
9
|
|
|
$I->amOnRoute('site/contact'); |
10
|
|
|
} |
11
|
|
|
|
12
|
|
|
public function openContactPage(FunctionalTester $I): void |
13
|
|
|
{ |
14
|
|
|
$I->see('Contact', 'h1'); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function submitEmptyForm(FunctionalTester $I): void |
18
|
|
|
{ |
19
|
|
|
$I->submitForm('#contact-form', []); |
20
|
|
|
$I->expectTo('see validations errors'); |
21
|
|
|
$I->see('Contact', 'h1'); |
22
|
|
|
$I->see('Name cannot be blank'); |
23
|
|
|
$I->see('Email cannot be blank'); |
24
|
|
|
$I->see('Subject cannot be blank'); |
25
|
|
|
$I->see('Body cannot be blank'); |
26
|
|
|
$I->see('The verification code is incorrect'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function submitFormWithIncorrectEmail(FunctionalTester $I): void |
30
|
|
|
{ |
31
|
|
|
$I->submitForm('#contact-form', [ |
32
|
|
|
'ContactForm[name]' => 'tester', |
33
|
|
|
'ContactForm[email]' => 'tester.email', |
34
|
|
|
'ContactForm[subject]' => 'test subject', |
35
|
|
|
'ContactForm[body]' => 'test content', |
36
|
|
|
'ContactForm[verifyCode]' => 'testme', |
37
|
|
|
]); |
38
|
|
|
$I->expectTo('see that email address is wrong'); |
39
|
|
|
$I->dontSee('Name cannot be blank', '.help-inline'); |
40
|
|
|
$I->see('Email is not a valid email address.'); |
41
|
|
|
$I->dontSee('Subject cannot be blank', '.help-inline'); |
42
|
|
|
$I->dontSee('Body cannot be blank', '.help-inline'); |
43
|
|
|
$I->dontSee('The verification code is incorrect', '.help-inline'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function submitFormSuccessfully(FunctionalTester $I): void |
47
|
|
|
{ |
48
|
|
|
$I->submitForm('#contact-form', [ |
49
|
|
|
'ContactForm[name]' => 'tester', |
50
|
|
|
'ContactForm[email]' => '[email protected]', |
51
|
|
|
'ContactForm[subject]' => 'test subject', |
52
|
|
|
'ContactForm[body]' => 'test content', |
53
|
|
|
'ContactForm[verifyCode]' => 'testme', |
54
|
|
|
]); |
55
|
|
|
$I->seeEmailIsSent(); |
56
|
|
|
$I->dontSeeElement('#contact-form'); |
57
|
|
|
$I->see('Thank you for contacting us. We will respond to you as soon as possible.'); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|