You are here

protected function WebformCivicrmTestBase::editCivicrmOptionElement in Webform CiviCRM Integration 8.5

Modify settings so the element displays as a checkbox

Parameters

string $selector:

bool $multiple:

bool $enableStatic: TRUE if static radio option should be enabled.

bool $default:

string $type: possible values - checkboxes, radios, select, civicrm-options

3 calls to WebformCivicrmTestBase::editCivicrmOptionElement()
ContactSubmissionTest::testStaticCurrentUser in tests/src/FunctionalJavascript/ContactSubmissionTest.php
Test Existing Contact Element configured as Current (logged-in) User
CustomFieldSubmissionTest::testSubmitWebform in tests/src/FunctionalJavascript/CustomFieldSubmissionTest.php
Test submitting Custom Fields
GroupsTagsSubmissionTest::testSubmitWebform in tests/src/FunctionalJavascript/GroupsTagsSubmissionTest.php

File

tests/src/FunctionalJavascript/WebformCivicrmTestBase.php, line 197

Class

WebformCivicrmTestBase

Namespace

Drupal\Tests\webform_civicrm\FunctionalJavascript

Code

protected function editCivicrmOptionElement($selector, $multiple = TRUE, $enableStatic = FALSE, $default = NULL, $type = NULL) {
  $checkbox_edit_button = $this
    ->assertSession()
    ->elementExists('css', '[data-drupal-selector="' . $selector . '"] a.webform-ajax-link');
  $checkbox_edit_button
    ->click();
  $this
    ->assertSession()
    ->waitForElementVisible('css', '[data-drupal-selector="edit-change-type"]', 3000);
  $this
    ->htmlOutput();
  if ($type) {
    $this
      ->assertSession()
      ->elementExists('css', '[data-drupal-selector="edit-change-type"]')
      ->click();
    $this
      ->assertSession()
      ->waitForElementVisible('css', "[data-drupal-selector='edit-elements-{$type}-operation']", 3000)
      ->click();
    $this
      ->assertSession()
      ->waitForElementVisible('css', "[data-drupal-selector='edit-cancel']", 3000);
  }
  if ($enableStatic) {
    $this
      ->getSession()
      ->getPage()
      ->selectFieldOption("properties[civicrm_live_options]", 0);
    $this
      ->assertSession()
      ->waitForField('properties[options][options][civicrm_option_1][enabled]', 3000);
  }
  if ($default) {
    $this
      ->getSession()
      ->getPage()
      ->selectFieldOption("properties[options][default]", $default);
  }
  if (!$type || $type == 'civicrm-options') {
    $this
      ->getSession()
      ->getPage()
      ->uncheckField('properties[extra][aslist]');
    $this
      ->assertSession()
      ->checkboxNotChecked('properties[extra][aslist]');
    $this
      ->htmlOutput();
    if (!$multiple) {
      $this
        ->getSession()
        ->getPage()
        ->uncheckField('properties[extra][multiple]');
      $this
        ->assertSession()
        ->checkboxNotChecked('properties[extra][multiple]');
    }
  }
  if ($multiple) {
    $this
      ->getSession()
      ->getPage()
      ->checkField('properties[extra][multiple]');
    $this
      ->assertSession()
      ->checkboxChecked('properties[extra][multiple]');
  }
  $this
    ->htmlOutput();
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Save');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest(5000);
}