You are here

public function WebformVariantExcludedTest::testVariantExcluded in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/Variant/WebformVariantExcludedTest.php \Drupal\Tests\webform\Functional\Variant\WebformVariantExcludedTest::testVariantExcluded()

Test variant element.

File

tests/src/Functional/Variant/WebformVariantExcludedTest.php, line 31

Class

WebformVariantExcludedTest
Tests for the webform variant excluded.

Namespace

Drupal\Tests\webform\Functional\Variant

Code

public function testVariantExcluded() {
  $this
    ->drupalLogin($this->rootUser);

  // Check that the test variant plugin is available to 'test_variant_*'
  // webforms.
  $this
    ->drupalGet('/admin/structure/webform/manage/test_variant_multiple/element/add/webform_variant');
  $this
    ->assertRaw('<option value="override">Override</option>');
  $this
    ->assertRaw('<option value="test">Test</option>');

  // Exclude the test variant plugin.
  \Drupal::configFactory()
    ->getEditable('webform.settings')
    ->set('variant.excluded_variants', [
    'test' => 'test',
  ])
    ->save();

  // Check that the test variant plugin is now excluded.
  $this
    ->drupalGet('/admin/structure/webform/manage/test_variant_multiple/element/add/webform_variant');
  $this
    ->assertRaw('<option value="override">Override</option>');
  $this
    ->assertNoRaw('<option value="test">Test</option>');
}