function TableTest::testThemeTableNoStickyHeaders

If $sticky is FALSE, no tableheader.js should be included.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php, line 40
Definition of Drupal\system\Tests\Theme\TableTest.

Class

TableTest
Unit tests for theme_table().

Namespace

Drupal\system\Tests\Theme

Code

function testThemeTableNoStickyHeaders() {
  $header = array(
    'one',
    'two',
    'three',
  );
  $rows = array(
    array(
      1,
      2,
      3,
    ),
    array(
      4,
      5,
      6,
    ),
    array(
      7,
      8,
      9,
    ),
  );
  $attributes = array();
  $caption = NULL;
  $colgroups = array();
  $this->content = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => $attributes,
    'caption' => $caption,
    'colgroups' => $colgroups,
    'sticky' => FALSE,
  ));
  $js = drupal_add_js();
  $this
    ->assertFalse(isset($js['core/misc/tableheader.js']), 'tableheader.js was not included because $sticky = FALSE.');
  $this
    ->assertNoRaw('sticky-enabled', 'Table does not have a class of sticky-enabled because $sticky = FALSE.');
  drupal_static_reset('drupal_add_js');
}