Passed
Push — master ( 09d163...3c33c7 )
by Andrey
14:44
created

ContactFormCest::submitFormSuccessfully()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

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