diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 18f1c7f..b2a19d1 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -307,14 +307,12 @@ function _block_get_renderable_region($list = array()) { } } else { - $key_components = explode('.', $key); - $id = array_pop($key_components); $build[$key] = array( '#block' => $block, '#weight' => $block->get('weight'), '#pre_render' => array('_block_get_renderable_block'), '#cache' => array( - 'keys' => array($id, $settings['module']), + 'keys' => array($key, $settings['module']), 'granularity' => $settings['cache'], 'bin' => 'block', 'tags' => array('content' => TRUE), @@ -405,9 +403,15 @@ function block_theme_initialize($theme) { $regions = system_region_list($theme, REGIONS_VISIBLE); $default_theme_blocks = entity_load_multiple_by_properties('block', array('theme' => $default_theme)); foreach ($default_theme_blocks as $default_theme_block_id => $default_theme_block) { - list(, $machine_name) = explode('.', $default_theme_block_id); + if (strpos($default_theme_block_id, $default_theme . '_') === 0) { + $id = str_replace($default_theme, $theme, $default_theme_block_id); + } + else { + $id = $theme . '_' . $default_theme_block_id; + } $block = $default_theme_block->createDuplicate(); - $block->set('id', $theme . '.' . $machine_name); + $block->set('id', $id); + $block->set('theme', $theme); // If the region isn't supported by the theme, assign the block to the // theme's default region. if (!isset($regions[$block->get('region')])) { @@ -561,10 +565,8 @@ function template_preprocess_block(&$variables) { } // Create a valid HTML ID and make sure it is unique. if ($id = $variables['elements']['#block']->id()) { - $config_id = explode('.', $id); - $machine_name = array_pop($config_id); - $variables['attributes']['id'] = drupal_html_id('block-' . $machine_name); - $variables['theme_hook_suggestions'][] = 'block__' . $machine_name; + $variables['attributes']['id'] = drupal_html_id('block-' . $id); + $variables['theme_hook_suggestions'][] = 'block__' . $id; } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php index 3ce4513..f0626eb 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php @@ -153,7 +153,7 @@ public function testBlockDelete() { // Place the block. $instance = array( - 'machine_name' => drupal_strtolower($edit['info']), + 'id' => drupal_strtolower($edit['info']), 'settings[label]' => $edit['info'], 'region' => 'sidebar_first', ); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php index 53f8f5a..e5a4e71 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php @@ -104,7 +104,7 @@ public function testBlockFields() { $url = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default'); // Place the block. $instance = array( - 'machine_name' => drupal_strtolower($edit['info']), + 'id' => drupal_strtolower($edit['info']), 'settings[label]' => $edit['info'], 'region' => 'sidebar_first', ); diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index e873888..fcd2e72 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -81,14 +81,10 @@ public static function create(ContainerInterface $container) { public function form(array $form, array &$form_state) { $entity = $this->entity; $form['#tree'] = TRUE; - $form['id'] = array( - '#type' => 'value', - '#value' => $entity->id(), - ); $form['settings'] = $entity->getPlugin()->buildConfigurationForm(array(), $form_state); // If creating a new block, calculate a safe default machine name. - $form['machine_name'] = array( + $form['id'] = array( '#type' => 'machine_name', '#title' => $this->t('Machine name'), '#maxlength' => 64, @@ -255,14 +251,6 @@ protected function actions(array $form, array &$form_state) { public function validate(array $form, array &$form_state) { parent::validate($form, $form_state); - $entity = $this->entity; - if ($entity->isNew()) { - form_set_value($form['id'], $entity->get('theme') . '.' . $form_state['values']['machine_name'], $form_state); - } - if (!empty($form['machine_name']['#disabled'])) { - $config_id = explode('.', $form_state['values']['machine_name']); - $form_state['values']['machine_name'] = array_pop($config_id); - } $form_state['values']['visibility']['role']['roles'] = array_filter($form_state['values']['visibility']['role']['roles']); // The Block Entity form puts all block plugin form elements in the // settings form element, so just pass that to the block for validation. @@ -270,7 +258,7 @@ public function validate(array $form, array &$form_state) { 'values' => &$form_state['values']['settings'] ); // Call the plugin validate handler. - $entity->getPlugin()->validateConfigurationForm($form, $settings); + $this->entity->getPlugin()->validateConfigurationForm($form, $settings); } /** diff --git a/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php index e465455..5a8bd6f 100644 --- a/core/modules/block/lib/Drupal/block/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Entity/Block.php @@ -135,23 +135,12 @@ public function label($langcode = NULL) { } /** - * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::get(); - */ - public function get($property_name, $langcode = NULL) { - // The theme is stored in the entity ID. - $value = parent::get($property_name, $langcode); - if ($property_name == 'theme' && !$value) { - list($value) = explode('.', $this->id()); - } - return $value; - } - - /** * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::getExportProperties(); */ public function getExportProperties() { $properties = parent::getExportProperties(); $names = array( + 'theme', 'region', 'weight', 'plugin', diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php index 3621f26..52120f1 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php @@ -48,13 +48,13 @@ public function setUp() { public function testBlockOperationAlter() { // Add a test block, any block will do. // Set the machine name so the test_operation link can be built later. - $block_machine_name = Unicode::strtolower($this->randomName(16)); - $this->drupalPlaceBlock('system_powered_by_block', array('machine_name' => $block_machine_name)); + $block_id = Unicode::strtolower($this->randomName(16)); + $this->drupalPlaceBlock('system_powered_by_block', array('id' => $block_id)); // Get the Block listing. $this->drupalGet('admin/structure/block'); - $test_operation_link = 'admin/structure/block/manage/stark.' . $block_machine_name . '/test_operation'; + $test_operation_link = 'admin/structure/block/manage/' . $block_id . '/test_operation'; // Test if the test_operation link is on the page. $this->assertLinkByHref($test_operation_link); } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php index 31bce89..f559b87 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php @@ -40,7 +40,7 @@ function setUp() { // Enable our test blocks. $this->drupalPlaceBlock('system_menu_block:menu-tools'); - $this->drupalPlaceBlock('test_html_id', array('machine_name' => 'test_id_block')); + $this->drupalPlaceBlock('test_html_id', array('id' => 'test_id_block')); } /** diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php index a078821..8367d6a 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php @@ -62,7 +62,7 @@ public function testLanguageBlockVisibility() { // Enable a standard block and set the visibility setting for one language. $edit = array( 'visibility[language][langcodes][en]' => TRUE, - 'machine_name' => strtolower($this->randomName(8)), + 'id' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', ); $this->drupalPost('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, t('Save block')); @@ -99,7 +99,6 @@ public function testLanguageBlockVisibilityLanguageDelete() { ), ), ), - 'machine_name' => 'language_block_test', ); $block = $this->drupalPlaceBlock('system_powered_by_block', $edit); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php index f92e850..da6202e 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php @@ -45,17 +45,17 @@ function testBlockRenderOrder() { // Enable test blocks and place them in the same region. $region = 'header'; $test_blocks = array( - 'stark.powered' => array( + 'stark_powered' => array( 'weight' => '-3', - 'machine_name' => 'powered', + 'id' => 'stark_powered', ), - 'stark.by' => array( + 'stark_by' => array( 'weight' => '3', - 'machine_name' => 'by', + 'id' => 'stark_by', ), - 'stark.drupal' => array( + 'stark_drupal' => array( 'weight' => '3', - 'machine_name' => 'drupal', + 'id' => 'stark_drupal', ), ); @@ -65,7 +65,7 @@ function testBlockRenderOrder() { 'label' => 'Test Block', 'region' => $region, 'weight' => $test_block['weight'], - 'machine_name' => $test_block['machine_name'], + 'id' => $test_block['id'], )); } @@ -74,14 +74,13 @@ function testBlockRenderOrder() { $controller = $this->container->get('entity.manager')->getStorageController('block'); foreach ($controller->loadMultiple() as $return_block) { - $settings = $return_block->get('settings'); $id = $return_block->get('id'); if ($return_block_weight = $return_block->get('weight')) { $this->assertTrue($test_blocks[$id]['weight'] == $return_block_weight, 'Block weight is set as "' . $return_block_weight . '" for ' . $id . ' block.'); - $position[$id] = strpos($test_content, 'block-' . $test_blocks[$id]['machine_name']); + $position[$id] = strpos($test_content, drupal_html_class('block-' . $test_blocks[$id]['id'])); } } - $this->assertTrue($position['stark.powered'] < $position['stark.by'], 'Blocks with different weight are rendered in the correct order.'); - $this->assertTrue($position['stark.drupal'] < $position['stark.by'], 'Blocks with identical weight are rendered in reverse alphabetical order.'); + $this->assertTrue($position['stark_powered'] < $position['stark_by'], 'Blocks with different weight are rendered in the correct order.'); + $this->assertTrue($position['stark_drupal'] < $position['stark_by'], 'Blocks with identical weight are rendered in reverse alphabetical order.'); } } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index 1e72237..cb3d82d 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -80,7 +80,8 @@ protected function createTests() { // Create a block with only required values. $entity = $this->controller->create(array( - 'id' => 'stark.test_block', + 'id' => 'test_block', + 'theme' => 'stark', 'plugin' => 'test_html_id', )); $entity->save(); @@ -88,16 +89,17 @@ protected function createTests() { $this->assertTrue($entity instanceof Block, 'The newly created entity is a Block.'); // Verify all of the block properties. - $actual_properties = \Drupal::config('block.block.stark.test_block')->get(); + $actual_properties = \Drupal::config('block.block.test_block')->get(); $this->assertTrue(!empty($actual_properties['uuid']), 'The block UUID is set.'); unset($actual_properties['uuid']); // Ensure that default values are filled in. $expected_properties = array( - 'id' => 'stark.test_block', + 'id' => 'test_block', 'weight' => '', 'status' => '1', 'langcode' => language_default()->id, + 'theme' => 'stark', 'region' => '-1', 'plugin' => 'test_html_id', 'settings' => array( @@ -117,7 +119,7 @@ protected function createTests() { * Tests the rendering of blocks. */ protected function loadTests() { - $entity = $this->controller->load('stark.test_block'); + $entity = $this->controller->load('test_block'); $this->assertTrue($entity instanceof Block, 'The loaded entity is a Block.'); @@ -133,7 +135,7 @@ protected function loadTests() { */ protected function renderTests() { // Test the rendering of a block. - $entity = entity_load('block', 'stark.test_block'); + $entity = entity_load('block', 'test_block'); $output = entity_view($entity, 'block'); $expected = array(); $expected[] = '
'; @@ -153,7 +155,8 @@ protected function renderTests() { // Test the rendering of a block with a given title. $entity = $this->controller->create(array( - 'id' => 'stark.test_block2', + 'id' => 'test_block2', + 'theme' => 'stark', 'plugin' => 'test_html_id', 'settings' => array( 'label' => 'Powered by Bananas', @@ -182,7 +185,7 @@ protected function renderTests() { * Tests the deleting of blocks. */ protected function deleteTests() { - $entity = $this->controller->load('stark.test_block'); + $entity = $this->controller->load('test_block'); // Ensure that the storage isn't currently empty. $config_storage = $this->container->get('config.storage'); @@ -209,7 +212,7 @@ public function testDefaultBlocks() { $entities = $this->controller->loadMultiple(); $entity = reset($entities); - $this->assertEqual($entity->id(), 'stark.test_block', 'The default test block was loaded.'); + $this->assertEqual($entity->id(), 'test_block', 'The default test block was loaded.'); } } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php index 9c2966f..c24a2cb 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php @@ -40,7 +40,7 @@ function testBlockThemeHookSuggestions() { $block = entity_create('block', array( 'plugin' => 'system_menu_block:menu-admin', 'region' => 'footer', - 'id' => \Drupal::config('system.theme')->get('default') . '.machinename', + 'id' => 'machinename', )); $variables = array(); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index 94c8b9e..c290cfd 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -32,7 +32,7 @@ function testBlockVisibility() { // Enable a standard block. $default_theme = \Drupal::config('system.theme')->get('default'); $edit = array( - 'machine_name' => strtolower($this->randomName(8)), + 'id' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', 'settings[label]' => $title, ); @@ -73,7 +73,7 @@ function testBlockVisibilityListedEmpty() { // Enable a standard block. $default_theme = \Drupal::config('system.theme')->get('default'); $edit = array( - 'machine_name' => strtolower($this->randomName(8)), + 'id' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', 'settings[label]' => $title, 'visibility[path][visibility]' => BLOCK_VISIBILITY_LISTED, @@ -103,15 +103,14 @@ function testBlock() { $block = array(); $block['id'] = 'system_powered_by_block'; $block['settings[label]'] = $this->randomName(8); - $block['machine_name'] = strtolower($this->randomName(8)); $block['theme'] = \Drupal::config('system.theme')->get('default'); $block['region'] = 'header'; // Set block title to confirm that interface works and override any custom titles. - $this->drupalPost('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'machine_name' => $block['machine_name'], 'region' => $block['region']), t('Save block')); + $this->drupalPost('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'id' => $block['id'], 'region' => $block['region']), t('Save block')); $this->assertText(t('The block configuration has been saved.'), 'Block title set.'); // Check to see if the block was created by checking its configuration. - $instance = entity_load('block', $block['theme'] . '.' . $block['machine_name']); + $instance = entity_load('block', $block['id']); $this->assertEqual($instance->label(), $block['settings[label]'], 'Stored block title found.'); @@ -122,7 +121,7 @@ function testBlock() { // Set the block to the disabled region. $edit = array(); - $edit['blocks[' . $block['theme'] . '.' . $block['machine_name'] . '][region]'] = -1; + $edit['blocks[' . $block['id'] . '][region]'] = -1; $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); // Confirm that the block is now listed as disabled. @@ -133,11 +132,11 @@ function testBlock() { $this->assertNoText(t($block['settings[label]'])); // Check for
if the machine name // is my_block_instance_name. - $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-' . strtr(strtolower($block['machine_name']), '-', '_'))); + $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-' . str_replace('_', '-', strtolower($block['id'])))); $this->assertNoFieldByXPath($xpath, FALSE, 'Block found in no regions.'); // Test deleting the block from the edit form. - $this->drupalGet('admin/structure/block/manage/' . $block['theme'] . '.' . $block['machine_name']); + $this->drupalGet('admin/structure/block/manage/' . $block['id']); $this->drupalPost(NULL, array(), t('Delete')); $this->assertRaw(t('Are you sure you want to delete the block %name?', array('%name' => $block['settings[label]']))); $this->drupalPost(NULL, array(), t('Delete')); @@ -151,11 +150,11 @@ function testHideBlockTitle() { $block_name = 'system_powered_by_block'; // Create a random title for the block. $title = $this->randomName(8); - $machine_name = strtolower($this->randomName(8)); + $id = strtolower($this->randomName(8)); // Enable a standard block. $default_theme = variable_get('theme_default', 'stark'); $edit = array( - 'machine_name' => $machine_name, + 'id' => $id, 'region' => 'sidebar_first', 'settings[label]' => $title, ); @@ -168,7 +167,7 @@ function testHideBlockTitle() { $edit = array( 'settings[label_display]' => FALSE, ); - $this->drupalPost('admin/structure/block/manage/' . $default_theme . '.' . $machine_name, $edit, t('Save block')); + $this->drupalPost('admin/structure/block/manage/' . $id, $edit, t('Save block')); $this->assertText('The block configuration has been saved.', 'Block was saved'); $this->drupalGet('user'); @@ -191,7 +190,7 @@ function moveBlockToRegion(array $block, $region) { // Set the created block to a specific region. $block += array('theme' => \Drupal::config('system.theme')->get('default')); $edit = array(); - $edit['blocks[' . $block['theme'] . '.' . $block['machine_name'] . '][region]'] = $region; + $edit['blocks[' . $block['id'] . '][region]'] = $region; $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); // Confirm that the block was moved to the proper region. @@ -204,7 +203,7 @@ function moveBlockToRegion(array $block, $region) { // Confirm that the custom block was found at the proper region. $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array( ':region-class' => 'region region-' . drupal_html_class($region), - ':block-id' => 'block-' . strtr(strtolower($block['machine_name']), '-', '_'), + ':block-id' => 'block-' . str_replace('_', '-', strtolower($block['id'])), )); $this->assertFieldByXPath($xpath, NULL, t('Block found in %region_name region.', array('%region_name' => drupal_html_class($region)))); } @@ -222,7 +221,6 @@ function testBlockRehash() { // Add a test block. $block = array(); $block['id'] = 'test_cache'; - $block['machine_name'] = strtolower($this->randomName(8)); $block['theme'] = \Drupal::config('system.theme')->get('default'); $block['region'] = 'header'; $block = $this->drupalPlaceBlock('test_cache', array('region' => 'header')); @@ -297,7 +295,7 @@ function testBlockModuleDisable() { // that the form still functions as expected. $edit = array( 'settings[label]' => $this->randomName(8), - 'machine_name' => strtolower($this->randomName(8)), + 'id' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', ); $this->drupalPost('admin/structure/block/add/system_powered_by_block/stark', $edit, t('Save block')); @@ -305,7 +303,7 @@ function testBlockModuleDisable() { $this->assertText($edit['settings[label]']); // Update the weight of a block. - $edit = array('blocks[stark.' . $edit['machine_name'] . '][weight]' => -1); + $edit = array('blocks[' . $edit['id'] . '][weight]' => -1); $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); $this->assertText(t('The block settings have been updated.')); @@ -324,13 +322,10 @@ function testBlockModuleDisable() { // correct regions. $this->drupalGet(''); foreach ($regions as $region) { - // @todo Use a proper method for this. - $name_pieces = explode('.', $blocks[$region]->id()); - $machine_name = array_pop($name_pieces); $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array( ':region-class' => 'region region-' . drupal_html_class($region), - ':block-id' => 'block-' . strtr(strtolower($machine_name), '-', '_'), - )); + ':block-id' => 'block-' . str_replace('_', '-', strtolower($blocks[$region]->id())), + )); $this->assertFieldByXPath($xpath, NULL, format_string('Block %name found in the %region region.', array( '%name' => $blocks[$region]->label(), '%region' => $region, diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php b/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php index 5c8bf6a..7a10c8a 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php @@ -67,45 +67,11 @@ function setUp() { 'footer', ); - $default_theme = variable_get('theme_default', 'stark'); - $manager = $this->container->get('plugin.manager.block'); - $instances = config_get_storage_names_with_prefix('plugin.core.block.' . $default_theme); - foreach ($instances as $plugin_id) { - \Drupal::config($plugin_id)->delete(); + $block_storage = $this->container->get('entity.manager')->getStorageController('block'); + $blocks = $block_storage->loadByProperties(array('theme' => \Drupal::config('system.theme')->get('default'))); + foreach ($blocks as $block) { + $block->delete(); } } - /** - * Moves a block to a given region via the UI and confirms the result. - * - * @param array $block - * An array of information about the block, including the following keys: - * - module: The module providing the block. - * - title: The title of the block. - * - delta: The block's delta key. - * @param string $region - * The machine name of the theme region to move the block to, for example - * 'header' or 'sidebar_first'. - */ - function moveBlockToRegion(array $block, $region) { - // Set the created block to a specific region. - $edit = array(); - $edit['blocks[0][region]'] = $region; - $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); - - // Confirm that the block was moved to the proper region. - $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array( '%region_name' => $region))); - - // Confirm that the block is being displayed. - $this->drupalGet(''); - $this->assertText(t($block['title']), 'Block successfully being displayed on the page.'); - - // Confirm that the custom block was found at the proper region. - $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array( - ':region-class' => 'region region-' . drupal_html_class($region), - ':block-id' => 'block-' . strtr(strtolower($block['machine_name']), '-', '_'), - )); - $this->assertFieldByXPath($xpath, NULL, t('Block found in %region_name region.', array('%region_name' => drupal_html_class($region)))); - } - } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php index 95cab30..64c4227 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php @@ -51,14 +51,14 @@ function setUp() { 'label' => 'Tools', 'tr' => '5', 'plugin_id' => 'system_menu_block:menu-tools', - 'settings' => array('region' => 'sidebar_second', 'machine_name' => 'tools'), + 'settings' => array('region' => 'sidebar_second', 'id' => 'tools'), 'test_weight' => '-1', ), array( 'label' => 'Powered by Drupal', 'tr' => '12', 'plugin_id' => 'system_powered_by_block', - 'settings' => array('region' => 'footer', 'machine_name' => 'powered'), + 'settings' => array('region' => 'footer', 'id' => 'powered'), 'test_weight' => '0', ), ); @@ -81,24 +81,24 @@ function testBlockAdminUiPage() { $element = $this->xpath('//*[@id="blocks"]/tbody/tr[' . $values['tr'] . ']/td[1]/text()'); $this->assertTrue((string)$element[0] == $values['label'], 'The "' . $values['label'] . '" block title is set inside the ' . $values['settings']['region'] . ' region.'); // Look for a test block region select form element. - $this->assertField('blocks[stark.' . $values['settings']['machine_name'] . '][region]', 'The block "' . $values['label'] . '" has a region assignment field.'); + $this->assertField('blocks[' . $values['settings']['id'] . '][region]', 'The block "' . $values['label'] . '" has a region assignment field.'); // Move the test block to the header region. - $edit['blocks[stark.' . $values['settings']['machine_name'] . '][region]'] = 'header'; + $edit['blocks[' . $values['settings']['id'] . '][region]'] = 'header'; // Look for a test block weight select form element. - $this->assertField('blocks[stark.' . $values['settings']['machine_name'] . '][weight]', 'The block "' . $values['label'] . '" has a weight assignment field.'); + $this->assertField('blocks[' . $values['settings']['id'] . '][weight]', 'The block "' . $values['label'] . '" has a weight assignment field.'); // Change the test block's weight. - $edit['blocks[stark.' . $values['settings']['machine_name'] . '][weight]'] = $values['test_weight']; + $edit['blocks[' . $values['settings']['id'] . '][weight]'] = $values['test_weight']; } $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); foreach ($this->testBlocks as $values) { // Check if the region and weight settings changes have persisted. $this->assertOptionSelected( - 'edit-blocks-stark' . $values['settings']['machine_name'] . '-region', + 'edit-blocks-' . $values['settings']['id'] . '-region', 'header', 'The block "' . $values['label'] . '" has the correct region assignment (header).' ); $this->assertOptionSelected( - 'edit-blocks-stark' . $values['settings']['machine_name'] . '-weight', + 'edit-blocks-' . $values['settings']['id'] . '-weight', $values['test_weight'], 'The block "' . $values['label'] . '" has the correct weight assignment (' . $values['test_weight'] . ').' ); @@ -135,17 +135,17 @@ public function testCandidateBlockList() { public function testMachineNameSuggestion() { $url = 'admin/structure/block/add/test_block_instantiation/stark'; $this->drupalGet($url); - $this->assertFieldByName('machine_name', 'displaymessage', 'Block form uses raw machine name suggestion when no instance already exists.'); + $this->assertFieldByName('id', 'displaymessage', 'Block form uses raw machine name suggestion when no instance already exists.'); $this->drupalPost($url, array(), 'Save block'); // Now, check to make sure the form starts by autoincrementing correctly. $this->drupalGet($url); - $this->assertFieldByName('machine_name', 'displaymessage_2', 'Block form appends _2 to plugin-suggested machine name when an instance already exists.'); + $this->assertFieldByName('id', 'displaymessage_2', 'Block form appends _2 to plugin-suggested machine name when an instance already exists.'); $this->drupalPost($url, array(), 'Save block'); // And verify that it continues working beyond just the first two. $this->drupalGet($url); - $this->assertFieldByName('machine_name', 'displaymessage_3', 'Block form appends _3 to plugin-suggested machine name when two instances already exist.'); + $this->assertFieldByName('id', 'displaymessage_3', 'Block form appends _3 to plugin-suggested machine name when two instances already exist.'); } } diff --git a/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php b/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php index 00fccc3..b3bf5b9 100644 --- a/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php @@ -36,16 +36,21 @@ function testNewDefaultThemeBlocks() { $default_theme = \Drupal::config('system.theme')->get('default'); // Add several block instances. - $this->adminUser = $this->drupalCreateUser(array('administer blocks')); - $this->drupalLogin($this->adminUser); + $this->drupalLogin($this->drupalCreateUser(array('administer blocks'))); // Add two instances of the user login block. - $this->drupalPlaceBlock('user_login_block'); - $this->drupalPlaceBlock('user_login_block'); + $this->drupalPlaceBlock('user_login_block', array( + 'id' => $default_theme . '_' . strtolower($this->randomName(8)), + )); + $this->drupalPlaceBlock('user_login_block', array( + 'id' => $default_theme . '_' . strtolower($this->randomName(8)), + )); // Add an instance of a different block. - $this->drupalPlaceBlock('system_powered_by_block'); - $this->drupalLogout($this->adminUser); + $this->drupalPlaceBlock('system_powered_by_block', array( + 'id' => $default_theme . '_' . strtolower($this->randomName(8)), + )); + $this->drupalLogout(); // Enable a different theme. $new_theme = 'bartik'; @@ -56,30 +61,18 @@ function testNewDefaultThemeBlocks() { ->save(); // Ensure that the new theme has all the blocks as the previous default. - // @todo Replace the string manipulation below once the configuration - // system provides a method for extracting an ID in a given namespace. - $default_prefix = "block.block.$default_theme"; - $new_prefix = "block.block.$new_theme"; - $default_block_names = config_get_storage_names_with_prefix($default_prefix); - $new_blocks = array_flip(config_get_storage_names_with_prefix($new_prefix)); + $default_block_names = $this->container->get('entity.query')->get('block') + ->condition('theme', $default_theme) + ->execute(); + $new_blocks = $this->container->get('entity.query')->get('block') + ->condition('theme', $new_theme) + ->execute(); $this->assertTrue(count($default_block_names) == count($new_blocks), 'The new default theme has the same number of blocks as the previous theme.'); foreach ($default_block_names as $default_block_name) { - // Make sure the configuration object name is in the expected format. - if (strpos($default_block_name, $default_prefix) === 0) { - // Remove the matching block from the list of blocks in the new theme. - // E.g., if the old theme has block.block.stark.admin, - // unset block.block.bartik.admin. - $id = substr($default_block_name, (strlen($default_prefix) + 1)); - unset($new_blocks[$new_prefix . '.' . $id]); - } - else { - $this->fail(format_string( - '%block is not an expected block instance name.', - array( - '%block' => $default_block_name, - ) - )); - } + // Remove the matching block from the list of blocks in the new theme. + // E.g., if the old theme has block.block.stark_admin, + // unset block.block.bartik_admin. + unset($new_blocks[str_replace($default_theme . '_', $new_theme . '_', $default_block_name)]); } $this->assertTrue(empty($new_blocks), 'The new theme has exactly the same blocks as the previous default theme.'); } 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 65a9ed9..66c974d 100644 --- a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php @@ -110,11 +110,11 @@ public function testViewsBlockForm() { $this->assertTrue(empty($elements), 'The label field is not found for Views blocks.'); // Test that that machine name field is hidden from display and has been // saved as expected from the default value. - $this->assertNoFieldById('edit-machine-name', 'stark.views_block__test_view_block_1', 'The machine name is hidden on the views block form.'); + $this->assertNoFieldById('edit-machine-name', 'views_block__test_view_block_1', 'The machine name is hidden on the views block form.'); // Save the block. $this->drupalPost(NULL, array(), t('Save block')); $storage = $this->container->get('entity.manager')->getStorageController('block'); - $block = $storage->load('stark.views_block__test_view_block_block_1'); + $block = $storage->load('views_block__test_view_block_block_1'); // This will only return a result if our new block has been created with the // expected machine name. $this->assertTrue(!empty($block), 'The expected block was loaded.'); @@ -122,7 +122,7 @@ public function testViewsBlockForm() { for ($i = 2; $i <= 3; $i++) { // Place the same block again and make sure we have a new ID. $this->drupalPost('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, array(), t('Save block')); - $block = $storage->load('stark.views_block__test_view_block_block_1_' . $i); + $block = $storage->load('views_block__test_view_block_block_1_' . $i); // This will only return a result if our new block has been created with the // expected machine name. $this->assertTrue(!empty($block), 'The expected block was loaded.'); @@ -135,14 +135,14 @@ public function testViewsBlockForm() { $this->drupalPost('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, $edit, t('Save block')); - $block = $storage->load('stark.views_block__test_view_block_block_1_4'); + $block = $storage->load('views_block__test_view_block_block_1_4'); $config = $block->getPlugin()->getConfiguration(); $this->assertEqual(10, $config['items_per_page'], "'Items per page' is properly saved."); $edit['settings[override][items_per_page]'] = 5; - $this->drupalPost('admin/structure/block/manage/stark.views_block__test_view_block_block_1_4', $edit, t('Save block')); + $this->drupalPost('admin/structure/block/manage/views_block__test_view_block_block_1_4', $edit, t('Save block')); - $block = $storage->load('stark.views_block__test_view_block_block_1_4'); + $block = $storage->load('views_block__test_view_block_block_1_4'); $config = $block->getPlugin()->getConfiguration(); $this->assertEqual(5, $config['items_per_page'], "'Items per page' is properly saved."); diff --git a/core/modules/block/tests/modules/block_test/config/block.block.stark.test_block.yml b/core/modules/block/tests/modules/block_test/config/block.block.test_block.yml similarity index 91% rename from core/modules/block/tests/modules/block_test/config/block.block.stark.test_block.yml rename to core/modules/block/tests/modules/block_test/config/block.block.test_block.yml index e8b5ade..4b68aca 100644 --- a/core/modules/block/tests/modules/block_test/config/block.block.stark.test_block.yml +++ b/core/modules/block/tests/modules/block_test/config/block.block.test_block.yml @@ -1,4 +1,5 @@ -id: stark.test_block +id: test_block +theme: stark weight: '' status: '1' langcode: en diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php index 6265660..81d0c42 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php @@ -43,7 +43,7 @@ function setUp() { */ function testLanguageBlock() { // Enable the language switching block. - $block = $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('machine_name' => 'test_language_block')); + $block = $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('id' => 'test_language_block')); // Add language. $edit = array( diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php index e039341..9964488 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php @@ -408,7 +408,7 @@ function testUrlLanguageFallback() { $this->drupalGet('admin/config/regional/language/detection'); // Enable the language switcher block. - $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('machine_name' => 'test_language_block')); + $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('id' => 'test_language_block')); // Access the front page without specifying any valid URL language prefix // and having as browser language preference a non-default language. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php index a63bcf8..70598ee 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php @@ -61,7 +61,7 @@ public function testRecentNodeBlock() { )); // Enable the recent content block with two items. - $block = $this->drupalPlaceBlock('node_recent_block', array('machine_name' => 'test_block', 'block_count' => 2)); + $block = $this->drupalPlaceBlock('node_recent_block', array('id' => 'test_block', 'block_count' => 2)); // Test that block is not visible without nodes. $this->drupalGet(''); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeSyndicateBlockTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeSyndicateBlockTest.php index 887b7ea..06a618f 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeSyndicateBlockTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeSyndicateBlockTest.php @@ -40,7 +40,7 @@ function setUp() { */ public function testSyndicateBlock() { // Place the "Syndicate" block and confirm that it is rendered. - $this->drupalPlaceBlock('node_syndicate_block', array('machine_name' => 'test_syndicate_block')); + $this->drupalPlaceBlock('node_syndicate_block', array('id' => 'test_syndicate_block')); $this->drupalGet(''); $this->assertFieldByXPath('//div[@id="block-test-syndicate-block"]/*', NULL, 'Syndicate block found.'); } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 1ebccca..8e45b48 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -358,7 +358,7 @@ protected function drupalCreateContentType(array $values = array()) { * @endcode * The following defaults are provided: * - label: Random string. - * - machine_name: Random string. + * - id: Random string. * - region: 'sidebar_first'. * - theme: The default theme. * - visibility: Empty array. @@ -373,20 +373,18 @@ protected function drupalPlaceBlock($plugin_id, array $settings = array()) { $settings += array( 'plugin' => $plugin_id, 'region' => 'sidebar_first', - 'machine_name' => strtolower($this->randomName(8)), + 'id' => strtolower($this->randomName(8)), 'theme' => \Drupal::config('system.theme')->get('default'), 'label' => $this->randomName(8), 'visibility' => array(), 'weight' => 0, ); - foreach (array('region', 'machine_name', 'theme', 'plugin', 'visibility', 'weight') as $key) { + foreach (array('region', 'id', 'theme', 'plugin', 'visibility', 'weight') as $key) { $values[$key] = $settings[$key]; // Remove extra values that do not belong in the settings array. unset($settings[$key]); } $values['settings'] = $settings; - // Build the ID out of the theme and machine_name. - $values['id'] = $values['theme'] . '.' . $values['machine_name']; $block = entity_create('block', $values); $block->save(); return $block; diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php index 7d1814e..a6a9bde 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php @@ -43,14 +43,12 @@ function setUp() { // This test puts menu links in the Tools menu and then tests for their // presence on the page, so we need to ensure that the Tools block will be - // displayed in the default theme and admin theme. - $settings = array( + // displayed in the admin theme. + $this->drupalPlaceBlock('system_menu_block:menu-tools', array( 'machine_name' => 'system_menu_tools', 'region' => 'content', - ); - $this->drupalPlaceBlock('system_menu_block:menu-tools', $settings); - $settings['theme'] = \Drupal::config('system.theme')->get('admin'); - $this->drupalPlaceBlock('system_menu_block:menu-tools', $settings); + 'theme' => \Drupal::config('system.theme')->get('admin'), + )); } /** @@ -357,7 +355,7 @@ function testBreadCrumbs() { // ('taxonomy/term/%') should never be translated and appear in any menu // other than the breadcrumb trail. $elements = $this->xpath('//div[@id=:menu]/descendant::a[@href=:href]', array( - ':menu' => 'block-system-menu-tools', + ':menu' => 'block-bartik-tools', ':href' => url($link['link_path']), )); $this->assertTrue(count($elements) == 1, "Link to {$link['link_path']} appears only once."); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php b/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php index 0e047ec..539f09e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php @@ -54,7 +54,7 @@ function testAccessDenied() { $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration')); // Enable the user login block. - $this->drupalPlaceBlock('user_login_block', array('machine_name' => 'login')); + $this->drupalPlaceBlock('user_login_block', array('id' => 'login')); // Log out and check that the user login block is shown on custom 403 pages. $this->drupalLogout(); @@ -82,7 +82,7 @@ function testAccessDenied() { $edit = array( 'region' => -1, ); - $this->drupalPost('admin/structure/block/manage/stark.login', $edit, t('Save block')); + $this->drupalPost('admin/structure/block/manage/login', $edit, t('Save block')); // Check that we can log in from the 403 page. $this->drupalLogout(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php index bde6f60..dbe590b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php @@ -43,7 +43,7 @@ public function testBlockUpgradeTitleLength() { // Confirm that the custom block has been created, and title matches input. $settings = array( 'settings[label]' => $this->randomName(255), - 'machine_name' => strtolower($this->randomName(8)), + 'id' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', ); $this->drupalPost('admin/structure/block/add/system_powered_by_block/' . \Drupal::config('system.theme')->get('default'), $settings, t('Save block')); @@ -52,7 +52,7 @@ public function testBlockUpgradeTitleLength() { // Try to add a block with a title over 255 characters. $settings = array( 'settings[label]' => $this->randomName(256), - 'machine_name' => strtolower($this->randomName(8)), + 'id' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', ); $this->drupalPost('admin/structure/block/add/system_powered_by_block/' . \Drupal::config('system.theme')->get('default'), $settings, t('Save block')); 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 02daf5a..f32a14c 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php @@ -9,7 +9,7 @@ use Drupal\block\Annotation\Block; use Drupal\Core\Annotation\Translation; -use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Config\Entity\Query\Query; use Drupal\Component\Utility\Xss; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -85,36 +85,6 @@ public function blockSubmit($form, &$form_state) { } /** - * Generates a views block instance ID. - * - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $manager - * The block storage controller. - * - * @return string - * The new block instance ID. - */ - public function generateBlockInstanceID(EntityStorageControllerInterface $manager) { - $original_id = 'views_block__' . $this->view->storage->id() . '_' . $this->view->current_display; - - // Get an array of block IDs without the theme prefix. - $block_ids = array_map(function ($block_id) { - $parts = explode('.', $block_id); - return end($parts); - }, array_keys($manager->loadMultiple())); - - // Iterate through potential IDs until we get a new one. E.g. - // 'views_block__MYVIEW_PAGE_1_2' - $count = 1; - $id = $original_id; - while (in_array($id, $block_ids)) { - $id = $original_id . '_' . ++$count; - } - - return $id; - } - - - /** * {@inheritdoc} */ public function getMachineNameSuggestion() { diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php index 05b7035..33e0b72 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php @@ -120,11 +120,11 @@ public function testExposedBlock() { $this->drupalGet('test_exposed_block'); // Test there is an exposed form in a block. - $xpath = $this->buildXPathQuery('//div[@id=:id]/div/form/@id', array(':id' => 'block-' . $block->get('machine_name'))); + $xpath = $this->buildXPathQuery('//div[@id=:id]/div/form/@id', array(':id' => drupal_html_id('block-' . $block->id()))); $this->assertFieldByXpath($xpath, $this->getExpectedExposedFormId($view), 'Expected form found in views block.'); // Test there is not an exposed form in the view page content area. - $xpath = $this->buildXPathQuery('//div[@class="view-content"]/form/@id', array(':id' => 'block-' . $block->get('machine_name'))); + $xpath = $this->buildXPathQuery('//div[@class="view-content"]/form/@id', array(':id' => drupal_html_id('block-' . $block->id()))); $this->assertNoFieldByXpath($xpath, $this->getExpectedExposedFormId($view), 'No exposed form found in views content region.'); // Test there is only one views exposed form on the page. diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php index a4c8567..bc980ee 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php @@ -268,9 +268,7 @@ protected function assertNoBlockAppears(Block $block) { * The result from the xpath query. */ protected function findBlockInstance(Block $block) { - $config_id = explode('.', $block->id()); - $machine_name = array_pop($config_id); - return $this->xpath('//div[@id = :id]', array(':id' => 'block-' . $machine_name)); + return $this->xpath('//div[@id = :id]', array(':id' => 'block-' . $block->id())); } /** diff --git a/core/profiles/minimal/config/block.block.stark.admin.yml b/core/profiles/minimal/config/block.block.stark_admin.yml similarity index 92% rename from core/profiles/minimal/config/block.block.stark.admin.yml rename to core/profiles/minimal/config/block.block.stark_admin.yml index d67096f..b167665 100644 --- a/core/profiles/minimal/config/block.block.stark.admin.yml +++ b/core/profiles/minimal/config/block.block.stark_admin.yml @@ -1,4 +1,5 @@ -id: stark.admin +id: stark_admin +theme: stark weight: '1' status: '1' langcode: en diff --git a/core/profiles/minimal/config/block.block.stark.login.yml b/core/profiles/minimal/config/block.block.stark_login.yml similarity index 91% rename from core/profiles/minimal/config/block.block.stark.login.yml rename to core/profiles/minimal/config/block.block.stark_login.yml index b15e395..a727ff5 100644 --- a/core/profiles/minimal/config/block.block.stark.login.yml +++ b/core/profiles/minimal/config/block.block.stark_login.yml @@ -1,4 +1,5 @@ -id: stark.login +id: stark_login +theme: stark weight: '0' status: '1' langcode: en diff --git a/core/profiles/minimal/config/block.block.stark.tools.yml b/core/profiles/minimal/config/block.block.stark_tools.yml similarity index 91% rename from core/profiles/minimal/config/block.block.stark.tools.yml rename to core/profiles/minimal/config/block.block.stark_tools.yml index 6901d44..9110cd2 100644 --- a/core/profiles/minimal/config/block.block.stark.tools.yml +++ b/core/profiles/minimal/config/block.block.stark_tools.yml @@ -1,4 +1,5 @@ -id: stark.tools +id: stark_tools +theme: stark weight: '0' status: '1' langcode: en diff --git a/core/profiles/standard/config/block.block.bartik.breadcrumbs.yml b/core/profiles/standard/config/block.block.bartik_breadcrumbs.yml similarity index 90% rename from core/profiles/standard/config/block.block.bartik.breadcrumbs.yml rename to core/profiles/standard/config/block.block.bartik_breadcrumbs.yml index db92b96..282865b 100644 --- a/core/profiles/standard/config/block.block.bartik.breadcrumbs.yml +++ b/core/profiles/standard/config/block.block.bartik_breadcrumbs.yml @@ -1,4 +1,5 @@ -id: bartik.breadcrumbs +id: bartik_breadcrumbs +theme: bartik weight: '-5' status: '0' langcode: en diff --git a/core/profiles/standard/config/block.block.bartik.content.yml b/core/profiles/standard/config/block.block.bartik_content.yml similarity index 91% rename from core/profiles/standard/config/block.block.bartik.content.yml rename to core/profiles/standard/config/block.block.bartik_content.yml index 24b161c..e288270 100644 --- a/core/profiles/standard/config/block.block.bartik.content.yml +++ b/core/profiles/standard/config/block.block.bartik_content.yml @@ -1,4 +1,5 @@ -id: bartik.content +id: bartik_content +theme: bartik weight: '0' status: '1' langcode: en diff --git a/core/profiles/standard/config/block.block.bartik.footer.yml b/core/profiles/standard/config/block.block.bartik_footer.yml similarity index 91% rename from core/profiles/standard/config/block.block.bartik.footer.yml rename to core/profiles/standard/config/block.block.bartik_footer.yml index 65c77f0..94bade5 100644 --- a/core/profiles/standard/config/block.block.bartik.footer.yml +++ b/core/profiles/standard/config/block.block.bartik_footer.yml @@ -1,4 +1,5 @@ -id: bartik.footer +id: bartik_footer +theme: bartik weight: '0' status: '1' langcode: en diff --git a/core/profiles/standard/config/block.block.bartik.help.yml b/core/profiles/standard/config/block.block.bartik_help.yml similarity index 92% rename from core/profiles/standard/config/block.block.bartik.help.yml rename to core/profiles/standard/config/block.block.bartik_help.yml index 11f7ec6..72fe3e4 100644 --- a/core/profiles/standard/config/block.block.bartik.help.yml +++ b/core/profiles/standard/config/block.block.bartik_help.yml @@ -1,4 +1,5 @@ -id: bartik.help +id: bartik_help +theme: bartik weight: '0' status: '1' langcode: en diff --git a/core/profiles/standard/config/block.block.bartik.login.yml b/core/profiles/standard/config/block.block.bartik_login.yml similarity index 91% rename from core/profiles/standard/config/block.block.bartik.login.yml rename to core/profiles/standard/config/block.block.bartik_login.yml index 69e7f9b..b9c22f3 100644 --- a/core/profiles/standard/config/block.block.bartik.login.yml +++ b/core/profiles/standard/config/block.block.bartik_login.yml @@ -1,4 +1,5 @@ -id: bartik.login +id: bartik_login +theme: bartik weight: '0' status: '1' langcode: en diff --git a/core/profiles/standard/config/block.block.bartik.powered.yml b/core/profiles/standard/config/block.block.bartik_powered.yml similarity index 91% rename from core/profiles/standard/config/block.block.bartik.powered.yml rename to core/profiles/standard/config/block.block.bartik_powered.yml index a8de940..55e368c 100644 --- a/core/profiles/standard/config/block.block.bartik.powered.yml +++ b/core/profiles/standard/config/block.block.bartik_powered.yml @@ -1,4 +1,5 @@ -id: bartik.powered +id: bartik_powered +theme: bartik weight: '10' status: '1' langcode: en diff --git a/core/profiles/standard/config/block.block.bartik.search.yml b/core/profiles/standard/config/block.block.bartik_search.yml similarity index 91% rename from core/profiles/standard/config/block.block.bartik.search.yml rename to core/profiles/standard/config/block.block.bartik_search.yml index 18f6a7c..80c6857 100644 --- a/core/profiles/standard/config/block.block.bartik.search.yml +++ b/core/profiles/standard/config/block.block.bartik_search.yml @@ -1,4 +1,5 @@ -id: bartik.search +id: bartik_search +theme: bartik weight: '-1' status: '1' langcode: en diff --git a/core/profiles/standard/config/block.block.bartik.tools.yml b/core/profiles/standard/config/block.block.bartik_tools.yml similarity index 92% rename from core/profiles/standard/config/block.block.bartik.tools.yml rename to core/profiles/standard/config/block.block.bartik_tools.yml index 633e299..74b322e 100644 --- a/core/profiles/standard/config/block.block.bartik.tools.yml +++ b/core/profiles/standard/config/block.block.bartik_tools.yml @@ -1,4 +1,5 @@ -id: bartik.tools +id: bartik_tools +theme: bartik weight: '0' status: '1' langcode: en diff --git a/core/profiles/standard/config/block.block.seven.breadcrumbs.yml b/core/profiles/standard/config/block.block.seven_breadcrumbs.yml similarity index 90% rename from core/profiles/standard/config/block.block.seven.breadcrumbs.yml rename to core/profiles/standard/config/block.block.seven_breadcrumbs.yml index 6ca8962..3164cb7 100644 --- a/core/profiles/standard/config/block.block.seven.breadcrumbs.yml +++ b/core/profiles/standard/config/block.block.seven_breadcrumbs.yml @@ -1,4 +1,5 @@ -id: seven.breadcrumbs +id: seven_breadcrumbs +theme: seven weight: '-2' status: '0' langcode: en diff --git a/core/profiles/standard/config/block.block.seven.content.yml b/core/profiles/standard/config/block.block.seven_content.yml similarity index 91% rename from core/profiles/standard/config/block.block.seven.content.yml rename to core/profiles/standard/config/block.block.seven_content.yml index 1725800..908501e 100644 --- a/core/profiles/standard/config/block.block.seven.content.yml +++ b/core/profiles/standard/config/block.block.seven_content.yml @@ -1,4 +1,5 @@ -id: seven.content +id: seven_content +theme: seven weight: '0' status: '1' langcode: en diff --git a/core/profiles/standard/config/block.block.seven.help.yml b/core/profiles/standard/config/block.block.seven_help.yml similarity index 92% rename from core/profiles/standard/config/block.block.seven.help.yml rename to core/profiles/standard/config/block.block.seven_help.yml index 132ee45..0c41a8b 100644 --- a/core/profiles/standard/config/block.block.seven.help.yml +++ b/core/profiles/standard/config/block.block.seven_help.yml @@ -1,4 +1,5 @@ -id: seven.help +id: seven_help +theme: seven weight: '0' status: '1' langcode: en diff --git a/core/profiles/standard/config/block.block.seven.login.yml b/core/profiles/standard/config/block.block.seven_login.yml similarity index 92% rename from core/profiles/standard/config/block.block.seven.login.yml rename to core/profiles/standard/config/block.block.seven_login.yml index 8ec1661..5d7b69f 100644 --- a/core/profiles/standard/config/block.block.seven.login.yml +++ b/core/profiles/standard/config/block.block.seven_login.yml @@ -1,4 +1,5 @@ -id: seven.login +id: seven_login +theme: seven weight: '10' status: '1' langcode: en diff --git a/core/profiles/standard/lib/Drupal/standard/Tests/StandardTest.php b/core/profiles/standard/lib/Drupal/standard/Tests/StandardTest.php index fc21631..a2c3a50 100644 --- a/core/profiles/standard/lib/Drupal/standard/Tests/StandardTest.php +++ b/core/profiles/standard/lib/Drupal/standard/Tests/StandardTest.php @@ -40,7 +40,7 @@ function testStandard() { $this->drupalGet('admin/structure/block/add/system_menu_block:menu-main/bartik'); $this->drupalPost(NULL, array( 'region' => 'sidebar_first', - 'machine_name' => 'main_navigation', + 'id' => 'main_navigation', ), t('Save block')); // Verify admin user can see the block. $this->drupalGet(''); @@ -51,7 +51,7 @@ function testStandard() { $this->drupalGet('admin/structure/block'); $elements = $this->xpath('//div[@role=:role and @id=:id]', array( ':role' => 'complementary', - ':id' => 'block-help', + ':id' => 'block-bartik-help', )); $this->assertEqual(count($elements), 1, 'Found complementary role on help block.'); @@ -59,7 +59,7 @@ function testStandard() { $this->drupalGet(''); $elements = $this->xpath('//div[@role=:role and @id=:id]', array( ':role' => 'complementary', - ':id' => 'block-powered', + ':id' => 'block-bartik-powered', )); $this->assertEqual(count($elements), 1, 'Found complementary role on powered by block.');