ContactCest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
dl 0
loc 47
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A openContactPage() 0 5 1
A _before() 0 3 1
A submitEmptyForm() 0 9 1
A submitFormWithIncorrectEmail() 0 11 1
A submitFormSuccessfully() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Tests\Functional;
6
7
use App\Tests\Support\FunctionalTester;
8
9
final class ContactCest
10
{
11
    public function _before(FunctionalTester $I)
12
    {
13
        $I->amOnPage('/contact');
14
    }
15
16
    public function openContactPage(FunctionalTester $I)
17
    {
18
        $I->wantTo('ensure that contact page works');
19
        $I->seeElement('button', ['name' => 'contact-button']);
20
        $I->see('Submit', ['name' => 'contact-button']);
21
    }
22
23
    public function submitEmptyForm(FunctionalTester $I)
24
    {
25
        $I->submitForm('#form-contact', []);
26
        $I->expectTo('see validations errors');
27
        $I->see('Name cannot be blank.');
28
        $I->see('Email cannot be blank.');
29
        $I->see('Email is not a valid email address.');
30
        $I->see('Subject cannot be blank.');
31
        $I->see('Body cannot be blank.');
32
    }
33
34
    public function submitFormWithIncorrectEmail(FunctionalTester $I)
35
    {
36
        $I->submitForm('#form-contact', [
37
            'ContactForm[name]' => 'tester',
38
            'ContactForm[email]' => 'tester.email',
39
            'ContactForm[subject]' => 'test subject',
40
            'ContactForm[body]' => 'test content',
41
            'ContactForm[verifyCode]' => 'testme',
42
        ]);
43
        $I->expectTo('see that email address is wrong');
44
        $I->see('Email is not a valid email address.');
45
    }
46
47
    public function submitFormSuccessfully(FunctionalTester $I)
48
    {
49
        $I->submitForm('#form-contact', [
50
            'ContactForm[name]' => 'tester',
51
            'ContactForm[email]' => '[email protected]',
52
            'ContactForm[subject]' => 'test subject',
53
            'ContactForm[body]' => 'test content',
54
        ]);
55
        $I->see("Thank you for contacting us, we'll get in touch with you as soon as possible.");
56
    }
57
}
58