You are here

public function StyleTableTest::testEmptyColumn in Drupal 8

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

Test 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.
  $result = $this
    ->xpath('//thead/tr/th/a[text()="Job"]');
  $this
    ->assertCount(1, $result, 'Ensure that empty column header is hidden.');
  $result = $this
    ->xpath('//tbody/tr/td[contains(concat(" ", @class, " "), " views-field-job-1 ")]');
  $this
    ->assertCount(0, $result, 'Ensure the empty table cells are hidden.');
}