Passed
Pull Request — master (#305)
by Wilmer
03:36
created

ContactFormCest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 32
dl 0
loc 53
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A submitEmptyForm() 0 10 1
A openContactPage() 0 3 1
A _before() 0 3 1
A submitFormSuccessfully() 0 12 1
A submitFormWithIncorrectEmail() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
final class ContactFormCest 
6
{
7
    public function _before(FunctionalTester $I): void
0 ignored issues
show
Bug introduced by
The type FunctionalTester was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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