function JavascriptStatesTest::doMultipleTriggerTests

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php \Drupal\FunctionalJavascriptTests\Core\Form\JavascriptStatesTest::doMultipleTriggerTests()
  2. 10 core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php \Drupal\FunctionalJavascriptTests\Core\Form\JavascriptStatesTest::doMultipleTriggerTests()

Tests states of elements triggered by multiple elements.

1 call to JavascriptStatesTest::doMultipleTriggerTests()
JavascriptStatesTest::testJavascriptStates in core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php
Tests the JavaScript #states functionality of form elements.

File

core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php, line 517

Class

JavascriptStatesTest
Tests the state of elements based on another elements.

Namespace

Drupal\FunctionalJavascriptTests\Core\Form

Code

protected function doMultipleTriggerTests() {
    $this->drupalGet('form-test/javascript-states-form');
    $page = $this->getSession()
        ->getPage();
    // Find trigger and target elements.
    $select_trigger = $page->findField('select_trigger');
    $this->assertNotEmpty($select_trigger);
    $textfield_trigger = $page->findField('textfield_trigger');
    $this->assertNotEmpty($textfield_trigger);
    $item_visible_value2_and_textfield = $this->assertSession()
        ->elementExists('css', '#edit-item-visible-when-select-trigger-has-value2-and-textfield-trigger-filled');
    // Verify initial state.
    $this->assertFalse($item_visible_value2_and_textfield->isVisible());
    // Change state: select the 'Value 2' option.
    $select_trigger->setValue('value2');
    $this->assertFalse($item_visible_value2_and_textfield->isVisible());
    // Change state: fill the textfield.
    $textfield_trigger->setValue('filled');
    $this->assertTrue($item_visible_value2_and_textfield->isVisible());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.