summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-05-31 07:46:54 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-05-31 07:46:54 +0000
commit2c1bb05313377c9df76bd068f52c9ec632ce13bb (patch)
tree7ff805a778fc9cabf8654853292af50bf581d9cc
parent3876e6acc6661926d756031d335ea634f2c19c0a (diff)
downloadbrdo-2c1bb05313377c9df76bd068f52c9ec632ce13bb.tar.gz
brdo-2c1bb05313377c9df76bd068f52c9ec632ce13bb.tar.bz2
#473080 by chx: Fix bug where switching themes would result in zero blocks (including content area). with tests.
-rw-r--r--modules/block/block.module5
-rw-r--r--modules/block/block.test44
2 files changed, 48 insertions, 1 deletions
diff --git a/modules/block/block.module b/modules/block/block.module
index 841761cdf..b12f44113 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -483,7 +483,10 @@ function block_form_system_performance_settings_alter(&$form, &$form_state) {
* Implement hook_form_FORM_ID_alter().
*/
function block_form_system_themes_form_alter(&$form, &$form_state) {
- $form['#submit'][] = 'block_system_themes_form_submit';
+ // This function needs to fire before the theme changes are recorded in the
+ // database, otherwise it will populate the default list of blocks from the
+ // new theme, which is empty.
+ array_unshift($form['#submit'], 'block_system_themes_form_submit');
}
/**
diff --git a/modules/block/block.test b/modules/block/block.test
index 9cef03036..9dcd199b6 100644
--- a/modules/block/block.test
+++ b/modules/block/block.test
@@ -193,6 +193,50 @@ class NonDefaultBlockAdmin extends DrupalWebTestCase {
}
/**
+ * Test blocks correctly initialized when picking a new default theme.
+ */
+class NewDefaultThemeBlocks extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => t('New default theme blocks'),
+ 'description' => t('Checks that the new default theme gets blocks.'),
+ 'group' => t('Block'),
+ );
+ }
+
+ /**
+ * Check the enabled Garland blocks are correctly copied over.
+ */
+ function testNewDefaultThemeBlocks() {
+ // Create administrative user.
+ $admin_user = $this->drupalCreateUser(array('administer site configuration'));
+ $this->drupalLogin($admin_user);
+
+ // Ensure no other theme's blocks are in the block table yet.
+ $count = db_query_range("SELECT 1 FROM {block} WHERE theme != 'garland'", 0, 1)->fetchField();
+ $this->assertFalse($count, t('Only Garland has blocks.'));
+
+ // Populate list of all blocks for matching against new theme.
+ $blocks = array();
+ $result = db_query('SELECT * FROM {block}');
+ foreach ($result as $block) {
+ // $block->theme and $block->bid will not match, so remove them.
+ unset($block->theme, $block->bid);
+ $blocks[$block->module][$block->delta] = $block;
+ }
+
+ // Turn on the Stark theme and ensure that it contains all of the blocks
+ // that Garland did.
+ $this->drupalPost('admin/build/themes', array('theme_default' => 'stark'), t('Save configuration'));
+ $result = db_query("SELECT * FROM {block} WHERE theme='stark'");
+ foreach ($result as $block) {
+ unset($block->theme, $block->bid);
+ $this->assertEqual($blocks[$block->module][$block->delta], $block, t('Block matched'));
+ }
+ }
+}
+
+/**
* Test the block system with admin themes.
*/
class BlockAdminThemeTestCase extends DrupalWebTestCase {