Drupal investigation

ContactFormCest.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. class ContactFormCest
  3. {
  4. public function _before(\FunctionalTester $I)
  5. {
  6. $I->amOnPage(['site/contact']);
  7. }
  8. public function openContactPage(\FunctionalTester $I)
  9. {
  10. $I->see('Contact', 'h1');
  11. }
  12. public function submitEmptyForm(\FunctionalTester $I)
  13. {
  14. $I->submitForm('#contact-form', []);
  15. $I->expectTo('see validations errors');
  16. $I->see('Contact', 'h1');
  17. $I->see('Name cannot be blank');
  18. $I->see('Email cannot be blank');
  19. $I->see('Subject cannot be blank');
  20. $I->see('Body cannot be blank');
  21. $I->see('The verification code is incorrect');
  22. }
  23. public function submitFormWithIncorrectEmail(\FunctionalTester $I)
  24. {
  25. $I->submitForm('#contact-form', [
  26. 'ContactForm[name]' => 'tester',
  27. 'ContactForm[email]' => 'tester.email',
  28. 'ContactForm[subject]' => 'test subject',
  29. 'ContactForm[body]' => 'test content',
  30. 'ContactForm[verifyCode]' => 'testme',
  31. ]);
  32. $I->expectTo('see that email address is wrong');
  33. $I->dontSee('Name cannot be blank', '.help-inline');
  34. $I->see('Email is not a valid email address.');
  35. $I->dontSee('Subject cannot be blank', '.help-inline');
  36. $I->dontSee('Body cannot be blank', '.help-inline');
  37. $I->dontSee('The verification code is incorrect', '.help-inline');
  38. }
  39. public function submitFormSuccessfully(\FunctionalTester $I)
  40. {
  41. $I->submitForm('#contact-form', [
  42. 'ContactForm[name]' => 'tester',
  43. 'ContactForm[email]' => 'tester@example.com',
  44. 'ContactForm[subject]' => 'test subject',
  45. 'ContactForm[body]' => 'test content',
  46. 'ContactForm[verifyCode]' => 'testme',
  47. ]);
  48. $I->seeEmailIsSent();
  49. $I->dontSeeElement('#contact-form');
  50. $I->see('Thank you for contacting us. We will respond to you as soon as possible.');
  51. }
  52. }