From d1c36266f35ae457e6ddfa14bc7486c3982e2914 Mon Sep 17 00:00:00 2001 From: Marco Villegas Date: Sat, 8 Jun 2013 11:03:22 -0500 Subject: [PATCH] Some final changes. - region, visibility and pages keys from D7 hook_block_info() does not have an equivalent on D8 because blocks does not know about the context it will be used in. - Some minor varible names changes to improve readability. --- .../Plugin/Block/ExampleEmptyBlock.php | 5 ---- .../block_example/Tests/BlockExampleTest.php | 31 ++++++++++---------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/block_example/lib/Drupal/block_example/Plugin/Block/ExampleEmptyBlock.php b/block_example/lib/Drupal/block_example/Plugin/Block/ExampleEmptyBlock.php index 847441e..36fcdd9 100644 --- a/block_example/lib/Drupal/block_example/Plugin/Block/ExampleEmptyBlock.php +++ b/block_example/lib/Drupal/block_example/Plugin/Block/ExampleEmptyBlock.php @@ -3,11 +3,6 @@ /** * @file * Contains \Drupal\block_example\Plugin\Block\ExampleEmptyBlock. - * - * @todo Did not find how to upgrade ex-block-info attributes: - * - 'region' => 'sidebar_first', // Not usually provided. - * - 'visibility' => BLOCK_VISIBILITY_LISTED, // Not usually provided. - * - 'pages' => 'node/*', // Not usually provided here. */ namespace Drupal\block_example\Plugin\Block; diff --git a/block_example/lib/Drupal/block_example/Tests/BlockExampleTest.php b/block_example/lib/Drupal/block_example/Tests/BlockExampleTest.php index e67a470..25d533b 100644 --- a/block_example/lib/Drupal/block_example/Tests/BlockExampleTest.php +++ b/block_example/lib/Drupal/block_example/Tests/BlockExampleTest.php @@ -45,40 +45,40 @@ class BlockExampleTest extends WebTestBase { function testBlockExampleBasic() { // Login the admin user. $this->drupalLogin($this->web_user); - $theme = config('system.theme')->get('default'); + $theme_name = config('system.theme')->get('default'); // Find the blocks in the settings page. - $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . $theme . '/add'); + $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . $theme_name . '/add'); $this->assertRaw(t('Title of first block (example_configurable_text)'), 'Block configurable-string found.'); $this->assertRaw(t('Example: empty block'), 'Block empty-block found.'); // Add blocks // Create a new block and make sure it gets uppercased. - $post = array( + $edit = array( 'settings[label]' => t('Title of first block (example_configurable_text)'), 'machine_name' => 'block_example_example_configurable_text', 'region' => 'sidebar_first', ); - $this->drupalPost('admin/structure/block/add/example_configurable_text/'.$theme, $post, t('Save block')); + $this->drupalPost('admin/structure/block/add/example_configurable_text/' . $theme_name , $edit, t('Save block')); $this->assertText(t('The block configuration has been saved.')); - $this->assertText($post['settings[label]']); + $this->assertText($edit['settings[label]']); $this->drupalGet('admin/structure/block'); - $this->assertLinkByHref(url('admin/structure/block/manage/'.$theme.'.block_example_example_configurable_text/configure')); + $this->assertLinkByHref(url('admin/structure/block/manage/' . $theme_name . '.block_example_example_configurable_text/configure')); - $post = array( - 'settings[label]' => t('configurable block to be uppercased'), + $edit = array( + 'settings[label]' => t('Configurable block to be uppercased'), 'machine_name' => 'uppercased_block', 'region' => 'sidebar_first', ); - $this->drupalPost('admin/structure/block/add/example_uppercase/'.$theme, $post, t('Save block')); + $this->drupalPost('admin/structure/block/add/example_uppercase/' . $theme_name, $edit, t('Save block')); - $post = array( + $edit = array( 'settings[label]' => t('Example: empty block'), 'machine_name' => 'block_example_example_empty', 'region' => 'sidebar_first', ); - $this->drupalPost('admin/structure/block/add/example_empty/'.$theme, $post, t('Save block')); + $this->drupalPost('admin/structure/block/add/example_empty/' . $theme_name, $edit, t('Save block')); // Verify that blocks are not shown $this->drupalGet('/'); @@ -90,13 +90,14 @@ class BlockExampleTest extends WebTestBase { $this->assertRaw(t('Title of first block (example_configurable_text)'), 'Block configurable text found.'); // Change content of configurable text block - $string = $this->randomName(); - - $this->drupalPost('admin/structure/block/manage/'.$theme.'.block_example_example_configurable_text/configure%3Fdestination%3Dnode', array('settings[block_example_string_text]' => $string), t('Save block')); + $edit = array( + 'settings[block_example_string_text]' => $this->randomName(), + ); + $this->drupalPost('admin/structure/block/manage/' . $theme_name . '.block_example_example_configurable_text/configure', $edit, t('Save block')); // Verify that new content is shown $this->drupalGet('/'); - $this->assertRaw($string, 'Content of configurable text block successfully verified.'); + $this->assertRaw($edit['settings[block_example_string_text]'], 'Content of configurable text block successfully verified.'); } } -- 1.7.10.4