You are here

public function WebformIcheckElementTest::testIcheckElement in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_icheck/tests/src/Functional/WebformIcheckElementTest.php \Drupal\Tests\webform_icheck\Functional\WebformIcheckElementTest::testIcheckElement()

Test iCheck element.

File

modules/webform_icheck/tests/src/Functional/WebformIcheckElementTest.php, line 24

Class

WebformIcheckElementTest
Tests for iCheck element.

Namespace

Drupal\Tests\webform_icheck\Functional

Code

public function testIcheckElement() {
  $this
    ->drupalGet('/webform/test_element_icheck');

  // Check custom iCheck style set to 'flat'.
  $this
    ->assertCssSelect('.js-form-item-checkbox-custom.form-item-checkbox-custom');
  $this
    ->assertRaw('<input data-webform-icheck="flat" data-drupal-selector="edit-checkbox-custom" type="checkbox" id="edit-checkbox-custom" name="checkbox_custom" value="1" class="form-checkbox" />');

  // Check default iCheck style not set.
  $this
    ->assertCssSelect('.js-form-item-checkbox-default.form-item-checkbox-default');
  $this
    ->assertRaw('<input data-drupal-selector="edit-checkbox-default" type="checkbox" id="edit-checkbox-default" name="checkbox_default" value="1" class="form-checkbox" />');

  // Check none iCheck style not set.
  $this
    ->assertCssSelect('.js-form-item-checkbox-none.form-item-checkbox-none');
  $this
    ->assertRaw('<input data-drupal-selector="edit-checkbox-none" type="checkbox" id="edit-checkbox-none" name="checkbox_none" value="1" class="form-checkbox" />');

  // Enable default icheck style.

  /** @var \Drupal\webform\WebformThirdPartySettingsManagerInterface $third_party_settings_manager */
  $third_party_settings_manager = \Drupal::service('webform.third_party_settings_manager');
  $third_party_settings_manager
    ->setThirdPartySetting('webform_icheck', 'default_icheck', 'minimal');
  $this
    ->drupalGet('/webform/test_element_icheck');

  // Check custom iCheck style still set to 'flat'.
  $this
    ->assertCssSelect('.js-form-item-checkbox-custom.form-item-checkbox-custom');
  $this
    ->assertRaw('<input data-webform-icheck="flat" data-drupal-selector="edit-checkbox-custom" type="checkbox" id="edit-checkbox-custom" name="checkbox_custom" value="1" class="form-checkbox" />');

  // Check default iCheck style set to 'minimal'.
  $this
    ->assertCssSelect('.js-form-item-checkbox-default.form-item-checkbox-default');
  $this
    ->assertRaw('<input data-webform-icheck="minimal" data-drupal-selector="edit-checkbox-default" type="checkbox" id="edit-checkbox-default" name="checkbox_default" value="1" class="form-checkbox" />');

  // Check none iCheck style not set.
  $this
    ->assertCssSelect('.js-form-item-checkbox-none.form-item-checkbox-none');
  $this
    ->assertRaw('<input data-drupal-selector="edit-checkbox-none" type="checkbox" id="edit-checkbox-none" name="checkbox_none" value="1" class="form-checkbox" />');
}