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

5
$I = new AcceptanceTester($scenario);
6 7 8 9 10 11 12 13
$I->wantTo('ensure that contact works');

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

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

$I->amGoingTo('submit contact form with no data');
$contactPage->submit([]);
14 15 16
if (method_exists($I, 'wait')) {
    $I->wait(3); // only for selenium
}
17 18
$I->expectTo('see validations errors');
$I->see('Contact', 'h1');
Johnny Theill committed
19 20 21 22 23
$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');
24 25 26

$I->amGoingTo('submit contact form with not correct email');
$contactPage->submit([
27 28 29 30 31
    'name' => 'tester',
    'email' => 'tester.email',
    'subject' => 'test subject',
    'body' => 'test content',
    'verifyCode' => 'testme',
32
]);
33 34 35
if (method_exists($I, 'wait')) {
    $I->wait(3); // only for selenium
}
36
$I->expectTo('see that email adress is wrong');
Johnny Theill committed
37 38 39 40 41
$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');
42 43 44

$I->amGoingTo('submit contact form with correct data');
$contactPage->submit([
45 46 47 48 49
    'name' => 'tester',
    'email' => 'tester@example.com',
    'subject' => 'test subject',
    'body' => 'test content',
    'verifyCode' => 'testme',
50
]);
51 52 53
if (method_exists($I, 'wait')) {
    $I->wait(3); // only for selenium
}
54
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');