commit dce72f4d6b631aa4a74be2ec1195f9961d33af7a Author: xjm Date: Sat Jan 5 15:21:09 2013 -0600 13 diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHiddenRegionTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHiddenRegionTest.php index 06c7bf0..c16439c 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockHiddenRegionTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockHiddenRegionTest.php @@ -46,7 +46,7 @@ function setUp() { ); $this->drupalLogin($this->adminUser); - $this->DrupalCreateBlockInstance('search_form_block'); + $this->drupalPlaceBlock('search_form_block'); } /** diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php index 97534fe..caf27e6 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php @@ -180,7 +180,7 @@ function addCustomMenu() { $this->assertText($title); // Enable the block. - $this->drupalPlaceBlock($menu_name); + $this->drupalPlaceBlock('menu_menu_block:' . $menu_name); return menu_load($menu_name); } diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDTestBase.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDTestBase.php index acdc7cf..3110d88 100644 --- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDTestBase.php +++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDTestBase.php @@ -24,16 +24,10 @@ function setUp() { parent::setUp(); + // Enable user login block. $this->admin_user = $this->drupalCreateUser(array('administer blocks')); $this->drupalLogin($this->admin_user); - - // Enable user login block. - $edit = array( - 'machine_name' => 'user_login', - 'region' => 'sidebar_first', - ); - $this->drupalPost('admin/structure/block/manage/user_login_block/stark', $edit, t('Save block')); - + $this->drupalPlaceBlock('user_login_block'); $this->drupalLogout(); // Use a different front page than login page for testing OpenID login from diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php index 49fa169..6a86d21 100644 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php +++ b/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php @@ -46,18 +46,8 @@ function setUp() { * Tests creating, viewing, voting on recent poll block. */ function testRecentBlock() { - $block_id = 'poll_recent_block'; - $default_theme = variable_get('theme_default', 'stark'); - - $block = array( - 'title' => $this->randomName(8), - 'machine_name' => $this->randomName(8), - 'region' => 'footer', - ); - - // Enable the most recent poll block. - $this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block')); - $this->assertText(t('The block configuration has been saved.'), '"Most recent poll" block enabled'); + // Enable the recent poll block. + $this->drupalPlaceBlock('poll_recent_block'); // Create a poll which should appear in recent polls block. $title = $this->randomName(); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchBlockTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchBlockTest.php index db977e5..b358ded 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchBlockTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchBlockTest.php @@ -7,10 +7,11 @@ namespace Drupal\search\Tests; +/** + * Tests the rendering of the search block. + */ class SearchBlockTest extends SearchTestBase { - protected $adminUser; - /** * Modules to enable. * @@ -30,27 +31,16 @@ function setUp() { parent::setUp(); // Create and login user. - $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'search content')); - $this->drupalLogin($this->adminUser); + $admin_user = $this->drupalCreateUser(array('administer blocks', 'search content')); + $this->drupalLogin($admin_user); } /** * Test that the search form block can be placed and works. */ protected function testSearchFormBlock() { - $block_id = 'search_form_block'; - $default_theme = variable_get('theme_default', 'stark'); - - $block = array( - 'title' => $this->randomName(8), - 'machine_name' => $this->randomName(8), - 'region' => 'content', - ); - - // Enable the search block. - $this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block')); - $this->assertText(t('The block configuration has been saved.'), '"Search form" block enabled'); - $this->assertText($block['title'], 'Block title was found.'); + $block = $this->drupalPlaceBlock('search_form_block'); + $this->assertText($block['subject'], 'Block title was found.'); // Test a normal search via the block form, from the front page. $terms = array('search_block_form' => 'test'); @@ -64,7 +54,6 @@ protected function testSearchFormBlock() { $this->assertResponse(200); $this->assertText('Your search yielded no results'); - $block['config_id'] = 'plugin.core.block.' . $default_theme . '.' . $block['machine_name']; $config = config($block['config_id']); $config->set('visibility.path.pages', 'search'); $config->save(); @@ -92,4 +81,5 @@ protected function testSearchFormBlock() { 'Redirected to correct url.' ); } + } diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php index e66ad90..4a7186f 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php @@ -51,11 +51,7 @@ function setUp() { search_update_totals(); // Enable the search block. - $edit = array( - 'machine_name' => 'search', - 'region' => 'content', - ); - $this->drupalPost('admin/structure/block/manage/search_form_block/stark', $edit, t('Save block')); + $this->drupalPlaceBlock('search'); } /** diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 7c71e81..d80a76e 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -383,7 +383,7 @@ protected function drupalPlaceBlock($plugin_id, array $settings = array(), $them } // If no theme was specified, use the default theme. - $theme = variable_get('theme_default', 'stark'); + $theme = $theme ?: variable_get('theme_default', 'stark'); // Populate some default block settings. $settings += array( diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php index 3454e35..1efb7fb 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php @@ -11,6 +11,7 @@ * Tests that report pages render properly, and that access logging works. */ class StatisticsReportsTest extends StatisticsTestBase { + public static function getInfo() { return array( 'name' => 'Statistics reports tests', @@ -86,16 +87,11 @@ function testPopularContentBlock() { drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000)); // Configure and save the block. - $block_id = 'statistics_popular_block'; - $default_theme = variable_get('theme_default', 'stark'); - $block = array( - 'machine_name' => $this->randomName(8), - 'region' => 'sidebar_first', + $this->drupalPlaceBlock('statistics_popular_block', array( 'statistics_block_top_day_num' => 3, 'statistics_block_top_all_num' => 3, 'statistics_block_top_last_num' => 3, - ); - $this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block')); + )); // Get some page and check if the block is displayed. $this->drupalGet('user'); @@ -106,4 +102,5 @@ function testPopularContentBlock() { $this->assertRaw(l($node->label(), 'node/' . $node->nid), 'Found link to visited node.'); } + } 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 92bfd68..9c51a89 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php @@ -17,8 +17,11 @@ class BreadcrumbTest extends MenuTestBase { * * @var array */ - public static $modules = array('menu_test'); + public static $modules = array('menu_test', 'block'); + /** + * Test paths in the Standard profile. + */ protected $profile = 'standard'; public static function getInfo() { @@ -39,14 +42,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. - $default_theme = variable_get('theme_default', 'stark'); - $admin_theme = variable_get('admin_theme', 'seven'); - $edit = array( + $settings = array( 'machine_name' => 'system_menu_tools', 'region' => 'content', ); - $this->drupalPost("admin/structure/block/manage/system_menu_block:menu-tools/{$default_theme}", $edit, t('Save block')); - $this->drupalPost("admin/structure/block/manage/system_menu_block:menu-tools/{$admin_theme}", $edit, t('Save block')); + $this->drupalPlaceBlock('system_menu_block:menu-tools', $settings); + $this->drupalPlaceBlock('system_menu_block:menu-tools', $settings, config('system.theme')->get('admin')); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php index d02e534..3dfd5c7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php @@ -33,24 +33,10 @@ function setUp() { $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'administer blocks')); $this->drupalLogin($this->admin_user); - // 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. - $default_theme = variable_get('theme_default', 'stark'); - $block = array( - 'machine_name' => $this->randomName(8), - 'region' => 'sidebar_first', - ); - $this->drupalPost("admin/structure/block/manage/system_menu_block:menu-tools/{$default_theme}", $block, t('Save block')); - - // This test puts menu links in the Administration menu and then tests for - // their presence on the page, so we need to ensure that the Administration - // block will be displayed in the default theme. - $block = array( - 'machine_name' => $this->randomName(8), - 'region' => 'sidebar_first', - ); - $this->drupalPost("admin/structure/block/manage/system_menu_block:menu-admin/{$default_theme}", $block, t('Save block')); + // This test puts menu links in the Tools and Administration menus and then + // tests for their presence on the page. + $this->drupalPlaceBlock('system_menu_block:menu-tools'); + $this->drupalPlaceBlock('system_menu_block:menu-admin'); } /** 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 af4f0a6..dc555cb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php @@ -54,13 +54,9 @@ function testAccessDenied() { $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration')); // Enable the user login block. - $edit = array( - 'machine_name' => 'login', - 'region' => 'sidebar_first', - ); - $this->drupalPost('admin/structure/block/manage/user_login_block/stark', $edit, t('Save block')); + $this->drupalPlaceBlock('user_login_block', array('machine_name' => 'login')); - // Logout and check that the user login block is shown on custom 403 pages. + // Log out and check that the user login block is shown on custom 403 pages. $this->drupalLogout(); $this->drupalGet('admin'); $this->assertText($this->admin_user->name, 'Found the custom 403 page'); 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 5bc27d2..63a5cd8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php @@ -35,26 +35,20 @@ public function setUp() { public function testBlockUpgradeTitleLength() { $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); - $block_id = 'system_powered_by_block'; - $default_theme = variable_get('theme_default', 'stark'); - $block = array( - 'machine_name' => $this->randomName(8), - 'region' => 'sidebar_first', - ); - - // Add a new custom block with a title of 255 characters. - $block['title'] = $this->randomName(255); - $this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block')); + // Add a block instance with a 255-character title. + $title = $this->randomName(255) + $this->drupalPlaceBlock('system_powered_by_block', array('title' => $title)); // Confirm that the custom block has been created, and title matches input. $this->drupalGet(''); - $this->assertText($block['title'], 'Block with title longer than 64 characters successfully created.'); + $this->assertText($title, 'Block with title longer than 64 characters successfully created.'); // Add a new custom block with a title over 255 characters. - $block['title'] = $this->randomName(256); - $this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block')); + $longer_title = $this->randomName(256); + $this->drupalPlaceBlock('system_powered_by_block', array('title' => $longer_title)); + // Confirm that the custom block cannot be created with title longer than // the maximum number of characters. - $this->assertText('Block title cannot be longer than 255 characters', 'Block with title longer than 255 characters created unsuccessfully.'); + $this->assertText('Block title cannot be longer than 255 characters'); } } diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php index c8dbdc8..fce2482 100644 --- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php +++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php @@ -56,8 +56,7 @@ function setUp() { $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.'); // Enable the language switcher block. - $edit = array('machine_name' => 'language_switcher', 'region' => 'sidebar_first'); - $this->drupalPost('admin/structure/block/manage/language_block:language_interface/bartik', $edit, t('Save block')); + $this->drupalPlaceBlock('language_block:language_interface'); // Reset static caches in our local language environment. $this->resetCaches(); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php b/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php index a4458d4..a2f027f 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php @@ -41,20 +41,7 @@ function setUp() { $this->adminUser = $this->drupalCreateUser(array('administer blocks')); $this->drupalLogin($this->adminUser); - - $block_id = 'user_login_block'; - $default_theme = variable_get('theme_default', 'stark'); - - $block = array( - 'title' => $this->randomName(8), - 'machine_name' => $this->randomName(8), - 'region' => 'sidebar_first', - ); - - // Enable the user login block. - $this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block')); - $this->assertText(t('The block configuration has been saved.'), 'User login block enabled'); - $this->plugin_id = 'plugin.core.block.' . $default_theme . '.' . $block['machine_name']; + $this->drupalPlaceBlock('user_login_block'); $this->drupalLogout($this->adminUser); } diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/OverrideDisplaysTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/OverrideDisplaysTest.php index 7d0d0cc..be4868e 100644 --- a/core/modules/views/lib/Drupal/views/Tests/UI/OverrideDisplaysTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/UI/OverrideDisplaysTest.php @@ -53,15 +53,12 @@ function testOverrideDisplays() { $this->assertResponse(200); $this->assertText($original_title); - // Put the block into the first sidebar region. - $default_theme = variable_get('theme_default', 'stark'); - $this->drupalGet("admin/structure/block/list/block_plugin_ui:{$default_theme}/add"); + // Confirm that the view block is available in the block administration UI. + $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add'); $this->assertText('View: ' . $view['human_name']); - $block = array( - 'machine_name' => $this->randomName(8), - 'region' => 'sidebar_first', - ); - $this->drupalPost("admin/structure/block/manage/views_block:{$view['name']}-block_1/{$default_theme}", $block, t('Save block')); + + // Place the block. + $this->drupalPlaceBlock("views_block:{$view['name']}-block_1"); // Make sure the title appears in the block. $this->drupalGet(''); @@ -115,15 +112,12 @@ function testWizardMixedDefaultOverriddenDisplays() { $this->assertText($view['page[title]']); $this->assertNoText($view['block[title]']); - // Put the block into the first sidebar region. - $default_theme = variable_get('theme_default', 'stark'); - $this->drupalGet("admin/structure/block/list/block_plugin_ui:{$default_theme}/add"); + // Confirm that the block is available in the block administration UI. + $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add'); $this->assertText('View: ' . $view['human_name']); - $block = array( - 'machine_name' => $this->randomName(8), - 'region' => 'sidebar_first', - ); - $this->drupalPost("admin/structure/block/manage/views_block:{$view['name']}-block_1/{$default_theme}", $block, t('Save block')); + + // Place the block. + $this->drupalPlaceBlock("views_block:{$view['name']}-block_1"); $this->drupalGet(''); $this->assertText($view['block[title]']); $this->assertNoText($view['page[title]']); diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php index 757cde2..aff9227 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php @@ -122,15 +122,12 @@ function testViewsWizardAndListing() { $this->assertText($view3['description']); $this->assertLinkByHref(url($view3['page[path]'])); - // Put the block into the first sidebar region. - $default_theme = variable_get('theme_default', 'stark'); - $this->drupalGet("admin/structure/block/list/block_plugin_ui:{$default_theme}/add"); + // Confirm that the block is available in the block administration UI. + $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add'); $this->assertText('View: ' . $view3['human_name']); - $block = array( - 'machine_name' => $this->randomName(8), - 'region' => 'sidebar_first', - ); - $this->drupalPost("admin/structure/block/manage/views_block:{$view3['name']}-block_1/{$default_theme}", $block, t('Save block')); + + // Place the block. + $this->drupalPlaceBlock("views_block:{$view3['name']}-block_1"); // Visit a random page (not the one that displays the view itself) and look // for the expected node title in the block. diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php index c5be21b..95f4709 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php @@ -74,17 +74,12 @@ function testItemsPerPage() { $pos2 = strpos($content, $node2->label()); $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, t('The nodes appear in the expected order in the page display.')); - $default_theme = variable_get('theme_default', 'stark'); - $this->drupalGet("admin/structure/block/list/block_plugin_ui:{$default_theme}/add"); + // Confirm that the block is listed in the block administration UI. + $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add'); $this->assertText('View: ' . $view['human_name']); - // Put the block into the first sidebar region, visit a page that displays - // the block, and check that the nodes we expect appear in the correct - // order. - $block = array( - 'machine_name' => $this->randomName(8), - 'region' => 'sidebar_first', - ); - $this->drupalPost("admin/structure/block/manage/views_block:{$view['name']}-block_1/{$default_theme}", $block, t('Save block')); + // Place the block, visit a page that displays the block, and check that the + // nodes we expect appear in the correct order. + $this->drupalPlaceBlock("views_block:{$view['name']}-block_1"); $this->drupalGet('user'); $content = $this->drupalGetContent();