ContactPage.php 605 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace tests\_pages;
  3. use yii\codeception\BasePage;
  4. class ContactPage extends BasePage
  5. {
  6. public $route = 'site/contact';
  7. /**
  8. * @param array $contactData
  9. */
  10. public function submit(array $contactData)
  11. {
  12. foreach ($contactData as $field => $value) {
  13. if (in_array($field, ['name','email','subject','verifyCode'])) {
  14. $this->guy->fillField('input[name="ContactForm[' . $field .']"]', $value);
  15. }
  16. }
  17. if (isset($contactData['body'])) {
  18. $this->guy->fillField('textarea[name="ContactForm[body]"]',$contactData['body']);
  19. }
  20. $this->guy->click('Submit','#contact-form');
  21. }
  22. }