.../src/Plugin/DisplayVariant/BlockPageVariant.php | 16 ++-------------- .../Plugin/DisplayVariant/BlockPageVariantTest.php | 20 ++++---------------- .../modules/shortcut/src/Tests/ShortcutLinksTest.php | 9 +++++++++ .../system/src/Tests/System/PageTitleTest.php | 2 ++ .../views/src/Tests/Plugin/DisabledDisplayTest.php | 2 ++ core/modules/views_ui/src/Tests/HandlerTest.php | 9 +++++++++ 6 files changed, 28 insertions(+), 30 deletions(-) diff --git a/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php b/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php index 6fb0a9f..5abe289 100644 --- a/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php +++ b/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php @@ -128,10 +128,8 @@ public function setTitle($title) { * {@inheritdoc} */ public function build() { - // Track whether blocks showing the main content, title and messages are - // displayed. + // Track whether blocks showing the main content and messages are displayed. $main_content_block_displayed = FALSE; - $title_block_displayed = FALSE; $messages_block_displayed = FALSE; $build = [ @@ -151,7 +149,6 @@ public function build() { } elseif ($block_plugin instanceof TitleBlockPluginInterface) { $block_plugin->setTitle($this->title); - $title_block_displayed = TRUE; } elseif ($block_plugin instanceof MessagesBlockPluginInterface) { $messages_block_displayed = TRUE; @@ -188,18 +185,9 @@ public function build() { ]; } - // Analogously for the page title. - if (!$title_block_displayed) { - $build['content']['page_title'] = [ - '#type' => 'page_title', - '#title' => $this->title, - '#weight' => -900, - ]; - } - // If any render arrays are manually placed, render arrays and blocks must // be sorted. - if (!$main_content_block_displayed || !$messages_block_displayed || !$title_block_displayed) { + if (!$main_content_block_displayed || !$messages_block_displayed) { unset($build['content']['#sorted']); } diff --git a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php index 421d5e4..53be808 100644 --- a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php +++ b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php @@ -152,8 +152,8 @@ public function providerBuild() { 'block3' => [], '#sorted' => TRUE, ], - // The messages and title are rendered via the fallback in case there is - // no block rendering the main content. + // The messages are rendered via the fallback in case there is no block + // rendering the main content. 'content' => [ 'messages' => [ '#weight' => -1000, @@ -183,8 +183,8 @@ public function providerBuild() { 'block3' => [], '#sorted' => TRUE, ], - // The main content, messages and title are rendered via the fallback in - // case there are no blocks rendering them. + // The main content & messages are rendered via the fallback in case + // there are no blocks rendering them. 'content' => [ 'system_main' => [ '#weight' => -800, @@ -194,11 +194,6 @@ public function providerBuild() { '#weight' => -1000, '#type' => 'status_messages', ], - 'page_title' => [ - '#type' => 'page_title', - '#title' => 'Hi cats!', - '#weight' => -900, - ], ], ], ]; @@ -215,7 +210,6 @@ public function providerBuild() { public function testBuild(array $blocks_config, $visible_block_count, array $expected_render_array) { $display_variant = $this->setUpDisplayVariant(); $display_variant->setMainContent(['#markup' => 'Hello kittens!']); - $display_variant->setTitle('Hi cats!'); $blocks = ['top' => [], 'center' => [], 'bottom' => []]; $block_plugin = $this->getMock('Drupal\Core\Block\BlockPluginInterface'); @@ -256,7 +250,6 @@ public function testBuildWithoutMainContent() { $this->blockRepository->expects($this->once()) ->method('getVisibleBlocksPerRegion') ->willReturn([]); - $display_variant->setTitle('Hi llamas!'); $expected = [ '#cache' => [ @@ -274,11 +267,6 @@ public function testBuildWithoutMainContent() { '#weight' => -1000, '#type' => 'status_messages', ], - 'page_title' => [ - '#type' => 'page_title', - '#title' => 'Hi llamas!', - '#weight' => -900, - ], ], ]; $this->assertSame($expected, $display_variant->build()); diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php index 84f315b..e52b9b6 100644 --- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php @@ -27,6 +27,15 @@ class ShortcutLinksTest extends ShortcutTestBase { public static $modules = array('router_test', 'views', 'block'); /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + + $this->drupalPlaceBlock('page_title_block'); + } + + /** * Tests that creating a shortcut works properly. */ public function testShortcutLinkAdd() { diff --git a/core/modules/system/src/Tests/System/PageTitleTest.php b/core/modules/system/src/Tests/System/PageTitleTest.php index 847d2d4..8dab86f 100644 --- a/core/modules/system/src/Tests/System/PageTitleTest.php +++ b/core/modules/system/src/Tests/System/PageTitleTest.php @@ -36,6 +36,8 @@ protected function setUp() { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $this->drupalPlaceBlock('page_title_block'); + $this->contentUser = $this->drupalCreateUser(array('create page content', 'access content', 'administer themes', 'administer site configuration', 'link to any page')); $this->drupalLogin($this->contentUser); } diff --git a/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php b/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php index 0b6faec..2268a47 100644 --- a/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php +++ b/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php @@ -34,6 +34,8 @@ protected function setUp() { $this->enableViewsTestModule(); + $this->drupalPlaceBlock('page_title_block'); + $admin_user = $this->drupalCreateUser(array('administer site configuration')); $this->drupalLogin($admin_user); } diff --git a/core/modules/views_ui/src/Tests/HandlerTest.php b/core/modules/views_ui/src/Tests/HandlerTest.php index 6eef010..99eed48 100644 --- a/core/modules/views_ui/src/Tests/HandlerTest.php +++ b/core/modules/views_ui/src/Tests/HandlerTest.php @@ -26,6 +26,15 @@ class HandlerTest extends UITestBase { public static $testViews = array('test_view_empty', 'test_view_broken'); /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + + $this->drupalPlaceBlock('page_title_block'); + } + + /** * Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition(). * * Adds a uid column to test the relationships.