1 theme.test public RenderElementTypesTestCase::testDetails()

Tests Form API #type 'details'.

File

core/modules/simpletest/tests/theme.test, line 647
Tests for the theme API.

Class

RenderElementTypesTestCase
Tests the markup of core render element types passed to backdrop_render().

Code

public function testDetails() {
  $elements = array(
    // Basic 'details' element.
    array(
      'name' => "Basic 'details'",
      'value' => array(
        '#type' => 'details',
        '#summary' => t('The summary'),
        '#details' => t('Detailed content'),
      ),
      'expected' => '<details><summary><span>The summary</span></summary><div class="details-content-wrapper">Detailed content</div></details>',
    ),
    // Basic 'details' with custom id and class attributes.
    array(
      'name' => "Basic 'details' with custom attributes",
      'value' => array(
        '#type' => 'details',
        '#summary' => t('The summary'),
        '#details' => t('Detailed content'),
        '#attributes' => array(
          'id' => 'foobar-id',
          'class' => array('fooclass'),
        ),
      ),
      'expected' => '<details id="foobar-id" class="fooclass"><summary><span>The summary</span></summary><div class="details-content-wrapper">Detailed content</div></details>',
    ),
    // Expanded 'details' with child element.
    array(
      'name' => "Details with child",
      'value' => array(
        '#type' => 'details',
        '#summary' => t('The summary'),
        '#open' => TRUE,
        'child' => array(
          '#markup' => 'foobar',
        ),
      ),
      'expected' => '<details open="open"><summary><span>The summary</span></summary><div class="details-child-wrapper">foobar</div></details>',
    ),
  );

  $this->assertElements($elements);
}