function StyleTableTest::testEmptyColumn

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testEmptyColumn()
  2. 10 core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testEmptyColumn()
  3. 11.x 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 135

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);
    $this->assertSession()
        ->elementNotExists('xpath', '//tbody/tr/td[contains(concat(" ", @class, " "), " views-field-job-1 ")]');
}

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