From 9a836865917b6132fd8f9e8977f415d93ef6027f Mon Sep 17 00:00:00 2001 From: Tor Arne Thune Date: Thu, 14 Jul 2011 13:06:24 +0200 Subject: [PATCH] Issue #1103590: Test for ensuring that blocks not inherited to hidden region when first enabling theme --- modules/block/block.test | 38 +++++++++++++++++++- .../tests/block_test_theme/block_test_theme.info | 12 ++++++ 2 files changed, 49 insertions(+), 1 deletions(-) create mode 100644 themes/tests/block_test_theme/block_test_theme.info diff --git a/modules/block/block.test b/modules/block/block.test index 022bf38..9c5afdd 100644 --- a/modules/block/block.test +++ b/modules/block/block.test @@ -83,7 +83,7 @@ class BlockTestCase extends DrupalWebTestCase { $this->assertTrue(array_key_exists('subject', $data) && empty($data['subject']), t('block_block_view() provides an empty block subject, since custom blocks do not have default titles.')); $this->assertEqual(check_markup($custom_block['body[value]'], $format), $data['content'], t('block_block_view() provides correct block content.')); - // Check if the block can be moved to all availble regions. + // Check if the block can be moved to all available regions. $custom_block['module'] = 'block'; $custom_block['delta'] = $bid; foreach ($this->regions as $region) { @@ -708,3 +708,39 @@ class BlockTemplateSuggestionsUnitTest extends DrupalUnitTestCase { $this->assertEqual($variables2['theme_hook_suggestions'], array('block__footer', 'block__block', 'block__block__hyphen_test'), t('Hyphens (-) in block delta were replaced by underscore (_)')); } } + +/** + * Test blocks not inherited to hidden regions when enabling new theme. + */ +class BlockHiddenRegionTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Blocks not in hidden region', + 'description' => 'Checks that a newly enabled theme does not inherit blocks to its hidden regions.', + 'group' => 'Block', + ); + } + + /** + * Checks that a block is not inherited to hidden region of newly enabled theme. + */ + function testBlockNotInHiddenRegion() { + // Create administrative user. + $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes', 'search content')); + $this->drupalLogin($admin_user); + + // Enable "block_test_theme" and set it as the default theme. + $theme = 'block_test_theme'; + theme_enable(array($theme)); + variable_set('theme_default', $theme); + menu_rebuild(); + + // Ensure that "block_test_theme" is set as the default theme. + $this->drupalGet('admin/structure/block'); + $this->assertText('Block test theme(' . t('active tab') . ')', t('Default local task on blocks admin page is the block test theme.')); + + // Ensure that the search form block is displayed. + $this->drupalGet(''); + $this->assertText('Search form', t('Block was displayed on the front page.')); + } +} diff --git a/themes/tests/block_test_theme/block_test_theme.info b/themes/tests/block_test_theme/block_test_theme.info new file mode 100644 index 0000000..fb70cb3 --- /dev/null +++ b/themes/tests/block_test_theme/block_test_theme.info @@ -0,0 +1,12 @@ +name = Block test theme +description = Theme for testing the block system +core = 8.x +hidden = TRUE + +regions_hidden[sidebar_first] = Left sidebar +regions_hidden[sidebar_second] = Right sidebar +regions[content] = Content +regions[header] = Header +regions[footer] = Footer +regions[highlighted] = Highlighted +regions[help] = Help -- 1.7.4.1