Passed
Branch update-yii-dataview (d90e66)
by Wilmer
13:07
created

ContactCest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A openContactPage() 0 5 1
A submitEmptyForm() 0 5 1
A _before() 0 3 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\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('Value cannot be blank.');
28
    }
29
30
    public function submitFormWithIncorrectEmail(FunctionalTester $I)
31
    {
32
        $I->submitForm('#form-contact', [
33
            'ContactForm[name]' => 'tester',
34
            'ContactForm[email]' => 'tester.email',
35
            'ContactForm[subject]' => 'test subject',
36
            'ContactForm[body]' => 'test content',
37
            'ContactForm[verifyCode]' => 'testme',
38
        ]);
39
        $I->expectTo('see that email address is wrong');
40
        $I->see('This value is not a valid email address.');
41
    }
42
43
    public function submitFormSuccessfully(FunctionalTester $I)
44
    {
45
        $I->submitForm('#form-contact', [
46
            'ContactForm[name]' => 'tester',
47
            'ContactForm[email]' => '[email protected]',
48
            'ContactForm[subject]' => 'test subject',
49
            'ContactForm[body]' => 'test content',
50
        ]);
51
        $I->see("Thank you for contacting us, we'll get in touch with you as soon as possible.");
52
    }
53
}
54