From 44bd34cb908048f655fbadd5df0068d86e10cb10 Mon Sep 17 00:00:00 2001 From: Tor Arne Thune Date: Thu, 3 Nov 2011 09:36:00 +0100 Subject: [PATCH] Issue #1103590: Added test to ensure that hidden regions do not inherit blocks when theme is first enabled --- core/modules/block/block.test | 36 +++++++++ .../tests/block_test_theme/block_test_theme.info | 14 ++++ core/themes/tests/block_test_theme/page.tpl.php | 78 ++++++++++++++++++++ 3 files changed, 128 insertions(+), 0 deletions(-) create mode 100644 core/themes/tests/block_test_theme/block_test_theme.info create mode 100644 core/themes/tests/block_test_theme/page.tpl.php diff --git a/core/modules/block/block.test b/core/modules/block/block.test index 0b41be5..d2cc638 100644 --- a/core/modules/block/block.test +++ b/core/modules/block/block.test @@ -755,3 +755,40 @@ class BlockTemplateSuggestionsUnitTest extends DrupalUnitTestCase { $this->assertEqual($variables2['content_attributes_array']['class'], array('test-class', 'content'), t('Default .content class added to block content_attributes_array')); } } + +/** + * Tests that hidden regions do not inherit blocks when a new theme is enabled. + */ +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 newly enabled theme does not inherit blocks to its hidden + * regions. + */ + 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', t('Block was displayed on the front page.')); + } +} diff --git a/core/themes/tests/block_test_theme/block_test_theme.info b/core/themes/tests/block_test_theme/block_test_theme.info new file mode 100644 index 0000000..6b15fe5 --- /dev/null +++ b/core/themes/tests/block_test_theme/block_test_theme.info @@ -0,0 +1,14 @@ +name = Block test theme +description = Theme for testing the block system +core = 8.x +hidden = TRUE + +regions[sidebar_first] = Left sidebar +regions_hidden[] = sidebar_first +regions[sidebar_second] = Right sidebar +regions_hidden[] = sidebar_second +regions[content] = Content +regions[header] = Header +regions[footer] = Footer +regions[highlighted] = Highlighted +regions[help] = Help diff --git a/core/themes/tests/block_test_theme/page.tpl.php b/core/themes/tests/block_test_theme/page.tpl.php new file mode 100644 index 0000000..ba72882 --- /dev/null +++ b/core/themes/tests/block_test_theme/page.tpl.php @@ -0,0 +1,78 @@ + + +
+ + + + + + + + + + + + + +
+ +
+
+ + +

+ +
+ + + + +
+
+ + + +
-- 1.7.5.4