StyleHtmlListTest.php in Drupal 9
File
core/modules/views/tests/src/Kernel/Plugin/StyleHtmlListTest.php
View source
<?php
namespace Drupal\Tests\views\Kernel\Plugin;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
class StyleHtmlListTest extends ViewsKernelTestBase {
public static $testViews = [
'test_style_html_list',
];
public function testDefaultRowClasses() {
$view = Views::getView('test_style_html_list');
$output = $view
->preview();
$output = \Drupal::service('renderer')
->renderRoot($output);
$this
->assertStringContainsString('<div>', $output, 'Empty class is not added to DIV when class is not set');
$this
->assertStringContainsString('<ul>', $output, 'Empty class is not added to UL when class is not set');
$view->style_plugin->options['class'] = 'class';
$view->style_plugin->options['wrapper_class'] = 'wrapper-class';
$output = $view
->preview();
$output = \Drupal::service('renderer')
->renderRoot($output);
$this
->assertStringContainsString('<div class="wrapper-class">', $output, 'Class is added to DIV');
$this
->assertStringContainsString('<ul class="class">', $output, 'Class is added to UL');
}
}