function ViewsAddDefaultTableCssClassUpdateTest::testViewsPostUpdateAddDefaultTableCssClass
Tests the upgrade path adding table style default CSS class.
File
-
core/
modules/ views/ tests/ src/ Functional/ Update/ ViewsAddDefaultTableCssClassUpdateTest.php, line 47
Class
- ViewsAddDefaultTableCssClassUpdateTest
- Tests the addition of the default table style `class` setting.
Namespace
Drupal\Tests\views\Functional\UpdateCode
public function testViewsPostUpdateAddDefaultTableCssClass() : void {
$view = View::load('test_table_css_class');
$data = $view->toArray();
$counter = 0;
foreach ($data['display'] as $display) {
if (array_key_exists('style', $display['display_options'])) {
$style = $display['display_options']['style'];
// The style has type and options so we need to ensure we are reviewing options.
if (is_array($style) && array_key_exists('options', $style)) {
$this->assertArrayNotHasKey('class', $style['options']);
$counter++;
}
}
}
$this->assertEquals(3, $counter);
$this->runUpdates();
$view = View::load('test_table_css_class');
$data = $view->toArray();
$counter = 0;
foreach ($data['display'] as $display) {
if (array_key_exists('style', $display['display_options'])) {
$style = $display['display_options']['style'];
// The style has type and options so we need to ensure we are reviewing options.
if (is_array($style) && array_key_exists('options', $style)) {
if (is_array($style) && array_key_exists('options', $style)) {
$this->assertArrayHasKey('class', $style['options']);
$counter++;
}
}
}
}
$this->assertEquals(3, $counter);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.