Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / views / tests / src / Kernel / Plugin / StyleHtmlListTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Kernel\Plugin;
4
5 use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
6 use Drupal\views\Views;
7
8 /**
9  * Tests the HTML list style plugin.
10  *
11  * @group views
12  * @see \Drupal\views\Plugin\views\style\HtmlList
13  */
14 class StyleHtmlListTest extends ViewsKernelTestBase {
15
16   /**
17    * Views used by this test.
18    *
19    * @var array
20    */
21   public static $testViews = ['test_style_html_list'];
22
23   /**
24    * Make sure that the HTML list style markup is correct.
25    */
26   public function testDefaultRowClasses() {
27     $view = Views::getView('test_style_html_list');
28     $output = $view->preview();
29     $output = \Drupal::service('renderer')->renderRoot($output);
30
31     // Check that an empty class attribute is not added if the wrapper class is
32     // not set.
33     $this->assertTrue(strpos($output, '<div>') !== FALSE, 'Empty class is not added to DIV when class is not set');
34
35     // Check that an empty class attribute is not added if the list class is
36     // not set.
37     $this->assertTrue(strpos($output, '<ul>') !== FALSE, 'Empty class is not added to UL when class is not set');
38
39     // Set wrapper class and list class in style options.
40     $view->style_plugin->options['class'] = 'class';
41     $view->style_plugin->options['wrapper_class'] = 'wrapper-class';
42
43     $output = $view->preview();
44     $output = \Drupal::service('renderer')->renderRoot($output);
45
46     // Check that class attribute is present if the wrapper class is set.
47     $this->assertTrue(strpos($output, '<div class="wrapper-class">') !== FALSE, 'Class is added to DIV');
48
49     // Check that class attribute is present if the list class is set.
50     $this->assertTrue(strpos($output, '<ul class="class">') !== FALSE, 'Class is added to UL');
51   }
52
53 }