You are here

public function TableTest::testThemeTableHeaderCellOption in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php \Drupal\KernelTests\Core\Render\Element\TableTest::testThemeTableHeaderCellOption()

Tests that the 'header' option in cells works correctly.

File

core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php, line 138

Class

TableTest
Tests built-in table theme functions.

Namespace

Drupal\KernelTests\Core\Render\Element

Code

public function testThemeTableHeaderCellOption() {
  $rows = [
    [
      [
        'data' => 1,
        'header' => TRUE,
      ],
      [
        'data' => 1,
        'header' => FALSE,
      ],
      [
        'data' => 1,
      ],
    ],
  ];
  $table = [
    '#type' => 'table',
    '#rows' => $rows,
  ];
  $this
    ->render($table);
  $this
    ->removeWhiteSpace();
  $this
    ->assertRaw('<th>1</th><td>1</td><td>1</td>', 'The th and td tags was printed correctly.');
}