ContactCept.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. use tests\codeception\_pages\ContactPage;
  3. /* @var $scenario Codeception\Scenario */
  4. $I = new AcceptanceTester($scenario);
  5. $I->wantTo('ensure that contact works');
  6. $contactPage = ContactPage::openBy($I);
  7. $I->see('Contact', 'h1');
  8. $I->amGoingTo('submit contact form with no data');
  9. $contactPage->submit([]);
  10. if (method_exists($I, 'wait')) {
  11. $I->wait(3); // only for selenium
  12. }
  13. $I->expectTo('see validations errors');
  14. $I->see('Contact', 'h1');
  15. $I->see('Name cannot be blank');
  16. $I->see('Email cannot be blank');
  17. $I->see('Subject cannot be blank');
  18. $I->see('Body cannot be blank');
  19. $I->see('The verification code is incorrect');
  20. $I->amGoingTo('submit contact form with not correct email');
  21. $contactPage->submit([
  22. 'name' => 'tester',
  23. 'email' => 'tester.email',
  24. 'subject' => 'test subject',
  25. 'body' => 'test content',
  26. 'verifyCode' => 'testme',
  27. ]);
  28. if (method_exists($I, 'wait')) {
  29. $I->wait(3); // only for selenium
  30. }
  31. $I->expectTo('see that email address is wrong');
  32. $I->dontSee('Name cannot be blank', '.help-inline');
  33. $I->see('Email is not a valid email address.');
  34. $I->dontSee('Subject cannot be blank', '.help-inline');
  35. $I->dontSee('Body cannot be blank', '.help-inline');
  36. $I->dontSee('The verification code is incorrect', '.help-inline');
  37. $I->amGoingTo('submit contact form with correct data');
  38. $contactPage->submit([
  39. 'name' => 'tester',
  40. 'email' => 'tester@example.com',
  41. 'subject' => 'test subject',
  42. 'body' => 'test content',
  43. 'verifyCode' => 'testme',
  44. ]);
  45. if (method_exists($I, 'wait')) {
  46. $I->wait(3); // only for selenium
  47. }
  48. $I->dontSeeElement('#contact-form');
  49. $I->see('Thank you for contacting us. We will respond to you as soon as possible.');