You are here

function ElementTest::testWrapperIds in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Form/ElementTest.php \Drupal\system\Tests\Form\ElementTest::testWrapperIds()

Tests wrapper ids for checkboxes and radios.

File

core/modules/system/src/Tests/Form/ElementTest.php, line 99
Contains \Drupal\system\Tests\Form\ElementTest.

Class

ElementTest
Tests building and processing of core form elements.

Namespace

Drupal\system\Tests\Form

Code

function testWrapperIds() {
  $this
    ->drupalGet('form-test/checkboxes-radios');

  // Verify that wrapper id is different from element id.
  foreach (array(
    'checkboxes',
    'radios',
  ) as $type) {
    $element_ids = $this
      ->xpath('//div[@id=:id]', array(
      ':id' => 'edit-' . $type,
    ));
    $wrapper_ids = $this
      ->xpath('//fieldset[@id=:id]', array(
      ':id' => 'edit-' . $type . '--wrapper',
    ));
    $this
      ->assertTrue(count($element_ids) == 1, format_string('A single element id found for type %type', array(
      '%type' => $type,
    )));
    $this
      ->assertTrue(count($wrapper_ids) == 1, format_string('A single wrapper id found for type %type', array(
      '%type' => $type,
    )));
  }
}