diff --git a/core/modules/block_content/block_content.links.action.yml b/core/modules/block_content/block_content.links.action.yml index 4772a6f..b0900a6 100644 --- a/core/modules/block_content/block_content.links.action.yml +++ b/core/modules/block_content/block_content.links.action.yml @@ -8,6 +8,4 @@ block_content_add_action: route_name: block_content.add_page title: 'Add custom block' appears_on: - - block.admin_library - entity.block_content.collection - class: \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction diff --git a/core/modules/block_content/block_content.links.menu.yml b/core/modules/block_content/block_content.links.menu.yml new file mode 100644 index 0000000..26fb0a1 --- /dev/null +++ b/core/modules/block_content/block_content.links.menu.yml @@ -0,0 +1,10 @@ +entity.block_content.collection: + title: 'Custom blocks' + route_name: entity.block_content.collection + parent: system.admin_content + description: 'Create and manage custom blocks that can be placed in theme regions.' +entity.block_content_type.collection: + title: 'Block types' + route_name: entity.block_content_type.collection + parent: system.admin_structure + description: 'Manage form and display settings for custom blocks.' diff --git a/core/modules/block_content/block_content.links.task.yml b/core/modules/block_content/block_content.links.task.yml index 2b88171..7f9ce4d 100644 --- a/core/modules/block_content/block_content.links.task.yml +++ b/core/modules/block_content/block_content.links.task.yml @@ -1,16 +1,7 @@ entity.block_content.collection: - title: 'Custom block library' + title: 'Custom blocks' route_name: entity.block_content.collection - base_route: block.admin_display -block_content.list_sub: - title: Blocks - route_name: entity.block_content.collection - parent_id: entity.block_content.collection -entity.block_content_type.collection: - title: Types - route_name: entity.block_content_type.collection - parent_id: entity.block_content.collection - weight: 1 + base_route: system.admin_content entity.block_content.canonical: title: Edit diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module index 49de8ac..459b122 100644 --- a/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module @@ -18,24 +18,23 @@ function block_content_help($route_name, RouteMatchInterface $route_match) { $field_ui = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#'; $output = ''; $output .= '

' . t('About') . '

'; - $output .= '

' . t('The Custom Block module allows you to create custom block types and content-containing blocks, and provides a Custom block library listing all of them. Custom block types have fields; see the Field module help for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the Block module help page for details. For more information, see the online documentation for the Custom Block module.', array(':block-library' => \Drupal::url('entity.block_content.collection'), ':block-content' => \Drupal::url('entity.block_content.collection'), ':field-help' => \Drupal::url('help.page', array('name' => 'field')), ':blocks' => \Drupal::url('help.page', array('name' => 'block')), ':online-help' => 'https://www.drupal.org/documentation/modules/block_content')) . '

'; + $output .= '

' . t('The Custom Block module allows you to create custom block types and block content based on those types. Once created, these custom blocks can be placed in regions just like blocks provided by other modules. For more information, see the online documentation for the Custom Block module.', array(':block-types' => \Drupal::url('entity.block_content_type.collection'), ':block-list' => \Drupal::url('entity.block_content.collection'), ':online-help' => 'https://www.drupal.org/documentation/modules/block_content')) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Creating and managing custom block types') . '
'; - $output .= '
' . t('Users with the Administer blocks permission can create and edit custom block types with fields and display settings, from the Custom block types page in the Custom block library. For more information about managing fields and display settings, see the Field UI module help.', array(':types' => \Drupal::url('entity.block_content_type.collection'), ':field-ui' => $field_ui)) . '
'; + $output .= '
' . t('Users with the Administer blocks permission can create and edit custom block types, each with their own set of fields and display settings, from the Block types page. For more information about managing fields and display settings, see Field module help and Field UI module help.', array(':types' => \Drupal::url('entity.block_content_type.collection'), ':field-help' => \Drupal::url('help.page', ['name' => 'field']), ':field-ui' => $field_ui)) . '
'; $output .= '
' . t('Creating custom blocks') . '
'; - $output .= '
' . t('Users with the Administer blocks permission can create, edit, and delete custom blocks of each custom block type you have defined, from the Custom block library page. Custom blocks are shown in the Place blocks list on the Block layout page; see the Block module help for more information about placing blocks.', array(':blocks' => \Drupal::url('block.admin_display'), ':block-library' => \Drupal::url('entity.block_content.collection'), ':block_help' => \Drupal::url('help.page', array('name' => 'block')))) . '
'; + $output .= '
' . t('Users with the Administer blocks permission can create, edit, and delete custom blocks from the Block content page. These custom blocks can then be added to a region of your site theme on the Block layout page. See the Block module help for more information about placing blocks.', array(':blocks' => \Drupal::url('block.admin_display'), ':block-list' => \Drupal::url('entity.block_content.collection'), ':block-help' => \Drupal::url('help.page', array('name' => 'block')))) . '
'; $output .= '
'; return $output; case 'entity.block_content.collection': - $output = '

' . t('Blocks in the block library belong to block types, each with its own fields and display settings. After creating a block, place it in a region from the Block layout page.', array(':types' => \Drupal::url('entity.block_content_type.collection'), ':blocks' => \Drupal::url('block.admin_display'))) . '

'; + $output = '

' . t('Every custom block is based on a reusable block type. Once created, each block can then be placed in any region from the Block layout page.', array(':block-types' => \Drupal::url('entity.block_content_type.collection'), ':block-layout' => \Drupal::url('block.admin_display'))) . '

'; return $output; case 'entity.block_content_type.collection': - $output = '

' . t('Each block type has its own fields and display settings. Create blocks of each type on the Block library page.', array(':block-library' => \Drupal::url('entity.block_content.collection'))) . '

'; + $output = '

' . t('After creating a block type, you can create a block based on it from the Block content page. Each block type has its own fields and display settings.', array(':block-list' => \Drupal::url('entity.block_content.collection'))) . '

'; return $output; - } } diff --git a/core/modules/block_content/block_content.routing.yml b/core/modules/block_content/block_content.routing.yml index 8e4f649..6752a2e 100644 --- a/core/modules/block_content/block_content.routing.yml +++ b/core/modules/block_content/block_content.routing.yml @@ -1,8 +1,8 @@ entity.block_content_type.collection: - path: '/admin/structure/block/block-content/types' + path: '/admin/structure/block-content' defaults: _entity_list: 'block_content_type' - _title: 'Custom block library' + _title: 'Block types' requirements: _permission: 'administer blocks' @@ -27,10 +27,10 @@ block_content.add_form: _permission: 'administer blocks' entity.block_content_type.delete_form: - path: '/admin/structure/block/block-content/manage/{block_content_type}/delete' + path: '/admin/structure/block-content/manage/{block_content_type}/delete' defaults: _entity_form: 'block_content_type.delete' - _title: 'Delete' + _title: 'Delete block type' requirements: _entity_access: 'block_content_type.delete' options: @@ -39,6 +39,7 @@ entity.block_content_type.delete_form: entity.block_content.canonical: path: '/block/{block_content}' defaults: + _title_callback: '\Drupal\block_content\Controller\BlockContentController::blockContentTitle' _entity_form: 'block_content.edit' options: _admin_route: TRUE @@ -65,24 +66,25 @@ entity.block_content.delete_form: _entity_access: 'block_content.delete' block_content.type_add: - path: '/admin/structure/block/block-content/types/add' + path: '/admin/structure/block-content/add' defaults: _entity_form: 'block_content_type.add' - _title: 'Add' + _title: 'Add block type' requirements: _permission: 'administer blocks' entity.block_content_type.edit_form: - path: '/admin/structure/block/block-content/manage/{block_content_type}' + path: '/admin/structure/block-content/manage/{block_content_type}' defaults: _entity_form: 'block_content_type.edit' + _title: 'Edit block type' requirements: _entity_access: 'block_content_type.update' entity.block_content.collection: - path: '/admin/structure/block/block-content' + path: '/admin/content/block-content' defaults: - _title: 'Custom block library' + _title: 'Custom blocks' _entity_list: 'block_content' requirements: _permission: 'administer blocks' diff --git a/core/modules/block_content/config/optional/views.view.block_content.yml b/core/modules/block_content/config/optional/views.view.block_content.yml index 27ecb0c..58de979 100644 --- a/core/modules/block_content/config/optional/views.view.block_content.yml +++ b/core/modules/block_content/config/optional/views.view.block_content.yml @@ -5,7 +5,7 @@ dependencies: - block_content - user id: block_content -label: 'Custom block library' +label: 'Custom blocks' module: views description: 'Find and manage custom blocks.' tag: default @@ -163,7 +163,7 @@ display: click_sort_column: value type: string settings: - link_to_entity: true + link_to_entity: false group_column: value group_columns: { } group_rows: true @@ -432,7 +432,7 @@ display: entity_field: type plugin_id: bundle sorts: { } - title: 'Custom block library' + title: 'Custom blocks' header: { } footer: { } empty: @@ -476,12 +476,12 @@ display: position: 1 display_options: display_extenders: { } - path: admin/structure/block/block-content + path: admin/content/block-content menu: type: tab - title: 'Custom block library' + title: 'Custom blocks' description: '' - parent: block.admin_display + parent: system.admin_content weight: 0 context: '0' menu_name: admin diff --git a/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php index 088c4d7..d6c70d2 100644 --- a/core/modules/block_content/src/BlockContentForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -182,11 +182,11 @@ public function save(array $form, FormStateInterface $form_state) { $context = array('@type' => $block->bundle(), '%info' => $block->label()); $logger = $this->logger('block_content'); $block_type = $this->blockContentTypeStorage->load($block->bundle()); - $t_args = array('@type' => $block_type->label(), '%info' => $block->label()); + $t_args = array('@type' => $block_type->label(), '%info' => $block->label(), '@layout-url' => \Drupal::url('block.admin_display')); if ($insert) { $logger->notice('@type: added %info.', $context); - drupal_set_message($this->t('@type %info has been created.', $t_args)); + drupal_set_message($this->t('@type %info has been created. Visit the Block layout page to add it to a region.', $t_args)); } else { $logger->notice('@type: updated %info.', $context); @@ -194,23 +194,7 @@ public function save(array $form, FormStateInterface $form_state) { } if ($block->id()) { - $form_state->setValue('id', $block->id()); - $form_state->set('id', $block->id()); - if ($insert) { - if (!$theme = $block->getTheme()) { - $theme = $this->config('system.theme')->get('default'); - } - $form_state->setRedirect( - 'block.admin_add', - array( - 'plugin_id' => 'block_content:' . $block->uuid(), - 'theme' => $theme, - ) - ); - } - else { - $form_state->setRedirectUrl($block->urlInfo('collection')); - } + $form_state->setRedirectUrl($block->urlInfo('collection')); } else { // In the unlikely case something went wrong on save, the block will be diff --git a/core/modules/block_content/src/BlockContentViewsData.php b/core/modules/block_content/src/BlockContentViewsData.php index abb2cb2..60105e0 100644 --- a/core/modules/block_content/src/BlockContentViewsData.php +++ b/core/modules/block_content/src/BlockContentViewsData.php @@ -29,7 +29,7 @@ public function getViewsData() { $data['block_content_field_data']['type']['field']['id'] = 'field'; $data['block_content']['block_content_listing_empty'] = array( - 'title' => t('Empty block library behavior'), + 'title' => t('Empty custom blocks page behavior'), 'help' => t('Provides a link to add a new block.'), 'area' => array( 'id' => 'block_content_listing_empty', diff --git a/core/modules/block_content/src/Controller/BlockContentController.php b/core/modules/block_content/src/Controller/BlockContentController.php index 4d65362..d394395 100644 --- a/core/modules/block_content/src/Controller/BlockContentController.php +++ b/core/modules/block_content/src/Controller/BlockContentController.php @@ -7,10 +7,11 @@ namespace Drupal\block_content\Controller; +use Drupal\block_content\BlockContentInterface; +use Drupal\block_content\BlockContentTypeInterface; use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\block_content\BlockContentTypeInterface; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -120,6 +121,19 @@ public function addForm(BlockContentTypeInterface $block_content_type, Request $ } /** + * A title callback for block content entities. + * + * @param \Drupal\block_content\BlockContentInterface $block_content + * The current custom block. + * + * @return string + * The title of the custom block. + */ + public function blockContentTitle(BlockContentInterface $block_content) { + return $this->entityManager()->getTranslationFromContext($block_content)->label(); + } + + /** * Provides the page title for this controller. * * @param \Drupal\block_content\BlockContentTypeInterface $block_content_type diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 7f572bd..f45ccee 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -43,7 +43,7 @@ * "canonical" = "/block/{block_content}", * "delete-form" = "/block/{block_content}/delete", * "edit-form" = "/block/{block_content}", - * "collection" = "/admin/structure/block/block-content", + * "collection" = "/admin/structure/block-content", * }, * translatable = TRUE, * entity_keys = { diff --git a/core/modules/block_content/src/Entity/BlockContentType.php b/core/modules/block_content/src/Entity/BlockContentType.php index 8494814..f04511f 100644 --- a/core/modules/block_content/src/Entity/BlockContentType.php +++ b/core/modules/block_content/src/Entity/BlockContentType.php @@ -35,9 +35,9 @@ * "label" = "label" * }, * links = { - * "delete-form" = "/admin/structure/block/block-content/manage/{block_content_type}/delete", - * "edit-form" = "/admin/structure/block/block-content/manage/{block_content_type}", - * "collection" = "/admin/structure/block/block-content/types", + * "delete-form" = "/admin/structure/block-content/manage/{block_content_type}/delete", + * "edit-form" = "/admin/structure/block-content/manage/{block_content_type}", + * "collection" = "/admin/structure/block-content/types", * }, * config_export = { * "id", diff --git a/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php b/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php deleted file mode 100644 index 62e0c3c..0000000 --- a/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php +++ /dev/null @@ -1,36 +0,0 @@ -getParameter('theme')) { - $options['query']['theme'] = $theme; - } - // Adds a destination on custom block listing. - if ($route_match->getRouteName() == 'entity.block_content.collection') { - $options['query']['destination'] = $this->url(''); - } - return $options; - } - -} diff --git a/core/modules/block_content/src/Tests/BlockContentCreationTest.php b/core/modules/block_content/src/Tests/BlockContentCreationTest.php index fdd1124..8ddd852 100644 --- a/core/modules/block_content/src/Tests/BlockContentCreationTest.php +++ b/core/modules/block_content/src/Tests/BlockContentCreationTest.php @@ -111,14 +111,17 @@ public function testBlockContentCreationMultipleViewModes() { '%name' => $edit['info[0][value]'] )), 'Basic block created.'); + $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]); + $block = reset($blocks); + $this->drupalGet('admin/structure/block/add/block_content:' . $block->uuid() . '/classy'); + // Save our block permanently $this->drupalPostForm(NULL, NULL, t('Save block')); // Set test_view_mode as a custom display to be available on the list. - $this->drupalGet('admin/structure/block/block-content'); - $this->drupalGet('admin/structure/block/block-content/types'); + $this->drupalGet('admin/structure/block-content'); $this->clickLink(t('Manage display')); - $this->drupalGet('admin/structure/block/block-content/manage/basic/display'); + $this->drupalGet('admin/structure/block-content/manage/basic/display'); $custom_view_mode = array( 'display_modes_custom[test_view_mode]' => 1, ); diff --git a/core/modules/block_content/src/Tests/BlockContentListTest.php b/core/modules/block_content/src/Tests/BlockContentListTest.php index 8b77d1a..11f72e1 100644 --- a/core/modules/block_content/src/Tests/BlockContentListTest.php +++ b/core/modules/block_content/src/Tests/BlockContentListTest.php @@ -30,10 +30,10 @@ class BlockContentListTest extends BlockContentTestBase { */ public function testListing() { $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'translate configuration'))); - $this->drupalGet('admin/structure/block/block-content'); + $this->drupalGet('admin/content/block-content'); // Test for the page title. - $this->assertTitle(t('Custom block library') . ' | Drupal'); + $this->assertTitle(t('Custom blocks') . ' | Drupal'); // Test for the table. $element = $this->xpath('//div[@class="layout-content"]//table'); diff --git a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php b/core/modules/block_content/src/Tests/BlockContentListViewsTest.php index 34a5f22..b2579c8 100644 --- a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php +++ b/core/modules/block_content/src/Tests/BlockContentListViewsTest.php @@ -28,10 +28,10 @@ class BlockContentListViewsTest extends BlockContentTestBase { */ public function testListing() { $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'translate configuration'))); - $this->drupalGet('admin/structure/block/block-content'); + $this->drupalGet('admin/content/block-content'); // Test for the page title. - $this->assertTitle(t('Custom block library') . ' | Drupal'); + $this->assertTitle(t('Custom blocks') . ' | Drupal'); // Test for the table. $element = $this->xpath('//div[@class="layout-content"]//table'); @@ -66,7 +66,8 @@ public function testListing() { // Confirm that once the user returns to the listing, the text of the label // (versus elsewhere on the page). - $this->assertFieldByXpath('//td/a', $label, 'Label found for added block.'); + $elements = $this->xpath('//td[contains(@class,"views-field-info")]'); + $this->assertEqual(trim((string) $elements[0]), $label, 'Label found for added block.'); // Check the number of table row cells. $elements = $this->xpath('//div[@class="layout-content"]//table/tbody/tr/td'); @@ -74,7 +75,7 @@ public function testListing() { // Check the contents of each row cell. The first cell contains the label, // the second contains the machine name, and the third contains the // operations list. - $this->assertIdentical((string) $elements[0]->xpath('a')[0], $label); + $this->assertIdentical(trim((string) $elements[0]), $label); // Edit the entity using the operations link. $blocks = $this->container @@ -96,7 +97,8 @@ public function testListing() { // Confirm that once the user returns to the listing, the text of the label // (versus elsewhere on the page). - $this->assertFieldByXpath('//td/a', $new_label, 'Label found for updated custom block.'); + $elements = $this->xpath('//td[contains(@class,"views-field-info")]'); + $this->assertEqual(trim((string) $elements[0]), $new_label, 'Label found for updated custom block.'); // Delete the added entity using the operations link. $this->assertLinkByHref('block/' . $block->id() . '/delete'); diff --git a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php index 964f0f9..94ed535 100644 --- a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php +++ b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php @@ -149,7 +149,7 @@ protected function doTestBasicTranslation() { } // Check that the translate operation link is shown. - $this->drupalGet('admin/structure/block/block-content'); + $this->drupalGet('admin/content/block-content'); $this->assertLinkByHref('block/' . $entity->id() . '/translations'); } diff --git a/core/modules/block_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php index cf37f51..3317996 100644 --- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -60,7 +60,7 @@ public function testBlockContentTypeCreation() { 'id' => 'foo', 'label' => 'title for foo', ); - $this->drupalPostForm(NULL, $edit, t('Save')); + $this->drupalPostForm('admin/structure/block-content/add', $edit, t('Save')); $block_type = BlockContentType::load('foo'); $this->assertTrue($block_type, 'The new block type has been created.'); @@ -110,7 +110,7 @@ public function testBlockContentTypeEditing() { $edit = array( 'label' => 'Bar', ); - $this->drupalGet('admin/structure/block/block-content/manage/basic'); + $this->drupalGet('admin/structure/block-content/manage/basic'); $this->assertTitle(format_string('Edit @type custom block type | Drupal', ['@type' => 'basic'])); $this->drupalPostForm(NULL, $edit, t('Save')); \Drupal::entityManager()->clearCachedFieldDefinitions(); @@ -121,9 +121,9 @@ public function testBlockContentTypeEditing() { $this->assertUrl(\Drupal::url('block_content.add_form', ['block_content_type' => 'basic'], ['absolute' => TRUE]), [], 'Original machine name was used in URL.'); // Remove the body field. - $this->drupalPostForm('admin/structure/block/block-content/manage/basic/fields/block_content.basic.body/delete', array(), t('Delete')); + $this->drupalPostForm('admin/structure/block-content/manage/basic/fields/block_content.basic.body/delete', array(), t('Delete')); // Resave the settings for this type. - $this->drupalPostForm('admin/structure/block/block-content/manage/basic', array(), t('Save')); + $this->drupalPostForm('admin/structure/block-content/manage/basic', array(), t('Save')); // Check that the body field doesn't exist. $this->drupalGet('block/add/basic'); $this->assertNoRaw('Body', 'Body field was not found.'); @@ -144,7 +144,7 @@ public function testBlockContentTypeDeletion() { // Add a new block of this type. $block = $this->createBlockContent(FALSE, 'foo'); // Attempt to delete the block type, which should not be allowed. - $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete'); + $this->drupalGet('admin/structure/block-content/manage/' . $type->id() . '/delete'); $this->assertRaw( t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', array('%label' => $type->label())), 'The block type will not be deleted until all blocks of that type are removed.' @@ -154,7 +154,7 @@ public function testBlockContentTypeDeletion() { // Delete the block. $block->delete(); // Attempt to delete the block type, which should now be allowed. - $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete'); + $this->drupalGet('admin/structure/block-content/manage/' . $type->id() . '/delete'); $this->assertRaw( t('Are you sure you want to delete the custom block type %type?', array('%type' => $type->id())), 'The block type is available for deletion.' @@ -162,80 +162,4 @@ public function testBlockContentTypeDeletion() { $this->assertText(t('This action cannot be undone.'), 'The custom block type deletion confirmation form is available.'); } - /** - * Tests that redirects work as expected when multiple block types exist. - */ - public function testsBlockContentAddTypes() { - // Now create an initial block-type. - $this->createBlockContentType('basic', TRUE); - - $this->drupalLogin($this->adminUser); - // Create two block types programmatically. - $type = $this->createBlockContentType('foo'); - $type = $this->createBlockContentType('bar'); - - // Get the custom block storage. - $storage = $this->container - ->get('entity.manager') - ->getStorage('block_content'); - - // Install all themes. - \Drupal::service('theme_handler')->install(array('bartik', 'seven')); - $themes = array('bartik', 'seven', 'classy'); - $theme_settings = $this->config('system.theme'); - foreach ($themes as $default_theme) { - // Change the default theme. - $theme_settings->set('default', $default_theme)->save(); - \Drupal::service('router.builder')->rebuild(); - - // For each installed theme, go to its block page and test the redirects. - $themes = array('bartik', 'classy', 'seven'); - foreach ($themes as $theme) { - // Test that adding a block from the 'place blocks' form sends you to the - // block configure form. - $path = $theme == $default_theme ? 'admin/structure/block' : "admin/structure/block/list/$theme"; - $this->drupalGet($path); - $this->clickLinkPartialName('Place block'); - $this->clickLink(t('Add custom block')); - // The seven theme has markup inside the link, we cannot use clickLink(). - if ($default_theme == 'seven') { - $options = $theme != $default_theme ? array('query' => array('theme' => $theme)) : array(); - $this->assertLinkByHref(\Drupal::url('block_content.add_form', array('block_content_type' => 'foo'), $options)); - $this->drupalGet('block/add/foo', $options); - } - else { - $this->clickLink('foo'); - } - // Create a new block. - $edit = array('info[0][value]' => $this->randomMachineName(8)); - $this->drupalPostForm(NULL, $edit, t('Save')); - $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]'])); - if (!empty($blocks)) { - $block = reset($blocks); - $this->assertUrl(\Drupal::url('block.admin_add', array('plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme), array('absolute' => TRUE))); - $this->drupalPostForm(NULL, array(), t('Save block')); - $this->assertUrl(\Drupal::url('block.admin_display_theme', array('theme' => $theme), array('absolute' => TRUE, 'query' => array('block-placement' => Html::getClass($edit['info[0][value]']))))); - } - else { - $this->fail('Could not load created block.'); - } - } - } - - // Test that adding a block from the 'custom blocks list' doesn't send you - // to the block configure form. - $this->drupalGet('admin/structure/block/block-content'); - $this->clickLink(t('Add custom block')); - $this->clickLink('foo'); - $edit = array('info[0][value]' => $this->randomMachineName(8)); - $this->drupalPostForm(NULL, $edit, t('Save')); - $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]'])); - if (!empty($blocks)) { - $this->assertUrl(\Drupal::url('entity.block_content.collection', array(), array('absolute' => TRUE))); - } - else { - $this->fail('Could not load created block.'); - } - } - } diff --git a/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php b/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php deleted file mode 100644 index 9c01796..0000000 --- a/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php +++ /dev/null @@ -1,85 +0,0 @@ -directoryList = array( - 'block' => 'core/modules/block', - 'block_content' => 'core/modules/block_content', - ); - parent::setUp(); - - $config_factory = $this->getConfigFactoryStub(array('system.theme' => array( - 'default' => 'test_c', - ))); - - $themes = array(); - $themes['test_a'] = (object) array( - 'status' => 0, - ); - $themes['test_b'] = (object) array( - 'status' => 1, - 'info' => array( - 'name' => 'test_b', - ), - ); - $themes['test_c'] = (object) array( - 'status' => 1, - 'info' => array( - 'name' => 'test_c', - ), - ); - $theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface'); - $theme_handler->expects($this->any()) - ->method('listInfo') - ->will($this->returnValue($themes)); - - $container = new ContainerBuilder(); - $container->set('config.factory', $config_factory); - $container->set('theme_handler', $theme_handler); - \Drupal::setContainer($container); - } - - /** - * Checks block_content listing local tasks. - * - * @dataProvider getBlockContentListingRoutes - */ - public function testBlockContentListLocalTasks($route) { - $this->assertLocalTasks($route, array( - 0 => array( - 'block.admin_display', - 'entity.block_content.collection', - ), - 1 => array( - 'block_content.list_sub', - 'entity.block_content_type.collection', - ), - )); - } - - /** - * Provides a list of routes to test. - */ - public function getBlockContentListingRoutes() { - return array( - array('entity.block_content.collection', 'entity.block_content_type.collection'), - ); - } - -} diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php index fceb41d..92a9a5c 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php @@ -193,9 +193,9 @@ public function doCustomContentTypeListTest() { $block_content_type->save(); // Get the custom block type listing. - $this->drupalGet('admin/structure/block/block-content/types'); + $this->drupalGet('admin/structure/block-content'); - $translate_link = 'admin/structure/block/block-content/manage/' . $block_content_type->id() . '/translate'; + $translate_link = 'admin/structure/block-content/manage/' . $block_content_type->id() . '/translate'; // Test if the link to translate the custom block type is on the page. $this->assertLinkByHref($translate_link); @@ -414,7 +414,7 @@ public function doFieldListTest() { 'field' => 'node.' . $content_type->id() . '.body', ), array( - 'list' => 'admin/structure/block/block-content/manage/basic/fields', + 'list' => 'admin/structure/block-content/manage/basic/fields', 'field' => 'block_content.basic.body', ), );