ContactCept.php 1.5 KB

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