You are here

public function TableTest::testThemeTableResponsivePriority in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/system/src/Tests/Theme/TableTest.php \Drupal\system\Tests\Theme\TableTest::testThemeTableResponsivePriority()
  2. 8 core/modules/system/src/Tests/Render/Element/TableTest.php \Drupal\system\Tests\Render\Element\TableTest::testThemeTableResponsivePriority()
Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Theme/TableTest.php \Drupal\system\Tests\Theme\TableTest::testThemeTableResponsivePriority()

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

File

core/modules/system/src/Tests/Theme/TableTest.php, line 219
Contains \Drupal\system\Tests\Theme\TableTest.

Class

TableTest
Tests built-in table theme functions.

Namespace

Drupal\system\Tests\Theme

Code

public function testThemeTableResponsivePriority() {
  $header = array(
    // Test associative header indices.
    'associative_key' => array(
      'data' => 1,
      'class' => array(
        RESPONSIVE_PRIORITY_MEDIUM,
      ),
    ),
    // Test non-associative header indices.
    array(
      'data' => 2,
      'class' => array(
        RESPONSIVE_PRIORITY_LOW,
      ),
    ),
    // Test no responsive priorities.
    array(
      'data' => 3,
    ),
  );
  $rows = array(
    array(
      4,
      5,
      6,
    ),
  );
  $table = array(
    '#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.');
}