ContactCept.php 1.6 KB

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