function JavascriptStatesTest::doNestedTriggerTests

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php \Drupal\FunctionalJavascriptTests\Core\Form\JavascriptStatesTest::doNestedTriggerTests()
  2. 11.x core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php \Drupal\FunctionalJavascriptTests\Core\Form\JavascriptStatesTest::doNestedTriggerTests()

Tests states of radios element triggered by other radios element.

1 call to JavascriptStatesTest::doNestedTriggerTests()
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 547

Class

JavascriptStatesTest
Tests the state of elements based on another elements.

Namespace

Drupal\FunctionalJavascriptTests\Core\Form

Code

protected function doNestedTriggerTests() {
  $this->drupalGet('form-test/javascript-states-form');
  $page = $this->getSession()
    ->getPage();
  // Find trigger and target elements.
  $radios_opposite1 = $page->findField('radios_opposite1');
  $this->assertNotEmpty($radios_opposite1);
  $radios_opposite2 = $page->findField('radios_opposite2');
  $this->assertNotEmpty($radios_opposite2);
  // Verify initial state.
  $this->assertEquals('0', $radios_opposite1->getValue());
  $this->assertEquals('1', $radios_opposite2->getValue());
  // Set $radios_opposite2 value to 0, $radios_opposite1 value should be 1.
  $radios_opposite2->setValue('0');
  $this->assertEquals('1', $radios_opposite1->getValue());
  // Set $radios_opposite1 value to 1, $radios_opposite2 value should be 0.
  $radios_opposite1->setValue('0');
  $this->assertEquals('1', $radios_opposite2->getValue());
}

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