diff --git a/core/modules/views/src/Tests/Plugin/ViewsNoResultsBehaviorTest.php b/core/modules/views/src/Tests/Plugin/ViewsNoResultsBehaviorTest.php new file mode 100644 index 0000000..50610f8 --- /dev/null +++ b/core/modules/views/src/Tests/Plugin/ViewsNoResultsBehaviorTest.php @@ -0,0 +1,45 @@ +enableViewsTestModule(); + $user = $this->createUser([], null, TRUE); + $this->drupalLogin($user); + + // Set the Stark theme and use the default templates from views module. + /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ + $theme_handler = \Drupal::service('theme_handler'); + $theme_handler->install(['stark']); + $this->config('system.theme')->set('default', 'stark')->save(); + } + + /** + * Tests the view with the text. + */ + public function testDuplicateText() { + $output = $this->drupalGet('admin/content'); + $this->assertEqual(1, substr_count($output, 'No content available.'), 'Only one message should be present'); + } + +} diff --git a/core/modules/views/templates/views-view.html.twig b/core/modules/views/templates/views-view.html.twig index e81b1ab..22d517d 100644 --- a/core/modules/views/templates/views-view.html.twig +++ b/core/modules/views/templates/views-view.html.twig @@ -51,8 +51,12 @@ {{ exposed }} {{ attachment_before }} - {{ rows }} - {{ empty }} + {% if rows %} + {{ rows }} + {% elseif empty %} + {{ empty }} + {% endif %} + {{ pager }} {{ attachment_after }}