diff --git a/core/modules/views/src/Tests/Handler/AreaTest.php b/core/modules/views/src/Tests/Handler/AreaTest.php index de41c3d..953f737 100644 --- a/core/modules/views/src/Tests/Handler/AreaTest.php +++ b/core/modules/views/src/Tests/Handler/AreaTest.php @@ -116,6 +116,44 @@ public function testRenderArea() { } /** + * Tests that the header and footer areas are not rendered if empty. + */ + public function testRenderEmptyHeaderFooter() { + $header_string = '

' . $this->randomMachineName() . '

'; + $footer_string = '

' . $this->randomMachineName() . '

'; + $empty_string = '

' . $this->randomMachineName() . '

'; + + $view = Views::getView('test_example_area'); + $view->initHandlers(); + + $view->empty['test_example']->options['string'] = $empty_string; + + $output = $view->preview(); + $html = $this->container->get('renderer')->renderRoot($output); + $this->setRawContent($html); + + $xpath = '//div[contains(@class, :class)]'; + $this->assertEqual(0, count($this->xpath($xpath, [':class' => 'view-header']))); + $this->assertEqual(0, count($this->xpath($xpath, [':class' => 'view-footer']))); + + $view->header['test_example']->options['string'] = $header_string; + $view->header['test_example']->options['empty'] = TRUE; + + $view->footer['test_example']->options['string'] = $footer_string; + $view->footer['test_example']->options['empty'] = TRUE; + + $view->empty['test_example']->options['string'] = $empty_string; + + $output = $view->preview(); + $html = $this->container->get('renderer')->renderRoot($output); + $this->setRawContent($html); + + $xpath = '//div[contains(@class, :class)]'; + $this->assertEqual(1, count($this->xpath($xpath, [':class' => 'view-header']))); + $this->assertEqual(1, count($this->xpath($xpath, [':class' => 'view-footer']))); + } + + /** * Tests the access for an area. */ public function testAreaAccess() {