You are here

WebformStatesManagerTest.php in Webform 6.x

Same filename and directory in other branches
  1. 8.5 tests/src/Functional/States/WebformStatesManagerTest.php

File

tests/src/Functional/States/WebformStatesManagerTest.php
View source
<?php

namespace Drupal\Tests\webform\Functional\States;

use Drupal\Tests\webform\Functional\WebformBrowserTestBase;

/**
 * Tests for webform states manager.
 *
 * @group webform
 */
class WebformStatesManagerTest extends WebformBrowserTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
    'webform',
    'webform_test_states',
  ];

  /**
   * Webforms to load.
   *
   * @var array
   */
  protected static $testWebforms = [
    'test_states_to_text',
  ];

  /**
   * Tests states to text.
   */
  public function testStatesToText() {

    // Check converting #states to human readable text.
    $this
      ->drupalGet('/webform/test_states_to_text/confirmation');
    $this
      ->assertRaw('<label>textfield_and</label>');
    $this
      ->assertRaw('This element is <strong>required</strong> when <strong>all</strong> of the following conditions are met:<ul><li><strong>some_trigger</strong> is checked.</li><li><strong>some_value</strong> = <strong>one</strong>.</li><li><strong>some_number</strong> &gt;= <strong>1</strong>.</li></ul>');
    $this
      ->assertRaw('<label>textfield_or</label>');
    $this
      ->assertRaw('This element is <strong>required</strong> when <strong>any</strong> of the following conditions are met:<ul><li><strong>some_trigger</strong> is checked.</li><li><strong>some_value</strong> = <strong>one</strong>.</li><li><strong>some_number</strong> &gt;= <strong>1</strong>.</li></ul>');
    $this
      ->assertRaw('<label>textfield_or</label>');
    $this
      ->assertRaw('This element is <strong>required</strong> when <strong>any</strong> of the following conditions are met:<ul><li><strong>some_trigger</strong> is not checked.</li><li>When <strong>any</strong> of the following (nested) conditions are met:<ul><li><strong>some_value</strong> = <strong>one</strong>.</li><li><strong>some_number</strong> is between <strong>1</strong> and <strong>10</strong>.</li></ul></li></ul>');
  }

}

Classes

Namesort descending Description
WebformStatesManagerTest Tests for webform states manager.