function StyleTableTest::testFieldInColumns
Same name in other branches
- 8.9.x core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testFieldInColumns()
- 10 core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testFieldInColumns()
- 11.x core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testFieldInColumns()
Tests table fields in columns.
File
-
core/
modules/ views/ tests/ src/ Functional/ Plugin/ StyleTableTest.php, line 85
Class
- StyleTableTest
- Tests the table style views plugin.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testFieldInColumns() {
$this->drupalGet('test-table');
// Ensure that both columns are in separate tds.
// Check for class " views-field-job ", because just "views-field-job" won't
// do: "views-field-job-1" would also contain "views-field-job".
// @see Drupal\system\Tests\Form\ElementTest::testButtonClasses().
$this->assertSession()
->elementExists('xpath', '//tbody/tr/td[contains(concat(" ", @class, " "), " views-field-job ")]');
$this->assertSession()
->elementExists('xpath', '//tbody/tr/td[contains(concat(" ", @class, " "), " views-field-job-1 ")]');
// Combine the second job-column with the first one, with ', ' as separator.
$view = View::load('test_table');
$display =& $view->getDisplay('default');
$display['display_options']['style']['options']['columns']['job_1'] = 'job';
$display['display_options']['style']['options']['info']['job']['separator'] = ', ';
$view->save();
// Ensure that both columns are properly combined.
$this->drupalGet('test-table');
$this->assertSession()
->elementExists('xpath', '//tbody/tr/td[contains(concat(" ", @class, " "), " views-field-job views-field-job-1 ")]');
$this->assertSession()
->elementExists('xpath', '//tbody/tr/td[contains(., "Drummer, Drummer")]');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.