Blame view

tests/codeception/frontend/_pages/ContactPage.php 784 Bytes
4ca21c3e   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  <?php
  
  namespace tests\codeception\frontend\_pages;
  
  use yii\codeception\BasePage;
  use frontend\models\ContactForm;
  
  /**
   * Represents contact page
   * @property \tests\codeception\frontend\AcceptanceTester|\tests\codeception\frontend\FunctionalTester $actor
   */
  class ContactPage extends BasePage
  {
      public $route = 'site/contact';
  
      /**
       * @param array $contactData
       */
      public function submit(array $contactData)
      {
          $contactForm = new ContactForm;
   
          foreach ($contactData as $field => $value) {
              $inputType = $field === 'body' ? 'textarea' : 'input';
              $this->actor->fillField($inputType . '[name="' . $contactForm->formName() . '[' . $field . ']"]', $value);
          }
          $this->actor->click('contact-button');
      }
  }