function TableTest::testThemeTableNoStickyHeaders
If $sticky is FALSE, no tableheader.js should be included.
File
- 
              core/tests/ Drupal/ KernelTests/ Core/ Render/ Element/ TableTest.php, line 43 
Class
- TableTest
- Tests built-in table theme functions.
Namespace
Drupal\KernelTests\Core\Render\ElementCode
public function testThemeTableNoStickyHeaders() {
  $header = [
    'one',
    'two',
    'three',
  ];
  $rows = [
    [
      1,
      2,
      3,
    ],
    [
      4,
      5,
      6,
    ],
    [
      7,
      8,
      9,
    ],
  ];
  $attributes = [];
  $caption = NULL;
  $colgroups = [];
  $table = [
    '#type' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#attributes' => $attributes,
    '#caption' => $caption,
    '#colgroups' => $colgroups,
    '#sticky' => FALSE,
  ];
  $this->render($table);
  // Make sure tableheader.js was not attached.
  $tableheader = $this->xpath("//script[contains(@src, 'tableheader.js')]");
  $this->assertCount(0, $tableheader);
  $this->assertNoRaw('sticky-enabled');
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
