ContactCest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace frontend\tests\functional;
  3. use frontend\tests\FunctionalTester;
  4. /* @var $scenario \Codeception\Scenario */
  5. class ContactCest
  6. {
  7. public function _before(FunctionalTester $I)
  8. {
  9. $I->amOnPage(['site/contact']);
  10. }
  11. public function checkContact(FunctionalTester $I)
  12. {
  13. $I->see('Contact', 'h1');
  14. }
  15. public function checkContactSubmitNoData(FunctionalTester $I)
  16. {
  17. $I->submitForm('#contact-form', []);
  18. $I->see('Contact', 'h1');
  19. $I->seeValidationError('Name cannot be blank');
  20. $I->seeValidationError('Email cannot be blank');
  21. $I->seeValidationError('Subject cannot be blank');
  22. $I->seeValidationError('Body cannot be blank');
  23. $I->seeValidationError('The verification code is incorrect');
  24. }
  25. public function checkContactSubmitNotCorrectEmail(FunctionalTester $I)
  26. {
  27. $I->submitForm('#contact-form', [
  28. 'ContactForm[name]' => 'tester',
  29. 'ContactForm[email]' => 'tester.email',
  30. 'ContactForm[subject]' => 'test subject',
  31. 'ContactForm[body]' => 'test content',
  32. 'ContactForm[verifyCode]' => 'testme',
  33. ]);
  34. $I->seeValidationError('Email is not a valid email address.');
  35. $I->dontSeeValidationError('Name cannot be blank');
  36. $I->dontSeeValidationError('Subject cannot be blank');
  37. $I->dontSeeValidationError('Body cannot be blank');
  38. $I->dontSeeValidationError('The verification code is incorrect');
  39. }
  40. public function checkContactSubmitCorrectData(FunctionalTester $I)
  41. {
  42. $I->submitForm('#contact-form', [
  43. 'ContactForm[name]' => 'tester',
  44. 'ContactForm[email]' => 'tester@example.com',
  45. 'ContactForm[subject]' => 'test subject',
  46. 'ContactForm[body]' => 'test content',
  47. 'ContactForm[verifyCode]' => 'testme',
  48. ]);
  49. $I->seeEmailIsSent();
  50. $I->see('Thank you for contacting us. We will respond to you as soon as possible.');
  51. }
  52. }