57 lines
1.8KB

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