You are here

public function StyleTableTest::testEmptyColumn in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testEmptyColumn()

Tests that empty columns are hidden when empty_column is set.

File

core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php, line 151

Class

StyleTableTest
Tests the table style views plugin.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testEmptyColumn() {

  // Empty the 'job' data.
  \Drupal::database()
    ->update('views_test_data')
    ->fields([
    'job' => '',
  ])
    ->execute();
  $this
    ->drupalGet('test-table');

  // Test that only one of the job columns still shows.
  // Ensure that empty column header is hidden.
  $this
    ->assertSession()
    ->elementsCount('xpath', '//thead/tr/th/a[text()="Job"]', 1);
  $result = $this
    ->xpath('//tbody/tr/td[contains(concat(" ", @class, " "), " views-field-job-1 ")]');
  $this
    ->assertCount(0, $result, 'Ensure the empty table cells are hidden.');
}