diff --git a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php index 97d0c54..4ab9842 100644 --- a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php @@ -234,6 +234,27 @@ public function testViewsBlockForm() { } /** + * Tests the actual rendering of the views block. + */ + public function testBlockRendering() { + // Create a block and set a custom title. + $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('title' => 'test_view_block-block_1:1', 'views_label' => 'Custom title')); + $this->drupalGet(''); + + $result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2'); + $this->assertEqual((string) $result[0], 'Custom title'); + + // Don't override the title anymore. + $plugin = $block->getPlugin(); + $plugin->setConfigurationValue('views_label', ''); + $block->save(); + + $this->drupalGet(''); + $result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2'); + $this->assertEqual((string) $result[0], 'test_view_block'); + } + + /** * Tests the contextual links on a Views block. */ public function testBlockContextualLinks() { diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php index 1df1768..b26faa5 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php @@ -32,7 +32,13 @@ public function build() { if ($output = $this->view->executeDisplay($this->displayID)) { // Set the label to the title configured in the view. - $this->configuration['label'] = Xss::filterAdmin($this->view->getTitle()); + if (empty($this->configuration['views_label'])) { + $this->configuration['label'] = Xss::filterAdmin($this->view->getTitle()); + } + else { + $this->configuration['label'] = $this->configuration['views_label']; + } + $this->configuration['label_display'] = TRUE; // Before returning the block output, convert it to a renderable array // with contextual links. $this->addContextualLinks($output);