class StyleHtmlListTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Kernel/Plugin/StyleHtmlListTest.php \Drupal\Tests\views\Kernel\Plugin\StyleHtmlListTest
Tests the HTML list style plugin.
@group views
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\views\Kernel\Plugin\StyleHtmlListTest implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of StyleHtmlListTest
See also
\Drupal\views\Plugin\views\style\HtmlList
File
-
core/
modules/ views/ tests/ src/ Kernel/ Plugin/ StyleHtmlListTest.php, line 14
Namespace
Drupal\Tests\views\Kernel\PluginView source
class StyleHtmlListTest extends ViewsKernelTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_style_html_list',
];
/**
* Make sure that the HTML list style markup is correct.
*/
public function testDefaultRowClasses() {
$view = Views::getView('test_style_html_list');
$output = $view->preview();
$output = \Drupal::service('renderer')->renderRoot($output);
// Check that an empty class attribute is not added if the wrapper class is
// not set.
$this->assertStringContainsString('<div>', $output, 'Empty class is not added to DIV when class is not set');
// Check that an empty class attribute is not added if the list class is
// not set.
$this->assertStringContainsString('<ul>', $output, 'Empty class is not added to UL when class is not set');
// Set wrapper class and list class in style options.
$view->style_plugin->options['class'] = 'class';
$view->style_plugin->options['wrapper_class'] = 'wrapper-class';
$output = $view->preview();
$output = \Drupal::service('renderer')->renderRoot($output);
// Check that class attribute is present if the wrapper class is set.
$this->assertStringContainsString('<div class="wrapper-class">', $output, 'Class is added to DIV');
// Check that class attribute is present if the list class is set.
$this->assertStringContainsString('<ul class="class">', $output, 'Class is added to UL');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.