function DisplayPageTest::testEmptyRow
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayPageTest::testEmptyRow()
- 8.9.x core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayPageTest::testEmptyRow()
- 10 core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayPageTest::testEmptyRow()
Tests the templates with empty rows.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Plugin/ DisplayPageTest.php, line 232
Class
- DisplayPageTest
- Tests the page display plugin.
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testEmptyRow() : void {
$view = Views::getView('test_page_display');
$view->initDisplay();
$view->newDisplay('page', 'Page', 'empty_row');
$view->save();
$styles = [
'default' => '//div[@class="views-row"]',
// Olivero does not use the 'views-col' class.
'grid' => '//div[contains(@class, "views-col") or contains(@class, "views-view-grid__item-inner")]',
'html_list' => '//div[@class="item-list"]//li',
];
$themes = [
'olivero',
'stable9',
'stark',
'claro',
];
foreach ($themes as $theme) {
\Drupal::service('theme_installer')->install([
$theme,
]);
\Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme($theme));
foreach ($styles as $type => $xpath) {
$view = Views::getView('test_page_display');
$view->storage
->invalidateCaches();
$view->initDisplay();
$view->setDisplay('empty_row');
$view->displayHandlers
->get('empty_row')->default_display->options['style']['type'] = $type;
$view->initStyle();
$this->executeView($view);
$output = $view->preview();
$output = \Drupal::service('renderer')->renderRoot($output);
$this->setRawContent($output);
$this->assertCount(5, $this->xpath("{$xpath}[not(text()) and not(node())]"), "Empty rows in theme '{$theme}', type '{$type}'.");
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.