ContactCept.php 1.67 KB
Newer Older
1
<?php
2

3
use tests\codeception\_pages\ContactPage;
Mark committed
4

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

7
$I = new AcceptanceTester($scenario);
8
$I->wantTo('ensure that contact works');
Mark committed
9

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

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

Mark committed
14 15
$I->amGoingTo('submit contact form with no data');
$contactPage->submit([]);
16 17 18
if (method_exists($I, 'wait')) {
    $I->wait(3); // only for selenium
}
Mark committed
19
$I->expectTo('see validations errors');
20 21 22 23 24 25 26
$I->see('Contact', 'h1');
$I->see('Name cannot be blank');
$I->see('Email cannot be blank');
$I->see('Subject cannot be blank');
$I->see('Body cannot be blank');
$I->see('The verification code is incorrect');

Mark committed
27 28
$I->amGoingTo('submit contact form with not correct email');
$contactPage->submit([
29 30 31 32 33
    'name' => 'tester',
    'email' => 'tester.email',
    'subject' => 'test subject',
    'body' => 'test content',
    'verifyCode' => 'testme',
34
]);
35 36 37
if (method_exists($I, 'wait')) {
    $I->wait(3); // only for selenium
}
Mark committed
38
$I->expectTo('see that email adress is wrong');
39 40 41 42 43 44
$I->dontSee('Name cannot be blank', '.help-inline');
$I->see('Email is not a valid email address.');
$I->dontSee('Subject cannot be blank', '.help-inline');
$I->dontSee('Body cannot be blank', '.help-inline');
$I->dontSee('The verification code is incorrect', '.help-inline');

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