0
0

ContactCest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. }