diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php index 05921ed..bb0a6ee 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php @@ -28,6 +28,11 @@ class BlockUiTest extends WebTestBase { */ protected $adminUser; + /** + * Stores the current test theme name. + */ + protected $currentTheme; + public static function getInfo() { return array( 'name' => 'Block UI', @@ -46,17 +51,25 @@ function setUp() { $this->drupalLogin($this->adminUser); // Enable some test blocks. + $this->currentTheme = \Drupal::config('system.theme')->get('default'); $this->testBlocks = array( array( 'label' => 'Tools', 'tr' => '5', 'plugin_id' => 'system_menu_block:tools', 'settings' => array('region' => 'sidebar_second', 'id' => 'tools'), + 'test_weight' => '-2', + ), + array( + 'label' => 'Main page content', + 'tr' => '8', + 'plugin_id' => 'system_main_block', + 'settings' => array('region' => 'content', 'id' => $this->currentTheme . '_content'), 'test_weight' => '-1', ), array( 'label' => 'Powered by Drupal', - 'tr' => '12', + 'tr' => '13', 'plugin_id' => 'system_powered_by_block', 'settings' => array('region' => 'footer', 'id' => 'powered'), 'test_weight' => '0', @@ -104,12 +117,12 @@ function testBlockAdminUiPage() { foreach ($this->testBlocks as $values) { // Check if the region and weight settings changes have persisted. $this->assertOptionSelected( - 'edit-blocks-' . $values['settings']['id'] . '-region', + 'edit-blocks-' . str_replace('_', '-', $values['settings']['id']) . '-region', 'header', 'The block "' . $values['label'] . '" has the correct region assignment (header).' ); $this->assertOptionSelected( - 'edit-blocks-' . $values['settings']['id'] . '-weight', + 'edit-blocks-' . str_replace('_', '-', $values['settings']['id']) . '-weight', $values['test_weight'], 'The block "' . $values['label'] . '" has the correct weight assignment (' . $values['test_weight'] . ').' ); @@ -117,6 +130,21 @@ function testBlockAdminUiPage() { } /** + * Tests that the main page content block needs to be assigned in some region. + */ + public function testSystemMainContentBlockAssigned() { + // Try to disable main page content block. + $edit = array('blocks[' . $this->currentTheme . '_content][region]' => -1); + $this->drupalPostForm('admin/structure/block', $edit, t('Save blocks')); + $this->assertText(t('Main page content block needs to be placed in some region.'), 'Failed to disable main page content block.'); + + // Try to set main page content block in main content region. + $edit = array('blocks[' . $this->currentTheme . '_content][region]' => 'content'); + $this->drupalPostForm('admin/structure/block', $edit, t('Save blocks')); + $this->assertText(t('The block settings have been updated.'), 'Main page content block successfully moved to Content region.'); + } + + /** * Tests the block categories on the listing page. */ public function testCandidateBlockList() {