diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php new file mode 100644 index 0000000..ba2872b --- /dev/null +++ b/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php @@ -0,0 +1,74 @@ + 'Block hook operations', + 'description' => 'Implement hook entity operations alter.', + 'group' => 'Block', + ); + } + + function setUp() { + parent::setUp(); + + $permissions = array( + 'administer blocks', + ); + + // Create and log in user. + $admin_user = $this->drupalCreateUser($permissions); + $this->drupalLogin($admin_user); + } + + /** + * Tests the block listing for the translate operation. + * + * There are no blocks placed in the testing profile. Add one, then check + * for Translate operation. + */ + protected function doBlockListTest() { + // Add a test block, any block will do. + // Set the machine name so later the translate link can be build. + $block_machine_name = drupal_strtolower($this->randomName(16)); + $this->drupalPlaceBlock('system_powered_by_block', array('machine_name' => $block_machine_name)); + + // Get the Block listing. + $this->drupalGet('admin/structure/block'); + + $translate_link = 'admin/structure/block/manage/stark.' . $block_machine_name . '/translate'; + // Test if the link to translate the block is on the page. + $this->assertLinkByHref($translate_link); + } + + /* + * Tests block lists of config to see if translate link is added to operations. + */ + function testTranslateOperationInListUI() { + + // All lists from config_translation_config_translation_group_info(). + + $this->doBlockListTest(); + } + +} diff --git a/core/modules/block/tests/block_test_hook_operation/block_test_hook_operation.info.yml b/core/modules/block/tests/block_test_hook_operation/block_test_hook_operation.info.yml new file mode 100644 index 0000000..5bf37bd --- /dev/null +++ b/core/modules/block/tests/block_test_hook_operation/block_test_hook_operation.info.yml @@ -0,0 +1,9 @@ +name: 'Block test hook operation' +type: module +description: 'Implements a hook to test entity_hook_operations_alter() in blocks.' +package: Core +version: VERSION +hidden: TRUE +core: 8.x +dependencies: + - block diff --git a/core/modules/block/tests/block_test_hook_operation/block_test_hook_operation.module b/core/modules/block/tests/block_test_hook_operation/block_test_hook_operation.module new file mode 100644 index 0000000..a8e220d --- /dev/null +++ b/core/modules/block/tests/block_test_hook_operation/block_test_hook_operation.module @@ -0,0 +1,19 @@ +uri(); + $operations['translate'] = array( + 'title' => t('Translate'), + 'href' => $uri['path'] . '/translate', + 'options' => $uri['options'], + 'weight' => 50, + ); +}