ContactCept.php 1.56 KB
Newer Older
1
<?php
2 3
use tests\codeception\frontend\FunctionalTester;
use tests\codeception\frontend\_pages\ContactPage;
4

5 6
/* @var $scenario Codeception\Scenario */

7
$I = new FunctionalTester($scenario);
8 9 10 11 12 13 14 15 16 17
$I->wantTo('ensure that contact works');

$contactPage = ContactPage::openBy($I);

$I->see('Contact', 'h1');

$I->amGoingTo('submit contact form with no data');
$contactPage->submit([]);
$I->expectTo('see validations errors');
$I->see('Contact', 'h1');
Johnny Theill committed
18 19 20 21 22
$I->see('Name cannot be blank', '.help-block');
$I->see('Email cannot be blank', '.help-block');
$I->see('Subject cannot be blank', '.help-block');
$I->see('Body cannot be blank', '.help-block');
$I->see('The verification code is incorrect', '.help-block');
23 24 25

$I->amGoingTo('submit contact form with not correct email');
$contactPage->submit([
26 27 28 29 30
    'name' => 'tester',
    'email' => 'tester.email',
    'subject' => 'test subject',
    'body' => 'test content',
    'verifyCode' => 'testme',
31 32
]);
$I->expectTo('see that email adress is wrong');
Johnny Theill committed
33 34 35 36 37
$I->dontSee('Name cannot be blank', '.help-block');
$I->see('Email is not a valid email address.', '.help-block');
$I->dontSee('Subject cannot be blank', '.help-block');
$I->dontSee('Body cannot be blank', '.help-block');
$I->dontSee('The verification code is incorrect', '.help-block');
38 39 40

$I->amGoingTo('submit contact form with correct data');
$contactPage->submit([
41 42 43 44 45
    'name' => 'tester',
    'email' => 'tester@example.com',
    'subject' => 'test subject',
    'body' => 'test content',
    'verifyCode' => 'testme',
46 47
]);
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');