function TableTest::testThemeTableResponsivePriority

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php \Drupal\KernelTests\Core\Render\Element\TableTest::testThemeTableResponsivePriority()
  2. 10 core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php \Drupal\KernelTests\Core\Render\Element\TableTest::testThemeTableResponsivePriority()
  3. 11.x core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php \Drupal\KernelTests\Core\Render\Element\TableTest::testThemeTableResponsivePriority()

Tests 'priority-medium' and 'priority-low' classes.

File

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

Class

TableTest
Tests built-in table theme functions.

Namespace

Drupal\KernelTests\Core\Render\Element

Code

public function testThemeTableResponsivePriority() {
    $header = [
        // Test associative header indices.
'associative_key' => [
            'data' => 1,
            'class' => [
                RESPONSIVE_PRIORITY_MEDIUM,
            ],
        ],
        // Test non-associative header indices.
[
            'data' => 2,
            'class' => [
                RESPONSIVE_PRIORITY_LOW,
            ],
        ],
        // Test no responsive priorities.
[
            'data' => 3,
        ],
    ];
    $rows = [
        [
            4,
            5,
            6,
        ],
    ];
    $table = [
        '#type' => 'table',
        '#header' => $header,
        '#rows' => $rows,
        '#responsive' => TRUE,
    ];
    $this->render($table);
    $this->assertRaw('<th class="priority-medium">1</th>', 'Header 1: the priority-medium class was applied correctly.');
    $this->assertRaw('<th class="priority-low">2</th>', 'Header 2: the priority-low class was applied correctly.');
    $this->assertRaw('<th>3</th>', 'Header 3: no priority classes were applied.');
    $this->assertRaw('<td class="priority-medium">4</td>', 'Cell 1: the priority-medium class was applied correctly.');
    $this->assertRaw('<td class="priority-low">5</td>', 'Cell 2: the priority-low class was applied correctly.');
    $this->assertRaw('<td>6</td>', 'Cell 3: no priority classes were applied.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.